internal

package
v1.12.3-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const ActorAPILevel = 10

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.

Variables

View Source
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 Config added in v1.12.0

type Config struct {
	HostAddress                   string
	AppID                         string
	PlacementAddresses            []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 (c *Config) GetRemindersPartitionCountForType(actorType string) int

func (Config) GetRuntimeHostname added in v1.12.0

func (c Config) GetRuntimeHostname() string

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

type DeleteReminderRequest struct {
	Name      string
	ActorType string
	ActorID   string
}

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

type DeleteTimerRequest struct {
	Name      string
	ActorType string
	ActorID   string
}

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

type ExecuteReminderFn func(reminder *Reminder) bool

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

type ExecuteTimerFn func(reminder *Reminder) bool

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

type GetReminderRequest struct {
	Name      string
	ActorType string
	ActorID   string
}

GetReminderRequest is the request object to get an existing reminder.

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

type LookupActorRequest struct {
	ActorType string
	ActorID   string
}

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

type LookupActorResponse struct {
	Address string
	AppID   string
}

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
}

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

func (r Reminder) ActorKey() string

ActorKey returns the key of the actor for this reminder.

func (Reminder) HasRepeats added in v1.12.0

func (r Reminder) HasRepeats() bool

HasRepeats returns true if the reminder has repeats left.

func (Reminder) Key added in v1.12.0

func (r Reminder) Key() string

Key returns the key for this unique reminder.

func (*Reminder) MarshalBSON added in v1.12.0

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 added in v1.12.0

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

func (Reminder) NextTick added in v1.12.0

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 added in v1.12.0

func (r Reminder) RepeatsLeft() int

RepeatsLeft returns the number of repeats left.

func (*Reminder) RequiresUpdating added in v1.12.0

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

func (Reminder) ScheduledTime added in v1.12.0

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 added in v1.12.0

func (r Reminder) String() string

String implements fmt.Stringer and is used for debugging.

func (*Reminder) TickExecuted added in v1.12.0

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 added in v1.12.0

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

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
	RenameReminder(ctx context.Context, req *RenameReminderRequest) error
	DrainRebalancedReminders(actorType string, actorID string)
	OnPlacementTablesUpdated(ctx context.Context)

	SetResiliencyProvider(resiliency resiliency.Provider)
	SetExecuteReminderFn(fn ExecuteReminderFn)
	SetStateStoreProviderFn(fn StateStoreProviderFn)
	SetLookupActorFn(fn LookupActorFn)
}

RemindersProvider is the interface for the object that provides reminders services.

type RemindersProviderOpts added in v1.12.0

type RemindersProviderOpts struct {
	StoreName string
	Config    Config
}

RemindersProviderOpts contains the options for the reminders provider.

type RenameReminderRequest added in v1.12.0

type RenameReminderRequest struct {
	OldName   string
	ActorType string
	ActorID   string
	NewName   string
}

RenameReminderRequest is the request object for rename a reminder.

type StateStoreProviderFn added in v1.12.0

type StateStoreProviderFn func() (TransactionalStateStore, error)

StateStoreProviderFn is the type of a function that returns the state store provider.

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

Jump to

Keyboard shortcuts

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