Documentation

Overview

    Package reminder holds Reminder to avoid circular dependencies.

    Index

    Constants

    View Source
    const FreshUntilPrecision = time.Millisecond

      FreshUntilPrecision is precision of Reminder.FreshUntil, to which it is always truncated.

      Variables

      This section is empty.

      Functions

      This section is empty.

      Types

      type Payload

      type Payload struct {
      	TaskClass string        // corresponding TaskClass.ID, for metrics
      	Created   time.Time     // when AddTask was called, for metrics
      	Raw       proto.Message // a proto passed to AddTask, available only on happy path
      
      	CreateTaskRequest *taskspb.CreateTaskRequest // prepared Cloud Tasks request
      	PublishRequest    *pubsubpb.PublishRequest   // prepared PubSub request
      }

        Payload incapsulates the Reminder's payload.

        It is produced by Dispatcher and is ultimately consumed by Submitter. It is either produced and consumed in the same process (on a "happy path"), or it may travel between processes by being stored in a serialized form inside a Reminder (as its RawPayload), see Reminder.AttachPayload.

        type Reminder

        type Reminder struct {
        	// ID identifies a reminder.
        	//
        	// ID values are always in hex-encoded and are well distributed in keyspace.
        	ID string
        
        	// FreshUntil is the expected time by which the happy path should complete.
        	//
        	// If the sweeper encounters a Reminder before this time, the sweeper ignores
        	// it to allow the happy path to complete.
        	//
        	// Truncated to FreshUntilPrecision.
        	FreshUntil time.Time
        
        	// RawPayload is a proto-serialized tqpb.Payload.
        	//
        	// It is what is actually stored in the database.
        	RawPayload []byte
        	// contains filtered or unexported fields
        }

          Reminder reminds to enqueue a task.

          It is persisted transactionally with some other user logic to the database. Later, a task is actually scheduled and a reminder can be deleted non-transactionally.

          Its payload is represented either by a raw byte buffer (when the reminder is stored and loaded), or by a more complex Go value (when the reminder is manipulated by Dispatcher and Submitter). The Go value representation is described by Payload struct and it can be "attached" to the reminder via AttachReminder() or deserialized from the raw byte buffer via Payload().

          func (*Reminder) AttachPayload

          func (r *Reminder) AttachPayload(p *Payload) error

            AttachPayload attaches the given payload to this reminder.

            It mutates `p` with reminder's ID, which should already be populated.

            Panics if `r` has a payload attached already.

            func (*Reminder) DropPayload

            func (r *Reminder) DropPayload() *Reminder

              DropPayload returns a copy of the reminder without attached payload.

              func (*Reminder) MustHavePayload

              func (r *Reminder) MustHavePayload() *Payload

                MustHavePayload returns an attached payload or panics if `r` doesn't have a payload attached.

                Does not attempt to deserialize RawPayload.

                func (*Reminder) Payload

                func (r *Reminder) Payload() (*Payload, error)

                  Payload returns an attached payload, perhaps deserializing it first.