Documentation
¶
Overview ¶
Copyright 2023 The Dapr Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func DecodeInternalActorData(data []byte, e any) error
- func DecodeInternalActorReminderData(data []byte, e any) error
- func EncodeInternalActorData(result any) ([]byte, error)
- func ValidateHostEnvironment(mTLSEnabled bool, mode modes.DaprMode, namespace string) error
- type ActiveActorsCount
- type ActorHostedRequest
- type ActorLock
- type ActorMetadata
- type ActorRemindersMetadata
- type Actors
- type ActorsOpts
- type Config
- func (c *Config) GetDrainOngoingTimeoutForType(actorType string) time.Duration
- func (c *Config) GetDrainRebalancedActorsForType(actorType string) bool
- func (c *Config) GetIdleTimeoutForType(actorType string) time.Duration
- func (c *Config) GetReentrancyForType(actorType string) daprAppConfig.ReentrancyConfig
- func (c *Config) GetRemindersPartitionCountForType(actorType string) int
- type ConfigOpts
- type CreateReminderRequest
- type CreateTimerRequest
- type DeleteReminderRequest
- type DeleteStateRequest
- type DeleteTimerRequest
- type EntityConfig
- type GRPCConnectionFn
- type GetReminderRequest
- type GetStateRequest
- type InternalActor
- type OperationType
- type PlacementService
- type ReminderResponse
- type RenameReminderRequest
- type SaveStateRequest
- type StateOperationOpts
- type StateResponse
- type TimerResponse
- type TransactionalDelete
- type TransactionalOperation
- type TransactionalRequest
- type TransactionalUpsert
Constants ¶
const InternalActorTypePrefix = "dapr.internal."
Variables ¶
var ErrActorDisposed = errors.New("actor is already disposed")
ErrActorDisposed is the error when runtime tries to hold the lock of the disposed actor.
var ErrDaprResponseHeader = errors.New("error indicated via actor header response")
var ErrIncompatibleStateStore = errors.New("actor state store does not exist, or does not support transactions which are required to save state - please see https://docs.dapr.io/operations/components/setup-state-store/supported-state-stores/")
var ErrMaxStackDepthExceeded = errors.New("maximum stack depth exceeded")
var ErrReminderCanceled = errors.New("reminder has been canceled")
Functions ¶
func DecodeInternalActorData ¶ added in v1.10.0
DecodeInternalActorData decodes encoding/gob data and stores the result in e.
func DecodeInternalActorReminderData ¶ added in v1.10.0
DecodeInternalActorReminderData decodes internal actor reminder data payloads and stores the result in e.
func EncodeInternalActorData ¶ added in v1.10.0
EncodeInternalActorData encodes result using the encoding/gob format.
Types ¶
type ActiveActorsCount ¶ added in v0.5.0
ActiveActorsCount contain actorType and count of actors each type has.
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.
type ActorLock ¶ added in v1.2.0
type ActorLock struct {
// contains filtered or unexported fields
}
func NewActorLock ¶ added in v1.2.0
type ActorMetadata ¶ added in v1.3.0
type ActorMetadata struct {
ID string `json:"id"`
RemindersMetadata ActorRemindersMetadata `json:"actorRemindersMetadata"`
Etag *string `json:"-"`
}
ActorMetadata represents information about the actor type.
type ActorRemindersMetadata ¶ added in v1.3.0
type ActorRemindersMetadata struct {
PartitionCount int `json:"partitionCount"`
// contains filtered or unexported fields
}
ActorRemindersMetadata represents information about actor's reminders.
type Actors ¶
type Actors interface {
Call(ctx context.Context, req *invokev1.InvokeMethodRequest) (*invokev1.InvokeMethodResponse, error)
Init() error
Stop()
GetState(ctx context.Context, req *GetStateRequest) (*StateResponse, error)
TransactionalStateOperation(ctx context.Context, req *TransactionalRequest) error
GetReminder(ctx context.Context, req *GetReminderRequest) (*reminders.Reminder, error)
CreateReminder(ctx context.Context, req *CreateReminderRequest) error
DeleteReminder(ctx context.Context, req *DeleteReminderRequest) error
RenameReminder(ctx context.Context, req *RenameReminderRequest) error
CreateTimer(ctx context.Context, req *CreateTimerRequest) error
DeleteTimer(ctx context.Context, req *DeleteTimerRequest) error
IsActorHosted(ctx context.Context, req *ActorHostedRequest) bool
GetActiveActorsCount(ctx context.Context) []ActiveActorsCount
RegisterInternalActor(ctx context.Context, actorType string, actor InternalActor) error
}
Actors allow calling into virtual actors as well as actor state management.
func NewActors ¶
func NewActors(opts ActorsOpts) Actors
NewActors create a new actors runtime with given config.
type ActorsOpts ¶ added in v1.10.0
type ActorsOpts struct {
AppChannel channel.AppChannel
GRPCConnectionFn GRPCConnectionFn
Config Config
CertChain *daprCredentials.CertChain
TracingSpec configuration.TracingSpec
Resiliency resiliency.Provider
StateStoreName string
CompStore *compstore.ComponentStore
// TODO: @joshvanl Remove in Dapr 1.12 when ActorStateTTL is finalized.
StateTTLEnabled bool
// MockPlacement is a placement service implementation used for testing
MockPlacement PlacementService
}
ActorsOpts contains options for NewActors.
type Config ¶
type Config struct {
HostAddress string
AppID string
PlacementAddresses []string
HostedActorTypes []string
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
}
Config is the actor runtime configuration.
func NewConfig ¶
func NewConfig(opts ConfigOpts) Config
NewConfig returns the actor runtime configuration.
func (*Config) GetDrainOngoingTimeoutForType ¶ added in v1.7.0
func (*Config) GetDrainRebalancedActorsForType ¶ added in v1.7.0
func (*Config) GetIdleTimeoutForType ¶ added in v1.7.0
func (*Config) GetReentrancyForType ¶ added in v1.7.0
func (c *Config) GetReentrancyForType(actorType string) daprAppConfig.ReentrancyConfig
func (*Config) GetRemindersPartitionCountForType ¶ added in v1.7.0
type ConfigOpts ¶ added in v1.10.0
type ConfigOpts struct {
HostAddress string
AppID string
PlacementAddresses []string
Port int
Namespace string
AppConfig daprAppConfig.ApplicationConfig
HealthHTTPClient *http.Client
HealthEndpoint string
AppChannelAddress string
}
ConfigOpts contains options for NewConfig.
type CreateReminderRequest ¶
type CreateReminderRequest = reminders.CreateReminderRequest
CreateReminderRequest is the request object to create a new reminder.
type CreateTimerRequest ¶
type CreateTimerRequest = reminders.CreateTimerRequest
CreateTimerRequest is the request object to create a new timer.
type DeleteReminderRequest ¶
DeleteReminderRequest is the request object for deleting a 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.
type DeleteTimerRequest ¶
DeleteTimerRequest is a request object for deleting a timer.
type EntityConfig ¶ added in v1.7.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 GRPCConnectionFn ¶ added in v1.10.0
type GRPCConnectionFn func(ctx context.Context, address string, id string, namespace string, customOpts ...grpc.DialOption) (*grpc.ClientConn, func(destroy bool), error)
GRPCConnectionFn is the type of the function that returns a gRPC connection
type GetReminderRequest ¶
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 ¶ added in v1.10.5
func (r GetStateRequest) ActorKey() string
ActorKey returns the key of the actor for this request.
type InternalActor ¶ added in v1.10.0
type InternalActor interface {
SetActorRuntime(actorsRuntime Actors)
InvokeMethod(ctx context.Context, actorID string, methodName string, data []byte) (any, error)
DeactivateActor(ctx context.Context, actorID string) error
// InvokeReminder invokes reminder logic for an internal actor.
// Note that the DecodeInternalActorReminderData function should be used to decode the [data] parameter.
InvokeReminder(ctx context.Context, actorID string, reminderName string, data []byte, dueTime string, period string) error
InvokeTimer(ctx context.Context, actorID string, timerName string, params []byte) error
}
InternalActor represents the interface for invoking an "internal" actor (one which is built into daprd directly).
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 PlacementService ¶ added in v1.10.0
type PlacementService interface {
Start()
Stop()
WaitUntilPlacementTableIsReady(ctx context.Context) error
LookupActor(actorType, actorID string) (host string, appID string)
AddHostedActorType(actorType string) error
}
PlacementService allows for interacting with the actor placement service.
type ReminderResponse ¶
type ReminderResponse struct {
Data 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 ¶ added in v1.10.6
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 RenameReminderRequest ¶ added in v1.6.0
RenameReminderRequest is the request object for rename a reminder.
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 ¶ added in v1.10.5
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"`
}
StateResponse is the response returned from getting an actor state.
type TimerResponse ¶
type TimerResponse struct {
Callback string `json:"callback"`
Data 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 ¶ added in v1.10.6
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 ¶
TransactionalDelete defined a delete operation.
func (TransactionalDelete) StateOperation ¶ added in v1.10.5
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 ¶ added in v1.10.5
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 ¶ added in v1.10.5
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 ¶ added in v1.10.5
func (t TransactionalUpsert) StateOperation(baseKey string, opts StateOperationOpts) (op state.TransactionalStateOperation, err error)
StateOperation returns the state.TransactionalStateOperation object.