api

package
v1.15.0-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultIdleTimeout = time.Minute * 60

	DefaultOngoingCallTimeout   = time.Second * 60
	DefaultReentrancyStackLimit = 32
)
View Source
const (
	DaprSeparator = "||"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActorHostedRequest

type ActorHostedRequest struct {
	ActorID   string `json:"actorId"`
	ActorType string `json:"actorType"`
}

ActorHostedRequest is the request object for checking if an actor is hosted on this instance.

func (ActorHostedRequest) ActorKey

func (r ActorHostedRequest) ActorKey() string

ActorKey returns the key of the actor for this request.

type BulkStateResponse

type BulkStateResponse map[string][]byte

BulkStateResponse is the response returned from getting an actor state in bulk. It's a map where the key is the key of the state, and the value is the value as byte slice.

type CreateReminderRequest

type CreateReminderRequest struct {
	Name      string
	ActorType string
	ActorID   string
	Data      *anypb.Any `json:"data"`
	DueTime   string     `json:"dueTime"`
	Period    string     `json:"period"`
	TTL       string     `json:"ttl"`
	IsOneShot bool       `json:"-"`
}

CreateReminderRequest is the request object to create a new reminder.

func (CreateReminderRequest) ActorKey

func (req CreateReminderRequest) ActorKey() string

ActorKey returns the key of the actor for this reminder.

func (CreateReminderRequest) Key

func (req CreateReminderRequest) Key() string

Key returns the key for this unique reminder.

func (CreateReminderRequest) NewReminder

func (req CreateReminderRequest) NewReminder(now time.Time) (reminder *Reminder, err error)

NewReminder returns a new Reminder from a CreateReminderRequest object.

func (*CreateReminderRequest) UnmarshalJSON

func (req *CreateReminderRequest) UnmarshalJSON(data []byte) error

type CreateTimerRequest

type CreateTimerRequest struct {
	Name      string
	ActorType string
	ActorID   string
	DueTime   string     `json:"dueTime"`
	Period    string     `json:"period"`
	TTL       string     `json:"ttl"`
	Callback  string     `json:"callback"`
	Data      *anypb.Any `json:"data"`
}

CreateTimerRequest is the request object to create a new timer.

func (CreateTimerRequest) ActorKey

func (req CreateTimerRequest) ActorKey() string

ActorKey returns the key of the actor for this timer.

func (CreateTimerRequest) Key

func (req CreateTimerRequest) Key() string

Key returns the key for this unique timer.

func (CreateTimerRequest) NewReminder

func (req CreateTimerRequest) NewReminder(now time.Time) (reminder *Reminder, err error)

NewReminder returns a new Timer from a CreateTimerRequest object.

func (*CreateTimerRequest) UnmarshalJSON

func (req *CreateTimerRequest) UnmarshalJSON(data []byte) error

type DeleteReminderRequest

type DeleteReminderRequest struct {
	Name      string
	ActorType string
	ActorID   string
}

DeleteReminderRequest is the request object for deleting a reminder.

func (DeleteReminderRequest) ActorKey

func (req DeleteReminderRequest) ActorKey() string

ActorKey returns the key of the actor for this reminder.

func (DeleteReminderRequest) Key

func (req DeleteReminderRequest) Key() string

Key returns the key for this unique reminder.

type DeleteStateRequest

type DeleteStateRequest struct {
	ActorID   string `json:"actorId"`
	ActorType string `json:"actorType"`
	Key       string `json:"key"`
}

DeleteStateRequest is the request object for deleting an actor state.

func (DeleteStateRequest) ActorKey

func (r DeleteStateRequest) ActorKey() string

ActorKey returns the key of the actor for this request.

type DeleteTimerRequest

type DeleteTimerRequest struct {
	Name      string
	ActorType string
	ActorID   string
}

DeleteTimerRequest is a request object for deleting a timer.

func (DeleteTimerRequest) ActorKey

func (req DeleteTimerRequest) ActorKey() string

ActorKey returns the key of the actor for this timer.

func (DeleteTimerRequest) Key

func (req DeleteTimerRequest) Key() string

Key returns the key for this unique timer.

type EntityConfig

type EntityConfig struct {
	Entities                   []string
	ActorIdleTimeout           time.Duration
	DrainOngoingCallTimeout    time.Duration
	DrainRebalancedActors      bool
	ReentrancyConfig           config.ReentrancyConfig
	RemindersStoragePartitions int
}

Remap of config.EntityConfig.

func TranslateEntityConfig

func TranslateEntityConfig(appConfig config.EntityConfig) EntityConfig

TranslateEntityConfig converts a user-defined configuration into a domain-specific EntityConfig.

type GetBulkStateRequest

type GetBulkStateRequest struct {
	ActorID   string   `json:"actorId"`
	ActorType string   `json:"actorType"`
	Keys      []string `json:"keys"`
}

GetBulkStateRequest is the request object for getting bulk actor state.

func (GetBulkStateRequest) ActorKey

func (r GetBulkStateRequest) ActorKey() string

ActorKey returns the key of the actor for this request.

type GetReminderRequest

type GetReminderRequest struct {
	Name      string
	ActorType string
	ActorID   string
}

GetReminderRequest is the request object to get an existing reminder.

type GetStateRequest

type GetStateRequest struct {
	ActorID   string `json:"actorId"`
	ActorType string `json:"actorType"`
	Key       string `json:"key"`
}

GetStateRequest is the request object for getting actor state.

func (GetStateRequest) ActorKey

func (r GetStateRequest) ActorKey() string

ActorKey returns the key of the actor for this request.

type ListRemindersRequest

type ListRemindersRequest struct {
	ActorType string
}

type LookupActorRequest

type LookupActorRequest struct {
	ActorType string
	ActorID   string
	NoCache   bool
}

LookupActorRequest is the request for LookupActor.

func (LookupActorRequest) ActorKey

func (lar LookupActorRequest) ActorKey() string

ActorKey returns the key for the actor, which is "type/id".

type LookupActorResponse

type LookupActorResponse struct {
	Address string
	AppID   string
	Local   bool
}

LookupActorResponse is the response from LookupActor.

type OperationType

type OperationType string

OperationType describes a CRUD operation performed against a state store.

const (
	// Upsert is an update or create operation.
	Upsert OperationType = "upsert"
	// Delete is a delete operation.
	Delete OperationType = "delete"
)

type Reminder

type Reminder struct {
	ActorID        string         `json:"actorID,omitempty"`
	ActorType      string         `json:"actorType,omitempty"`
	Name           string         `json:"name,omitempty"`
	Data           *anypb.Any     `json:"data,omitempty"`
	Period         ReminderPeriod `json:"period,omitempty"`
	RegisteredTime time.Time      `json:"registeredTime,omitempty"`
	DueTime        string         `json:"dueTime,omitempty"` // Exact input value from user
	ExpirationTime time.Time      `json:"expirationTime,omitempty"`
	Callback       string         `json:"callback,omitempty"` // Used by timers only
	IsTimer        bool           `json:"-"`
	IsRemote       bool           `json:"-"`
}

Reminder represents a reminder or timer for a unique actor.

func (Reminder) ActorKey

func (r Reminder) ActorKey() string

ActorKey returns the key of the actor for this reminder.

func (Reminder) HasRepeats

func (r Reminder) HasRepeats() bool

HasRepeats returns true if the reminder has repeats left.

func (Reminder) Key

func (r Reminder) Key() string

Key returns the key for this unique reminder.

func (*Reminder) MarshalBSON

func (r *Reminder) MarshalBSON() ([]byte, error)

MarshalBSON implements bson.Marshaler. It encodes the message into a map[string]any before calling bson.Marshal.

func (*Reminder) MarshalJSON

func (r *Reminder) MarshalJSON() ([]byte, error)

func (Reminder) NextTick

func (r Reminder) NextTick() (time.Time, bool)

NextTick returns the time the reminder should tick again next. If the reminder has a TTL and the next tick is beyond the TTL, the second returned value will be false.

func (Reminder) RepeatsLeft

func (r Reminder) RepeatsLeft() int

RepeatsLeft returns the number of repeats left.

func (*Reminder) RequiresUpdating

func (r *Reminder) RequiresUpdating(new *Reminder) bool

func (Reminder) ScheduledTime

func (r Reminder) ScheduledTime() time.Time

ScheduledTime returns the time the reminder is scheduled to be executed at. This is implemented to comply with the queueable interface.

func (Reminder) String

func (r Reminder) String() string

String implements fmt.Stringer and is used for debugging.

func (*Reminder) TickExecuted

func (r *Reminder) TickExecuted() (done bool)

TickExecuted should be called after a reminder has been executed. "done" will be true if the reminder is done, i.e. no more executions should happen. If the reminder is not done, call "NextTick" to get the time it should tick next. Note: this method is not concurrency-safe.

func (*Reminder) UnmarshalJSON

func (r *Reminder) UnmarshalJSON(data []byte) error

func (*Reminder) UpdateFromTrack

func (r *Reminder) UpdateFromTrack(track *ReminderTrack)

UpdateFromTrack updates the reminder with data from the track object.

type ReminderPeriod

type ReminderPeriod struct {
	// contains filtered or unexported fields
}

ReminderPeriod contains the parsed period for a reminder.

func NewEmptyReminderPeriod

func NewEmptyReminderPeriod() ReminderPeriod

NewEmptyReminderPeriod returns an empty ReminderPeriod, which has unlimited repeats.

func NewReminderPeriod

func NewReminderPeriod(val string) (p ReminderPeriod, err error)

NewReminderPeriod parses a reminder period from a string and validates it.

func NewSchedulerReminderPeriod

func NewSchedulerReminderPeriod(val string, repeats uint32) ReminderPeriod

NewSchedulerReminderPeriod returns a new reminder period from the Scheduler service job schedule.

func (ReminderPeriod) GetFollowing

func (p ReminderPeriod) GetFollowing(t time.Time) time.Time

GetFollowing returns the next time the periodic reminder should fire after a given time.

func (ReminderPeriod) HasRepeats

func (p ReminderPeriod) HasRepeats() bool

HasRepeats returns true if the period will repeat.

func (ReminderPeriod) MarshalJSON

func (p ReminderPeriod) MarshalJSON() ([]byte, error)

func (ReminderPeriod) String

func (p ReminderPeriod) String() string

String implements fmt.Stringer. It returns the value.

func (*ReminderPeriod) UnmarshalJSON

func (p *ReminderPeriod) UnmarshalJSON(data []byte) error

type ReminderResponse

type ReminderResponse struct {
	Data    *anypb.Any `json:"data"`
	DueTime string     `json:"dueTime"`
	Period  string     `json:"period"`
}

ReminderResponse is the payload that is sent to an Actor SDK API for execution.

func (*ReminderResponse) MarshalJSON

func (r *ReminderResponse) MarshalJSON() ([]byte, error)

MarshalJSON is a custom JSON marshaler that encodes the data as JSON. Actor SDKs expect "data" to be a base64-encoded message with the JSON representation of the data, so this makes sure that happens. This method implements the json.Marshaler interface.

type ReminderTrack

type ReminderTrack struct {
	LastFiredTime  time.Time `json:"lastFiredTime"`
	RepetitionLeft int       `json:"repetitionLeft"`
	Etag           *string   `json:",omitempty"`
}

ReminderTrack is a persisted object that keeps track of the last time a reminder fired.

func (*ReminderTrack) MarshalJSON

func (r *ReminderTrack) MarshalJSON() ([]byte, error)

func (*ReminderTrack) UnmarshalJSON

func (r *ReminderTrack) UnmarshalJSON(data []byte) error

type SaveStateRequest

type SaveStateRequest struct {
	ActorID   string `json:"actorId"`
	ActorType string `json:"actorType"`
	Key       string `json:"key"`
	Value     any    `json:"value"`
}

SaveStateRequest is the request object for saving an actor state.

type StateOperationOpts

type StateOperationOpts struct {
	Metadata    map[string]string
	ContentType *string

	// TODO: @joshvanl Remove in Dapr 1.12 when ActorStateTTL is finalized.
	StateTTLEnabled bool
}

Options for the StateOperation method

type StateResponse

type StateResponse struct {
	Data     []byte            `json:"data"`
	Metadata map[string]string `json:"metadata"`
}

StateResponse is the response returned from getting an actor state.

type TimerResponse

type TimerResponse struct {
	Callback string     `json:"callback"`
	Data     *anypb.Any `json:"data"`
	DueTime  string     `json:"dueTime"`
	Period   string     `json:"period"`
}

TimerResponse is the response object send to an Actor SDK API when a timer fires.

func (*TimerResponse) MarshalJSON

func (t *TimerResponse) MarshalJSON() ([]byte, error)

MarshalJSON is a custom JSON marshaler that encodes the data as JSON. Actor SDKs expect "data" to be a base64-encoded message with the JSON representation of the data, so this makes sure that happens. This method implements the json.Marshaler interface.

type TransactionalDelete

type TransactionalDelete struct {
	Key  string  `json:"key"`
	ETag *string `json:"etag,omitempty"`
}

TransactionalDelete defined a delete operation.

func (TransactionalDelete) StateOperation

func (t TransactionalDelete) StateOperation(baseKey string, opts StateOperationOpts) (op state.TransactionalStateOperation, err error)

StateOperation returns the state.TransactionalStateOperation object.

type TransactionalOperation

type TransactionalOperation struct {
	Operation OperationType `json:"operation"`
	Request   any           `json:"request"`
}

TransactionalOperation is the request object for a state operation participating in a transaction.

func (TransactionalOperation) StateOperation

func (t TransactionalOperation) StateOperation(baseKey string, opts StateOperationOpts) (op state.TransactionalStateOperation, err error)

StateOperation returns the state.TransactionalStateOperation object.

type TransactionalRequest

type TransactionalRequest struct {
	Operations []TransactionalOperation `json:"operations"`
	ActorType  string
	ActorID    string
}

TransactionalRequest describes a set of stateful operations for a given actor that are performed in a transactional manner.

func (TransactionalRequest) ActorKey

func (r TransactionalRequest) ActorKey() string

ActorKey returns the key of the actor for this request.

type TransactionalUpsert

type TransactionalUpsert struct {
	Key      string            `json:"key"`
	Value    any               `json:"value"`
	ETag     *string           `json:"etag,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

TransactionalUpsert defines a key/value pair for an upsert operation.

func (TransactionalUpsert) StateOperation

func (t TransactionalUpsert) StateOperation(baseKey string, opts StateOperationOpts) (op state.TransactionalStateOperation, err error)

StateOperation returns the state.TransactionalStateOperation object.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL