Documentation ¶
Index ¶
- Constants
- Variables
- func NewHostedActors(actorTypes []string) *hostedActors
- type ActorsProviderOptions
- type AppHealthFn
- type Config
- type CreateReminderRequest
- type CreateTimerRequest
- type DeleteReminderRequest
- type DeleteTimerRequest
- type EntityConfig
- type ExecuteReminderFn
- type ExecuteTimerFn
- type GetReminderRequest
- type HaltActorFn
- type HaltAllActorsFn
- type LookupActorFn
- type LookupActorRequest
- type LookupActorResponse
- type PlacementService
- type Reminder
- func (r Reminder) ActorKey() string
- func (r Reminder) HasRepeats() bool
- func (r Reminder) Key() string
- func (r *Reminder) MarshalBSON() ([]byte, error)
- func (r *Reminder) MarshalJSON() ([]byte, error)
- func (r Reminder) NextTick() (time.Time, bool)
- func (r Reminder) RepeatsLeft() int
- func (r *Reminder) RequiresUpdating(new *Reminder) bool
- func (r Reminder) ScheduledTime() time.Time
- func (r Reminder) String() string
- func (r *Reminder) TickExecuted() (done bool)
- func (r *Reminder) UnmarshalJSON(data []byte) error
- func (r *Reminder) UpdateFromTrack(track *ReminderTrack)
- type ReminderPeriod
- type ReminderTrack
- type RemindersProvider
- type StateStoreProviderFn
- type TimersProvider
- type TransactionalStateStore
Constants ¶
const ( // APILevelFeatureRemindersProtobuf Enables serializing reminders as protobuf rather than JSON in the pkg/actors/reminders package // When serialized as protobuf, reminders have the "\0pb" prefix // Note this only control serializations; when un-serializing, legacy JSON is always supported as fallback APILevelFeatureRemindersProtobuf apiLevelFeature = 20 )
const ActorAPILevel = 20
ActorAPILevel is the level of the Actor APIs supported by this runtime. It is sent to the Placement service and disseminated to all other Dapr runtimes. The Dapr runtime can use this value, as well as the minimum API level observed in the cluster (as disseminated by Placement) to make decisions on feature availability across the cluster.
API levels per Dapr version: - 1.11.x and older = unset (equivalent to 0) - 1.12.x = 10 - 1.13.x = 20
Variables ¶
var ErrReminderCanceled = errors.New("reminder has been canceled")
ErrReminderCanceled is returned when the reminder has been canceled.
Functions ¶
func NewHostedActors ¶ added in v1.12.0
func NewHostedActors(actorTypes []string) *hostedActors
NewHostedActors creates a new hostedActors from a slice of actor types.
Types ¶
type ActorsProviderOptions ¶ added in v1.13.0
type ActorsProviderOptions struct { Config Config Security security.Handler Resiliency resiliency.Provider AppHealthFn AppHealthFn // Pointer to the API level object APILevel *atomic.Uint32 Clock kclock.WithTicker }
ActorsProviderOptions contains the options for providers of actors services.
type AppHealthFn ¶ added in v1.13.0
AppHealthFn is a function that returns a channel which is notified of changes in app health status.
type Config ¶ added in v1.12.0
type Config struct { HostAddress string AppID string ActorsService string RemindersService string HostedActorTypes *hostedActors Port int HeartbeatInterval time.Duration ActorDeactivationScanInterval time.Duration ActorIdleTimeout time.Duration DrainOngoingCallTimeout time.Duration DrainRebalancedActors bool Namespace string Reentrancy daprAppConfig.ReentrancyConfig RemindersStoragePartitions int EntityConfigs map[string]EntityConfig HealthHTTPClient *http.Client HealthEndpoint string AppChannelAddress string PodName string }
Config is the actor runtime configuration.
func (*Config) GetRemindersPartitionCountForType ¶ added in v1.12.0
func (Config) GetRuntimeHostname ¶ added in v1.12.0
type CreateReminderRequest ¶ added in v1.12.0
type CreateReminderRequest struct { Name string ActorType string ActorID string Data json.RawMessage `json:"data"` DueTime string `json:"dueTime"` Period string `json:"period"` TTL string `json:"ttl"` }
CreateReminderRequest is the request object to create a new reminder.
func (CreateReminderRequest) ActorKey ¶ added in v1.12.0
func (req CreateReminderRequest) ActorKey() string
ActorKey returns the key of the actor for this reminder.
func (CreateReminderRequest) Key ¶ added in v1.12.0
func (req CreateReminderRequest) Key() string
Key returns the key for this unique reminder.
func (CreateReminderRequest) NewReminder ¶ added in v1.12.0
func (req CreateReminderRequest) NewReminder(now time.Time) (reminder *Reminder, err error)
NewReminder returns a new Reminder from a CreateReminderRequest object.
type CreateTimerRequest ¶ added in v1.12.0
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 json.RawMessage `json:"data"` }
CreateTimerRequest is the request object to create a new timer.
func (CreateTimerRequest) ActorKey ¶ added in v1.12.0
func (req CreateTimerRequest) ActorKey() string
ActorKey returns the key of the actor for this timer.
func (CreateTimerRequest) Key ¶ added in v1.12.0
func (req CreateTimerRequest) Key() string
Key returns the key for this unique timer.
func (CreateTimerRequest) NewReminder ¶ added in v1.12.0
func (req CreateTimerRequest) NewReminder(now time.Time) (reminder *Reminder, err error)
NewReminder returns a new Timer from a CreateTimerRequest object.
type DeleteReminderRequest ¶ added in v1.12.0
DeleteReminderRequest is the request object for deleting a reminder.
func (DeleteReminderRequest) ActorKey ¶ added in v1.12.0
func (req DeleteReminderRequest) ActorKey() string
ActorKey returns the key of the actor for this reminder.
func (DeleteReminderRequest) Key ¶ added in v1.12.0
func (req DeleteReminderRequest) Key() string
Key returns the key for this unique reminder.
type DeleteTimerRequest ¶ added in v1.12.0
DeleteTimerRequest is a request object for deleting a timer.
func (DeleteTimerRequest) ActorKey ¶ added in v1.12.0
func (req DeleteTimerRequest) ActorKey() string
ActorKey returns the key of the actor for this timer.
func (DeleteTimerRequest) Key ¶ added in v1.12.0
func (req DeleteTimerRequest) Key() string
Key returns the key for this unique timer.
type EntityConfig ¶ added in v1.12.0
type EntityConfig struct { Entities []string ActorIdleTimeout time.Duration DrainOngoingCallTimeout time.Duration DrainRebalancedActors bool ReentrancyConfig daprAppConfig.ReentrancyConfig RemindersStoragePartitions int }
Remap of daprAppConfig.EntityConfig but with more useful types for actors.go.
type ExecuteReminderFn ¶ added in v1.12.0
ExecuteReminderFn is the type of the function invoked when a reminder is to be executed. If this method returns false, the reminder is canceled by the actor.
type ExecuteTimerFn ¶ added in v1.12.0
ExecuteTimerFn is the type of the function invoked when a timer is to be executed. If this method returns false, the timer does not repeat.
type GetReminderRequest ¶ added in v1.12.0
GetReminderRequest is the request object to get an existing reminder.
type HaltActorFn ¶ added in v1.13.0
HaltActorFn is the signature of the function invoked when the placement service requires an actor to be deactivated.
type HaltAllActorsFn ¶ added in v1.13.0
type HaltAllActorsFn = func() error
HaltAllActorsFn is the signature of the function invoked when the placement service requires all actors to be deactivated.
type LookupActorFn ¶ added in v1.12.0
type LookupActorFn func(ctx context.Context, actorType string, actorID string) (isLocal bool, actorAddress string)
LookupActorFn is the type of a function that returns whether an actor is locally-hosted and the address of its host.
type LookupActorRequest ¶ added in v1.12.0
LookupActorRequest is the request for LookupActor.
func (LookupActorRequest) ActorKey ¶ added in v1.12.0
func (lar LookupActorRequest) ActorKey() string
ActorKey returns the key for the actor, which is "type/id".
type LookupActorResponse ¶ added in v1.12.0
LookupActorResponse is the response from LookupActor.
type PlacementService ¶ added in v1.12.0
type PlacementService interface { io.Closer Start(context.Context) error WaitUntilReady(ctx context.Context) error LookupActor(ctx context.Context, req LookupActorRequest) (LookupActorResponse, error) AddHostedActorType(actorType string, idleTimeout time.Duration) error ReportActorDeactivation(ctx context.Context, actorType, actorID string) error SetHaltActorFns(haltFn HaltActorFn, haltAllFn HaltAllActorsFn) SetOnAPILevelUpdate(fn func(apiLevel uint32)) SetOnTableUpdateFn(fn func()) // PlacementHealthy returns true if the placement service is healthy. PlacementHealthy() bool // StatusMessage returns a custom status message. StatusMessage() string }
PlacementService allows for interacting with the actor placement service.
type Reminder ¶ added in v1.12.0
type Reminder struct { ActorID string `json:"actorID,omitempty"` ActorType string `json:"actorType,omitempty"` Name string `json:"name,omitempty"` Data json.RawMessage `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 }
Reminder represents a reminder or timer for a unique actor.
func (Reminder) ActorKey ¶ added in v1.12.0
ActorKey returns the key of the actor for this reminder.
func (Reminder) HasRepeats ¶ added in v1.12.0
HasRepeats returns true if the reminder has repeats left.
func (*Reminder) MarshalBSON ¶ added in v1.12.0
MarshalBSON implements bson.Marshaler. It encodes the message into a map[string]any before calling bson.Marshal.
func (*Reminder) MarshalJSON ¶ added in v1.12.0
func (Reminder) NextTick ¶ added in v1.12.0
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 ¶ added in v1.12.0
RepeatsLeft returns the number of repeats left.
func (*Reminder) RequiresUpdating ¶ added in v1.12.0
func (Reminder) ScheduledTime ¶ added in v1.12.0
ScheduledTime returns the time the reminder is scheduled to be executed at. This is implemented to comply with the queueable interface.
func (*Reminder) TickExecuted ¶ added in v1.12.0
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 ¶ added in v1.12.0
func (*Reminder) UpdateFromTrack ¶ added in v1.12.0
func (r *Reminder) UpdateFromTrack(track *ReminderTrack)
UpdateFromTrack updates the reminder with data from the track object.
type ReminderPeriod ¶ added in v1.12.0
type ReminderPeriod struct {
// contains filtered or unexported fields
}
ReminderPeriod contains the parsed period for a reminder.
func NewEmptyReminderPeriod ¶ added in v1.12.0
func NewEmptyReminderPeriod() ReminderPeriod
NewEmptyReminderPeriod returns an empty ReminderPeriod, which has unlimited repeats.
func NewReminderPeriod ¶ added in v1.12.0
func NewReminderPeriod(val string) (p ReminderPeriod, err error)
NewReminderPeriod parses a reminder period from a string and validates it.
func (ReminderPeriod) GetFollowing ¶ added in v1.12.0
func (p ReminderPeriod) GetFollowing(t time.Time) time.Time
GetNext returns the next time the periodic reminder should fire after a given time.
func (ReminderPeriod) HasRepeats ¶ added in v1.12.0
func (p ReminderPeriod) HasRepeats() bool
HasRepeats returns true if the period will repeat.
func (ReminderPeriod) MarshalJSON ¶ added in v1.12.0
func (p ReminderPeriod) MarshalJSON() ([]byte, error)
func (ReminderPeriod) String ¶ added in v1.12.0
func (p ReminderPeriod) String() string
String implements fmt.Stringer. It returns the value.
func (*ReminderPeriod) UnmarshalJSON ¶ added in v1.12.0
func (p *ReminderPeriod) UnmarshalJSON(data []byte) error
type ReminderTrack ¶ added in v1.12.0
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 ¶ added in v1.12.0
func (r *ReminderTrack) MarshalJSON() ([]byte, error)
func (*ReminderTrack) UnmarshalJSON ¶ added in v1.12.0
func (r *ReminderTrack) UnmarshalJSON(data []byte) error
type RemindersProvider ¶ added in v1.12.0
type RemindersProvider interface { io.Closer Init(ctx context.Context) error GetReminder(ctx context.Context, req *GetReminderRequest) (*Reminder, error) CreateReminder(ctx context.Context, req *Reminder) error DeleteReminder(ctx context.Context, req DeleteReminderRequest) error DrainRebalancedReminders(actorType string, actorID string) OnPlacementTablesUpdated(ctx context.Context) SetExecuteReminderFn(fn ExecuteReminderFn) SetStateStoreProviderFn(fn StateStoreProviderFn) SetLookupActorFn(fn LookupActorFn) }
RemindersProvider is the interface for the object that provides reminders services.
type StateStoreProviderFn ¶ added in v1.12.0
type StateStoreProviderFn func() (string, TransactionalStateStore, error)
StateStoreProviderFn is the type of a function that returns the state store provider and its name.
type TimersProvider ¶ added in v1.12.0
type TimersProvider interface { io.Closer Init(ctx context.Context) error CreateTimer(ctx context.Context, reminder *Reminder) error DeleteTimer(ctx context.Context, timerKey string) error GetActiveTimersCount(actorKey string) int64 SetExecuteTimerFn(fn ExecuteTimerFn) }
TimersProvider is the interface for the object that provides timers services.
type TransactionalStateStore ¶ added in v1.12.0
type TransactionalStateStore interface { state.Store state.TransactionalStore }
TransactionalStateStore is an interface that includes both state.Store and state.TransactionalStore