client

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: Apache-2.0 Imports: 39 Imported by: 318

Documentation

Index

Constants

View Source
const (
	// StateConsistencyUndefined is the undefined value for state consistency.
	StateConsistencyUndefined StateConsistency = 0
	// StateConsistencyEventual represents eventual state consistency value.
	StateConsistencyEventual StateConsistency = 1
	// StateConsistencyStrong represents strong state consistency value.
	StateConsistencyStrong StateConsistency = 2

	// StateConcurrencyUndefined is the undefined value for state concurrency.
	StateConcurrencyUndefined StateConcurrency = 0
	// StateConcurrencyFirstWrite represents first write concurrency value.
	StateConcurrencyFirstWrite StateConcurrency = 1
	// StateConcurrencyLastWrite represents last write concurrency value.
	StateConcurrencyLastWrite StateConcurrency = 2

	// StateOperationTypeUndefined is the undefined value for state operation type.
	StateOperationTypeUndefined OperationType = 0
	// StateOperationTypeUpsert represents upsert operation type value.
	StateOperationTypeUpsert OperationType = 1
	// StateOperationTypeDelete represents delete operation type value.
	StateOperationTypeDelete OperationType = 2

	// EventualType represents the eventual type value.
	EventualType = "eventual"
	// StrongType represents the strong type value.
	StrongType = "strong"
	// FirstWriteType represents the first write type value.
	FirstWriteType = "first-write"
	// LastWriteType represents the last write type value.
	LastWriteType = "last-write"
	// UpsertType represents the upsert type value.
	UpsertType = "upsert"
	// DeleteType represents the delete type value.
	DeleteType = "delete"
	// UndefinedType represents undefined type value.
	UndefinedType = "undefined"
)
View Source
const StreamBufferSize = 2 << 10

Maximum size, in bytes, for the buffer used by stream invocations: 2KB.

Variables

This section is empty.

Functions

func NewConversationRequest added in v1.12.0

func NewConversationRequest(llmName string, inputs []ConversationInput) conversationRequest

NewConversationRequest defines a request with a component name and one or more inputs as a slice for the ConverseAlpha1 method. Deprecated: use ConversationRequestAlpha2 and ConverseAlpha2 instead.

func NewWorkflowClient added in v1.13.0

func NewWorkflowClient() (*workflow.Client, error)

func SetLogger added in v1.10.0

func SetLogger(l *log.Logger)

SetLogger sets the global logger for the Dapr client. The default logger has a destination of os.Stdout, SetLogger allows you to optionally specify a custom logger (with a custom destination). To disable client logging entirely, use a nil argument e.g.: client.SetLogger(nil)

func WithContextID added in v1.12.0

func WithContextID(id string) conversationRequestOption

WithContextID to provide a new context or continue an existing one. Deprecated: use ConversationRequestAlpha2.ContextID instead.

func WithMetadata added in v1.12.0

func WithMetadata(metadata map[string]string) conversationRequestOption

WithMetadata used to define metadata to be passed to components. Deprecated: use ConversationRequestAlpha2.Metadata instead.

func WithParameters added in v1.12.0

func WithParameters(parameters map[string]*anypb.Any) conversationRequestOption

WithParameters should be used to provide parameters for custom fields. Deprecated: use ConversationRequestAlpha2.Parameters instead.

func WithScrubPII added in v1.12.0

func WithScrubPII(scrub bool) conversationRequestOption

WithScrubPII to define whether the outputs should have PII removed. Deprecated: use ConversationRequestAlpha2.ScrubPII instead.

func WithTemperature added in v1.12.0

func WithTemperature(temp float64) conversationRequestOption

WithTemperature to specify which way the LLM leans. Deprecated: use ConversationRequestAlpha2.Temperature instead.

Types

type ActorStateOperation added in v1.3.0

type ActorStateOperation struct {
	OperationType string
	Key           string
	Value         []byte
	TTLInSeconds  *int64
}

type BindingEvent added in v0.10.0

type BindingEvent struct {
	// Data is the input bindings sent
	Data []byte
	// Metadata is the input binding metadata
	Metadata map[string]string
}

BindingEvent represents the binding event handler input.

type BulkStateItem added in v1.0.0

type BulkStateItem struct {
	Key      string
	Value    []byte
	Etag     string
	Metadata map[string]string
	Error    string
}

BulkStateItem represents a single state item.

type Client

type Client interface {
	// InvokeBinding invokes specific operation on the configured Dapr binding.
	// This method covers input, output, and bi-directional bindings.
	InvokeBinding(ctx context.Context, in *InvokeBindingRequest) (out *BindingEvent, err error)

	// InvokeOutputBinding invokes configured Dapr binding with data.InvokeOutputBinding
	// This method differs from InvokeBinding in that it doesn't expect any content being returned from the invoked method.
	InvokeOutputBinding(ctx context.Context, in *InvokeBindingRequest) error

	// InvokeMethod invokes service without raw data
	InvokeMethod(ctx context.Context, appID, methodName, verb string) (out []byte, err error)

	// InvokeMethodWithContent invokes service with content
	InvokeMethodWithContent(ctx context.Context, appID, methodName, verb string, content *DataContent) (out []byte, err error)

	// InvokeMethodWithCustomContent invokes app with custom content (struct + content type).
	InvokeMethodWithCustomContent(ctx context.Context, appID, methodName, verb string, contentType string, content interface{}) (out []byte, err error)

	// GetMetadata returns metadata from the sidecar.
	GetMetadata(ctx context.Context) (metadata *GetMetadataResponse, err error)

	// SetMetadata sets a key-value pair in the sidecar.
	SetMetadata(ctx context.Context, key, value string) error

	// PublishEvent publishes data onto topic in specific pubsub component.
	PublishEvent(ctx context.Context, pubsubName, topicName string, data interface{}, opts ...PublishEventOption) error

	// PublishEventfromCustomContent serializes an struct and publishes its contents as data (JSON) onto topic in specific pubsub component.
	// Deprecated: This method is deprecated and will be removed in a future version of the SDK. Please use `PublishEvent` instead.
	PublishEventfromCustomContent(ctx context.Context, pubsubName, topicName string, data interface{}) error

	// PublishEvents publishes multiple events onto topic in specific pubsub component.
	// If all events are successfully published, response Error will be nil.
	// The FailedEvents field will contain all events that failed to publish.
	PublishEvents(ctx context.Context, pubsubName, topicName string, events []interface{}, opts ...PublishEventsOption) PublishEventsResponse

	// GetSecret retrieves preconfigured secret from specified store using key.
	GetSecret(ctx context.Context, storeName, key string, meta map[string]string) (data map[string]string, err error)

	// GetBulkSecret retrieves all preconfigured secrets for this application.
	GetBulkSecret(ctx context.Context, storeName string, meta map[string]string) (data map[string]map[string]string, err error)

	// SaveState saves the raw data into store using default state options.
	SaveState(ctx context.Context, storeName, key string, data []byte, meta map[string]string, so ...StateOption) error

	// SaveState saves the raw data into store using provided state options and etag.
	SaveStateWithETag(ctx context.Context, storeName, key string, data []byte, etag string, meta map[string]string, so ...StateOption) error

	// SaveBulkState saves multiple state item to store with specified options.
	SaveBulkState(ctx context.Context, storeName string, items ...*SetStateItem) error

	// GetState retrieves state from specific store using default consistency option.
	GetState(ctx context.Context, storeName, key string, meta map[string]string) (item *StateItem, err error)

	// GetStateWithConsistency retrieves state from specific store using provided state consistency.
	GetStateWithConsistency(ctx context.Context, storeName, key string, meta map[string]string, sc StateConsistency) (item *StateItem, err error)

	// GetBulkState retrieves state for multiple keys from specific store.
	GetBulkState(ctx context.Context, storeName string, keys []string, meta map[string]string, parallelism int32) ([]*BulkStateItem, error)

	// QueryStateAlpha1 runs a query against state store.
	QueryStateAlpha1(ctx context.Context, storeName, query string, meta map[string]string) (*QueryResponse, error)

	// DeleteState deletes content from store using default state options.
	DeleteState(ctx context.Context, storeName, key string, meta map[string]string) error

	// DeleteStateWithETag deletes content from store using provided state options and etag.
	DeleteStateWithETag(ctx context.Context, storeName, key string, etag *ETag, meta map[string]string, opts *StateOptions) error

	// ExecuteStateTransaction provides way to execute multiple operations on a specified store.
	ExecuteStateTransaction(ctx context.Context, storeName string, meta map[string]string, ops []*StateOperation) error

	// GetConfigurationItem can get target configuration item by storeName and key
	GetConfigurationItem(ctx context.Context, storeName, key string, opts ...ConfigurationOpt) (*ConfigurationItem, error)

	// GetConfigurationItems can get a list of configuration item by storeName and keys
	GetConfigurationItems(ctx context.Context, storeName string, keys []string, opts ...ConfigurationOpt) (map[string]*ConfigurationItem, error)

	// SubscribeConfigurationItems can subscribe the change of configuration items by storeName and keys, and return subscription id
	SubscribeConfigurationItems(ctx context.Context, storeName string, keys []string, handler ConfigurationHandleFunction, opts ...ConfigurationOpt) (string, error)

	// UnsubscribeConfigurationItems stops the subscription with target store's and ID.
	// Deprecated: Closing the `SubscribeConfigurationItems` stream (closing the given context) will unsubscribe the client and should be used in favor of `UnsubscribeConfigurationItems`.
	// UnsubscribeConfigurationItems can stop the subscription with target store's and id
	UnsubscribeConfigurationItems(ctx context.Context, storeName string, id string, opts ...ConfigurationOpt) error

	// Subscribe subscribes to a pubsub topic and streams messages to the returned Subscription.
	// Subscription must be closed after finishing with subscribing.
	Subscribe(ctx context.Context, opts SubscriptionOptions) (*Subscription, error)

	// SubscribeWithHandler subscribes to a pubsub topic and calls the given handler on topic events.
	// The returned cancel function must be called after  finishing with subscribing.
	SubscribeWithHandler(ctx context.Context, opts SubscriptionOptions, handler SubscriptionHandleFunction) (func() error, error)

	// DeleteBulkState deletes content for multiple keys from store.
	DeleteBulkState(ctx context.Context, storeName string, keys []string, meta map[string]string) error

	// DeleteBulkStateItems deletes content for multiple items from store.
	DeleteBulkStateItems(ctx context.Context, storeName string, items []*DeleteStateItem) error

	// TryLockAlpha1 attempts to grab a lock from a lock store.
	TryLockAlpha1(ctx context.Context, storeName string, request *LockRequest) (*LockResponse, error)

	// UnlockAlpha1 deletes unlocks a lock from a lock store.
	UnlockAlpha1(ctx context.Context, storeName string, request *UnlockRequest) (*UnlockResponse, error)

	// Encrypt data read from a stream, returning a readable stream that receives the encrypted data.
	// This method returns an error if the initial call fails. Errors performed during the encryption are received by the out stream.
	Encrypt(ctx context.Context, in io.Reader, opts EncryptOptions) (io.Reader, error)

	// Decrypt data read from a stream, returning a readable stream that receives the decrypted data.
	// This method returns an error if the initial call fails. Errors performed during the encryption are received by the out stream.
	Decrypt(ctx context.Context, in io.Reader, opts DecryptOptions) (io.Reader, error)

	// Shutdown the sidecar.
	Shutdown(ctx context.Context) error

	// Wait for a  sidecar to become available for at most `timeout` seconds. Returns errWaitTimedOut if timeout is reached.
	Wait(ctx context.Context, timeout time.Duration) error

	// WithTraceID adds existing trace ID to the outgoing context.
	WithTraceID(ctx context.Context, id string) context.Context

	// WithAuthToken sets Dapr API token on the instantiated client.
	WithAuthToken(token string)

	// Close cleans up all resources created by the client.
	Close()

	// RegisterActorTimer registers an actor timer.
	RegisterActorTimer(ctx context.Context, req *RegisterActorTimerRequest) error

	// UnregisterActorTimer unregisters an actor timer.
	UnregisterActorTimer(ctx context.Context, req *UnregisterActorTimerRequest) error

	// RegisterActorReminder registers an actor reminder.
	RegisterActorReminder(ctx context.Context, req *RegisterActorReminderRequest) error

	// UnregisterActorReminder unregisters an actor reminder.
	UnregisterActorReminder(ctx context.Context, req *UnregisterActorReminderRequest) error

	// InvokeActor calls a method on an actor.
	InvokeActor(ctx context.Context, req *InvokeActorRequest) (*InvokeActorResponse, error)

	// GetActorState get actor state
	GetActorState(ctx context.Context, req *GetActorStateRequest) (data *GetActorStateResponse, err error)

	// SaveStateTransactionally save actor state
	SaveStateTransactionally(ctx context.Context, actorType, actorID string, operations []*ActorStateOperation) error

	// ImplActorClientStub is to impl user defined actor client stub
	ImplActorClientStub(actorClientStub actor.Client, opt ...config.Option)

	// ScheduleJobAlpha1 creates and schedules a job.
	ScheduleJobAlpha1(ctx context.Context, req *Job) error

	// GetJobAlpha1 returns a scheduled job.
	GetJobAlpha1(ctx context.Context, name string) (*Job, error)

	// DeleteJobAlpha1 deletes a scheduled job.
	DeleteJobAlpha1(ctx context.Context, name string) error

	// ConverseAlpha1 interacts with a conversational AI model.
	ConverseAlpha1(ctx context.Context, request conversationRequest, options ...conversationRequestOption) (*ConversationResponse, error)

	// ConverseAlpha2 interacts with a conversational AI model.
	ConverseAlpha2(ctx context.Context, request ConversationRequestAlpha2,
		options ...conversationRequestOptionAlpha2) (*ConversationResponseAlpha2, error)

	// GrpcClient returns the base grpc client if grpc is used and nil otherwise
	GrpcClient() pb.DaprClient

	GrpcClientConn() *grpc.ClientConn
}

Client is the interface for Dapr client implementation.

func NewClient

func NewClient() (client Client, err error)

NewClient instantiates Dapr client using DAPR_GRPC_PORT environment variable as port. Note, this default factory function creates Dapr client only once. All subsequent invocations will return the already created instance. To create multiple instances of the Dapr client, use one of the parameterized factory functions:

NewClientWithPort(port string) (client Client, err error)
NewClientWithAddress(address string) (client Client, err error)
NewClientWithConnection(conn *grpc.ClientConn) Client
NewClientWithSocket(socket string) (client Client, err error)

func NewClientWithAddress

func NewClientWithAddress(address string) (client Client, err error)

NewClientWithAddress instantiates Dapr using specific address (including port). Deprecated: use NewClientWithAddressContext instead.

func NewClientWithAddressContext added in v1.8.0

func NewClientWithAddressContext(ctx context.Context, address string) (client Client, err error)

NewClientWithAddressContext instantiates Dapr using specific address (including port). Uses the provided context to create the connection.

func NewClientWithConnection

func NewClientWithConnection(conn *grpc.ClientConn) Client

NewClientWithConnection instantiates Dapr client using specific connection.

func NewClientWithPort

func NewClientWithPort(port string) (client Client, err error)

NewClientWithPort instantiates Dapr using specific gRPC port.

func NewClientWithSocket added in v1.3.1

func NewClientWithSocket(socket string) (client Client, err error)

NewClientWithSocket instantiates Dapr using specific socket.

type ConfigurationHandleFunction added in v1.4.0

type ConfigurationHandleFunction func(string, map[string]*ConfigurationItem)

type ConfigurationItem added in v1.4.0

type ConfigurationItem struct {
	Value    string
	Version  string
	Metadata map[string]string
}

type ConfigurationOpt added in v1.4.0

type ConfigurationOpt func(map[string]string)

func WithConfigurationMetadata added in v1.4.0

func WithConfigurationMetadata(key, value string) ConfigurationOpt

type ConversationInput added in v1.12.0

type ConversationInput struct {
	// The content to send to the llm.
	Content string
	// The role of the message.
	Role *string
	// Whether to Scrub PII from the input
	ScrubPII *bool
}

ConversationInput defines a single input for a conversation request for ConverseAlpha1. Deprecated: use ConversationInput in ConversationRequestAlpha2 instead.

type ConversationInputAlpha2 added in v1.13.0

type ConversationInputAlpha2 struct {
	Messages []*ConversationMessageAlpha2
	ScrubPII *bool
}

type ConversationMessageAlpha2 added in v1.13.0

type ConversationMessageAlpha2 struct {
	// oneof conversationmessagedeveloper, conversationmessagesystem, conversationmessageuser, conversationmessageassistant, conversationmessagetool
	ConversationMessageOfDeveloper *ConversationMessageOfDeveloperAlpha2
	ConversationMessageOfSystem    *ConversationMessageOfSystemAlpha2
	ConversationMessageOfUser      *ConversationMessageOfUserAlpha2
	ConversationMessageOfAssistant *ConversationMessageOfAssistantAlpha2
	ConversationMessageOfTool      *ConversationMessageOfToolAlpha2
}

func (*ConversationMessageAlpha2) Validate added in v1.13.0

func (cm *ConversationMessageAlpha2) Validate() bool

Validate ensures that exactly one of the oneof fields is set, not more, not less.

type ConversationMessageContentAlpha2 added in v1.13.0

type ConversationMessageContentAlpha2 struct {
	Text *string
}

type ConversationMessageOfAssistantAlpha2 added in v1.13.0

type ConversationMessageOfAssistantAlpha2 struct {
	Name      *string
	Content   []*ConversationMessageContentAlpha2
	ToolCalls []*ConversationToolCallsAlpha2
}

type ConversationMessageOfDeveloperAlpha2 added in v1.13.0

type ConversationMessageOfDeveloperAlpha2 struct {
	Name    *string
	Content []*ConversationMessageContentAlpha2
}

type ConversationMessageOfSystemAlpha2 added in v1.13.0

type ConversationMessageOfSystemAlpha2 struct {
	Name    *string
	Content []*ConversationMessageContentAlpha2
}

type ConversationMessageOfToolAlpha2 added in v1.13.0

type ConversationMessageOfToolAlpha2 struct {
	ToolID  *string
	Name    *string
	Content []*ConversationMessageContentAlpha2
}

type ConversationMessageOfUserAlpha2 added in v1.13.0

type ConversationMessageOfUserAlpha2 struct {
	Name    *string
	Content []*ConversationMessageContentAlpha2
}

type ConversationRequestAlpha2 added in v1.13.0

type ConversationRequestAlpha2 struct {
	Name        string // LLM component name
	ContextID   *string
	Inputs      []*ConversationInputAlpha2
	Parameters  map[string]*anypb.Any
	Metadata    map[string]string
	ScrubPII    *bool // Scrub PII from the output
	Temperature *float64
	Tools       []*ConversationToolsAlpha2
	ToolChoice  *ToolChoiceAlpha2
}

type ConversationResponse added in v1.12.0

type ConversationResponse struct {
	ContextID string
	Outputs   []ConversationResult
}

ConversationResponse is the basic response from a conversationRequest for ConverseAlpha1.

type ConversationResponseAlpha2 added in v1.13.0

type ConversationResponseAlpha2 struct {
	ContextID string
	Outputs   []*ConversationResultAlpha2
}

type ConversationResult added in v1.12.0

type ConversationResult struct {
	Result     string
	Parameters map[string]*anypb.Any
}

ConversationResult is the individual result from a conversation response for ConverseAlpha1.

type ConversationResultAlpha2 added in v1.13.0

type ConversationResultAlpha2 struct {
	Choices []*ConversationResultChoicesAlpha2
}

type ConversationResultChoicesAlpha2 added in v1.13.0

type ConversationResultChoicesAlpha2 struct {
	FinishReason string
	Index        int64
	Message      *ConversationResultMessageAlpha2
}

type ConversationResultMessageAlpha2 added in v1.13.0

type ConversationResultMessageAlpha2 struct {
	Content   string
	ToolCalls []*ConversationToolCallsAlpha2
}

type ConversationToolAlpha2 added in v1.13.0

type ConversationToolAlpha2 struct {
	Name      string
	Arguments string
}

type ConversationToolCallsAlpha2 added in v1.13.0

type ConversationToolCallsAlpha2 struct {
	ID        string
	ToolTypes ConversationToolAlpha2
}

type ConversationToolsAlpha2 added in v1.13.0

type ConversationToolsAlpha2 ConversationToolsFunctionAlpha2

ConversationToolsAlpha2 is one of the ConversationToolsFunctionAlpha2 types.

type ConversationToolsFunctionAlpha2 added in v1.13.0

type ConversationToolsFunctionAlpha2 struct {
	Name        string
	Description *string
	Parameters  *structpb.Struct
}

type DataContent added in v0.10.0

type DataContent struct {
	// Data is the input data
	Data []byte
	// ContentType is the type of the data content
	ContentType string
}

DataContent the service invocation content.

type DecryptOptions added in v1.8.0

type DecryptOptions struct {
	// Name of the component. Required.
	ComponentName string
	// Name (or name/version) of the key to decrypt the message.
	// Overrides any key reference included in the message if present.
	// This is required if the message doesn't include a key reference (i.e. was created with omit_decryption_key_name set to true).
	KeyName string
}

DecryptOptions contains options passed to the Decrypt method.

type DeleteStateItem added in v1.0.0

type DeleteStateItem SetStateItem

DeleteStateItem represents a single state to be deleted.

type ETag added in v1.0.0

type ETag struct {
	Value string
}

ETag represents an versioned record information.

type EncryptOptions added in v1.8.0

type EncryptOptions struct {
	// Name of the component. Required.
	ComponentName string
	// Name (or name/version) of the key. Required.
	KeyName string
	// Key wrapping algorithm to use. Required.
	// Supported options include: A256KW, A128CBC, A192CBC, A256CBC, RSA-OAEP-256.
	KeyWrapAlgorithm string
	// DataEncryptionCipher to use to encrypt data (optional): "aes-gcm" (default) or "chacha20-poly1305"
	DataEncryptionCipher string
	// If true, the encrypted document does not contain a key reference.
	// In that case, calls to the Decrypt method must provide a key reference (name or name/version).
	// Defaults to false.
	OmitDecryptionKeyName bool
	// Key reference to embed in the encrypted document (name or name/version).
	// This is helpful if the reference of the key used to decrypt the document is different from the one used to encrypt it.
	// If unset, uses the reference of the key used to encrypt the document (this is the default behavior).
	// This option is ignored if omit_decryption_key_name is true.
	DecryptionKeyName string
}

EncryptOptions contains options passed to the Encrypt method.

type FailurePolicy added in v1.13.0

type FailurePolicy interface {
	GetPBFailurePolicy() *commonpb.JobFailurePolicy
}

type GRPCClient

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

GRPCClient is the gRPC implementation of Dapr client.

func (*GRPCClient) Close

func (c *GRPCClient) Close()

Close cleans up all resources created by the client.

func (*GRPCClient) ConverseAlpha1 added in v1.12.0

func (c *GRPCClient) ConverseAlpha1(ctx context.Context, req conversationRequest, options ...conversationRequestOption) (*ConversationResponse, error)

ConverseAlpha1 can invoke an LLM given a request created by the NewConversationRequest function. Deprecated: use ConverseAlpha2 instead.

func (*GRPCClient) ConverseAlpha2 added in v1.13.0

func (c *GRPCClient) ConverseAlpha2(ctx context.Context, request ConversationRequestAlpha2, options ...conversationRequestOptionAlpha2) (*ConversationResponseAlpha2, error)

func (*GRPCClient) Decrypt added in v1.8.0

func (c *GRPCClient) Decrypt(ctx context.Context, in io.Reader, opts DecryptOptions) (io.Reader, error)

Decrypt data read from a stream, returning a readable stream that receives the decrypted data. This method returns an error if the initial call fails. Errors performed during the encryption are received by the out stream.

func (*GRPCClient) DeleteBulkState added in v1.0.0

func (c *GRPCClient) DeleteBulkState(ctx context.Context, storeName string, keys []string, meta map[string]string) error

DeleteBulkState deletes content for multiple keys from store.

func (*GRPCClient) DeleteBulkStateItems added in v1.0.0

func (c *GRPCClient) DeleteBulkStateItems(ctx context.Context, storeName string, items []*DeleteStateItem) error

DeleteBulkStateItems deletes content for multiple items from store.

func (*GRPCClient) DeleteJobAlpha1 added in v1.11.0

func (c *GRPCClient) DeleteJobAlpha1(ctx context.Context, name string) error

DeleteJobAlpha1 deletes a scheduled job.

func (*GRPCClient) DeleteState

func (c *GRPCClient) DeleteState(ctx context.Context, storeName, key string, meta map[string]string) error

DeleteState deletes content from store using default state options.

func (*GRPCClient) DeleteStateWithETag added in v0.10.0

func (c *GRPCClient) DeleteStateWithETag(ctx context.Context, storeName, key string, etag *ETag, meta map[string]string, opts *StateOptions) error

DeleteStateWithETag deletes content from store using provided state options and etag.

func (*GRPCClient) Encrypt added in v1.8.0

func (c *GRPCClient) Encrypt(ctx context.Context, in io.Reader, opts EncryptOptions) (io.Reader, error)

Encrypt data read from a stream, returning a readable stream that receives the encrypted data. This method returns an error if the initial call fails. Errors performed during the encryption are received by the out stream.

func (*GRPCClient) ExecuteStateTransaction added in v0.10.0

func (c *GRPCClient) ExecuteStateTransaction(ctx context.Context, storeName string, meta map[string]string, ops []*StateOperation) error

ExecuteStateTransaction provides way to execute multiple operations on a specified store.

func (*GRPCClient) GetActorState added in v1.3.0

func (*GRPCClient) GetBulkSecret added in v1.0.0

func (c *GRPCClient) GetBulkSecret(ctx context.Context, storeName string, meta map[string]string) (data map[string]map[string]string, err error)

GetBulkSecret retrieves all preconfigured secrets for this application.

func (*GRPCClient) GetBulkState added in v1.0.0

func (c *GRPCClient) GetBulkState(ctx context.Context, storeName string, keys []string, meta map[string]string, parallelism int32) ([]*BulkStateItem, error)

GetBulkState retrieves state for multiple keys from specific store.

func (*GRPCClient) GetConfigurationItem added in v1.4.0

func (c *GRPCClient) GetConfigurationItem(ctx context.Context, storeName, key string, opts ...ConfigurationOpt) (*ConfigurationItem, error)

func (*GRPCClient) GetConfigurationItems added in v1.4.0

func (c *GRPCClient) GetConfigurationItems(ctx context.Context, storeName string, keys []string, opts ...ConfigurationOpt) (map[string]*ConfigurationItem, error)

func (*GRPCClient) GetJobAlpha1 added in v1.11.0

func (c *GRPCClient) GetJobAlpha1(ctx context.Context, name string) (*Job, error)

GetJobAlpha1 retrieves a scheduled job.

func (*GRPCClient) GetMetadata added in v1.9.0

func (c *GRPCClient) GetMetadata(ctx context.Context) (metadata *GetMetadataResponse, err error)

GetMetadata returns the metadata of the sidecar

func (*GRPCClient) GetSecret

func (c *GRPCClient) GetSecret(ctx context.Context, storeName, key string, meta map[string]string) (data map[string]string, err error)

GetSecret retrieves preconfigured secret from specified store using key.

func (*GRPCClient) GetState

func (c *GRPCClient) GetState(ctx context.Context, storeName, key string, meta map[string]string) (item *StateItem, err error)

GetState retrieves state from specific store using default consistency option.

func (*GRPCClient) GetStateWithConsistency

func (c *GRPCClient) GetStateWithConsistency(ctx context.Context, storeName, key string, meta map[string]string, sc StateConsistency) (*StateItem, error)

GetStateWithConsistency retrieves state from specific store using provided state consistency.

func (*GRPCClient) GrpcClient added in v1.5.0

func (c *GRPCClient) GrpcClient() pb.DaprClient

GrpcClient returns the base grpc client.

func (*GRPCClient) GrpcClientConn added in v1.6.0

func (c *GRPCClient) GrpcClientConn() *grpc.ClientConn

GrpcClientConn returns the grpc.ClientConn object used by this client.

func (*GRPCClient) ImplActorClientStub added in v1.3.0

func (c *GRPCClient) ImplActorClientStub(actorClientStub actor.Client, opt ...config.Option)

ImplActorClientStub impls the given client stub @actorClientStub, an example of client stub is as followed

type ClientStub struct { // User defined function

	GetUser       func(context.Context, *User) (*User, error)
	Invoke        func(context.Context, string) (string, error)
	Get           func(context.Context) (string, error)
	Post          func(context.Context, string) error
	StartTimer    func(context.Context, *TimerRequest) error
	StopTimer     func(context.Context, *TimerRequest) error
	...
}

// Type defined the target type, which should be compatible with server side actor

func (a *ClientStub) Type() string {
	return "testActorType"
}

// ID defined actor ID to be invoked

func (a *ClientStub) ID() string {
	return "ActorImplID123456"
}.

func (*GRPCClient) InvokeActor added in v1.3.0

func (c *GRPCClient) InvokeActor(ctx context.Context, in *InvokeActorRequest) (out *InvokeActorResponse, err error)

InvokeActor invokes specific operation on the configured Dapr binding. This method covers input, output, and bi-directional bindings.

func (*GRPCClient) InvokeBinding

func (c *GRPCClient) InvokeBinding(ctx context.Context, in *InvokeBindingRequest) (*BindingEvent, error)

InvokeBinding invokes specific operation on the configured Dapr binding. This method covers input, output, and bi-directional bindings.

func (*GRPCClient) InvokeMethod added in v1.0.0

func (c *GRPCClient) InvokeMethod(ctx context.Context, appID, methodName, verb string) (out []byte, err error)

InvokeMethod invokes service without raw data ([]byte).

func (*GRPCClient) InvokeMethodWithContent added in v1.0.0

func (c *GRPCClient) InvokeMethodWithContent(ctx context.Context, appID, methodName, verb string, content *DataContent) (out []byte, err error)

InvokeMethodWithContent invokes service with content (data + content type).

func (*GRPCClient) InvokeMethodWithCustomContent added in v1.0.0

func (c *GRPCClient) InvokeMethodWithCustomContent(ctx context.Context, appID, methodName, verb string, contentType string, content interface{}) ([]byte, error)

InvokeMethodWithCustomContent invokes service with custom content (struct + content type).

func (*GRPCClient) InvokeOutputBinding

func (c *GRPCClient) InvokeOutputBinding(ctx context.Context, in *InvokeBindingRequest) error

InvokeOutputBinding invokes configured Dapr binding with data (allows nil).InvokeOutputBinding This method differs from InvokeBinding in that it doesn't expect any content being returned from the invoked method.

func (*GRPCClient) PublishEvent

func (c *GRPCClient) PublishEvent(ctx context.Context, pubsubName, topicName string, data interface{}, opts ...PublishEventOption) error

PublishEvent publishes data onto specific pubsub topic.

func (*GRPCClient) PublishEventfromCustomContent added in v1.0.0

func (c *GRPCClient) PublishEventfromCustomContent(ctx context.Context, pubsubName, topicName string, data interface{}) error

PublishEventfromCustomContent serializes an struct and publishes its contents as data (JSON) onto topic in specific pubsub component. Deprecated: This method is deprecated and will be removed in a future version of the SDK. Please use `PublishEvent` instead.

func (*GRPCClient) PublishEvents added in v1.8.0

func (c *GRPCClient) PublishEvents(ctx context.Context, pubsubName, topicName string, events []interface{}, opts ...PublishEventsOption) PublishEventsResponse

PublishEvents publishes multiple events onto topic in specific pubsub component. If all events are successfully published, response Error will be nil. The FailedEvents field will contain all events that failed to publish.

func (*GRPCClient) QueryStateAlpha1 added in v1.3.1

func (c *GRPCClient) QueryStateAlpha1(ctx context.Context, storeName, query string, meta map[string]string) (*QueryResponse, error)

QueryStateAlpha1 runs a query against state store.

func (*GRPCClient) RegisterActorReminder added in v1.3.0

func (c *GRPCClient) RegisterActorReminder(ctx context.Context, in *RegisterActorReminderRequest) (err error)

RegisterActorReminder registers a new reminder to target actor. Then, a reminder would be created and invoke actor's ReminderCall function if implemented. If server side actor impls this function, it's asserted to actor.ReminderCallee and can be invoked with call period and state data as param @in defined. Scheduling parameters 'DueTime', 'Period', and 'TTL' are optional.

func (*GRPCClient) RegisterActorTimer added in v1.3.0

func (c *GRPCClient) RegisterActorTimer(ctx context.Context, in *RegisterActorTimerRequest) (err error)

RegisterActorTimer register actor timer as given param @in defined. Scheduling parameters 'DueTime', 'Period', and 'TTL' are optional.

func (*GRPCClient) SaveBulkState added in v1.0.0

func (c *GRPCClient) SaveBulkState(ctx context.Context, storeName string, items ...*SetStateItem) error

SaveBulkState saves the multiple state item to store.

func (*GRPCClient) SaveState

func (c *GRPCClient) SaveState(ctx context.Context, storeName, key string, data []byte, meta map[string]string, so ...StateOption) error

SaveState saves the raw data into store, default options: strong, last-write.

func (*GRPCClient) SaveStateTransactionally added in v1.3.0

func (c *GRPCClient) SaveStateTransactionally(ctx context.Context, actorType, actorID string, operations []*ActorStateOperation) error

func (*GRPCClient) SaveStateWithETag added in v1.6.0

func (c *GRPCClient) SaveStateWithETag(ctx context.Context, storeName, key string, data []byte, etag string, meta map[string]string, so ...StateOption) error

SaveStateWithETag saves the raw data into store using provided state options and etag.

func (*GRPCClient) ScheduleJobAlpha1 added in v1.11.0

func (c *GRPCClient) ScheduleJobAlpha1(ctx context.Context, job *Job) error

ScheduleJobAlpha1 raises and schedules a job.

func (*GRPCClient) SetMetadata added in v1.9.0

func (c *GRPCClient) SetMetadata(ctx context.Context, key, value string) error

SetMetadata sets a value in the extended metadata of the sidecar

func (*GRPCClient) Shutdown added in v1.1.0

func (c *GRPCClient) Shutdown(ctx context.Context) error

Shutdown the sidecar.

func (*GRPCClient) Subscribe added in v1.11.0

func (c *GRPCClient) Subscribe(ctx context.Context, opts SubscriptionOptions) (*Subscription, error)

func (*GRPCClient) SubscribeConfigurationItems added in v1.4.0

func (c *GRPCClient) SubscribeConfigurationItems(ctx context.Context, storeName string, keys []string, handler ConfigurationHandleFunction, opts ...ConfigurationOpt) (string, error)

func (*GRPCClient) SubscribeWithHandler added in v1.11.0

func (c *GRPCClient) SubscribeWithHandler(ctx context.Context, opts SubscriptionOptions, handler SubscriptionHandleFunction) (func() error, error)

func (*GRPCClient) TryLockAlpha1 added in v1.5.0

func (c *GRPCClient) TryLockAlpha1(ctx context.Context, storeName string, request *LockRequest) (*LockResponse, error)

TryLockAlpha1 attempts to grab a lock from a lock store.

func (*GRPCClient) UnlockAlpha1 added in v1.5.0

func (c *GRPCClient) UnlockAlpha1(ctx context.Context, storeName string, request *UnlockRequest) (*UnlockResponse, error)

UnlockAlpha1 deletes unlocks a lock from a lock store.

func (*GRPCClient) UnregisterActorReminder added in v1.3.0

func (c *GRPCClient) UnregisterActorReminder(ctx context.Context, in *UnregisterActorReminderRequest) error

UnregisterActorReminder would unregister the actor reminder.

func (*GRPCClient) UnregisterActorTimer added in v1.3.0

func (c *GRPCClient) UnregisterActorTimer(ctx context.Context, in *UnregisterActorTimerRequest) error

UnregisterActorTimer unregisters actor timer.

func (*GRPCClient) UnsubscribeConfigurationItems added in v1.4.0

func (c *GRPCClient) UnsubscribeConfigurationItems(ctx context.Context, storeName string, id string, opts ...ConfigurationOpt) error

func (*GRPCClient) Wait added in v1.7.0

func (c *GRPCClient) Wait(ctx context.Context, timeout time.Duration) error

func (*GRPCClient) WithAuthToken added in v0.11.0

func (c *GRPCClient) WithAuthToken(token string)

WithAuthToken sets Dapr API token on the instantiated client. Allows empty string to reset token on existing client.

func (*GRPCClient) WithTraceID added in v0.11.0

func (c *GRPCClient) WithTraceID(ctx context.Context, id string) context.Context

WithTraceID adds existing trace ID to the outgoing context.

type GetActorStateRequest added in v1.3.0

type GetActorStateRequest struct {
	ActorType string
	ActorID   string
	KeyName   string
}

type GetActorStateResponse added in v1.3.0

type GetActorStateResponse struct {
	Data []byte
}

type GetMetadataResponse added in v1.9.0

type GetMetadataResponse struct {
	ID                   string
	ActiveActorsCount    []*MetadataActiveActorsCount
	RegisteredComponents []*MetadataRegisteredComponents
	ExtendedMetadata     map[string]string
	Subscriptions        []*MetadataSubscription
	HTTPEndpoints        []*MetadataHTTPEndpoint
}

type InvokeActorRequest added in v1.3.0

type InvokeActorRequest struct {
	ActorType string
	ActorID   string
	Method    string
	Data      []byte
}

type InvokeActorResponse added in v1.3.0

type InvokeActorResponse struct {
	Data []byte
}

type InvokeBindingRequest added in v1.0.0

type InvokeBindingRequest struct {
	// Name is name of binding to invoke.
	Name string
	// Operation is the name of the operation type for the binding to invoke
	Operation string
	// Data is the input bindings sent
	Data []byte
	// Metadata is the input binding metadata
	Metadata map[string]string
}

InvokeBindingRequest represents binding invocation request.

type Job added in v1.11.0

type Job struct {
	Name          string
	Schedule      *string
	Repeats       *uint32
	DueTime       *string
	TTL           *string
	Data          *anypb.Any
	FailurePolicy FailurePolicy
	Overwrite     bool
}

func NewJob added in v1.13.0

func NewJob(name string, opts ...JobOption) *Job

type JobFailurePolicyConstant added in v1.13.0

type JobFailurePolicyConstant struct {
	MaxRetries *uint32
	Interval   *time.Duration
}

func (*JobFailurePolicyConstant) GetPBFailurePolicy added in v1.13.0

func (f *JobFailurePolicyConstant) GetPBFailurePolicy() *commonpb.JobFailurePolicy

type JobFailurePolicyDrop added in v1.13.0

type JobFailurePolicyDrop struct{}

func (*JobFailurePolicyDrop) GetPBFailurePolicy added in v1.13.0

func (f *JobFailurePolicyDrop) GetPBFailurePolicy() *commonpb.JobFailurePolicy

type JobOption added in v1.13.0

type JobOption func(*Job)

func WithJobConstantFailurePolicy added in v1.13.0

func WithJobConstantFailurePolicy() JobOption

func WithJobConstantFailurePolicyInterval added in v1.13.0

func WithJobConstantFailurePolicyInterval(interval time.Duration) JobOption

func WithJobConstantFailurePolicyMaxRetries added in v1.13.0

func WithJobConstantFailurePolicyMaxRetries(maxRetries uint32) JobOption

func WithJobData added in v1.13.0

func WithJobData(data *anypb.Any) JobOption

func WithJobDropFailurePolicy added in v1.13.0

func WithJobDropFailurePolicy() JobOption

func WithJobDueTime added in v1.13.0

func WithJobDueTime(dueTime string) JobOption

func WithJobRepeats added in v1.13.0

func WithJobRepeats(repeats uint32) JobOption

func WithJobSchedule added in v1.13.0

func WithJobSchedule(schedule string) JobOption

func WithJobTTL added in v1.13.0

func WithJobTTL(ttl string) JobOption

type LockRequest added in v1.5.0

type LockRequest struct {
	ResourceID      string
	LockOwner       string
	ExpiryInSeconds int32
}

LockRequest is the lock request object.

type LockResponse added in v1.5.0

type LockResponse struct {
	Success bool
}

LockResponse is the lock operation response object.

type MetadataActiveActorsCount added in v1.9.0

type MetadataActiveActorsCount struct {
	Type  string
	Count int32
}

type MetadataHTTPEndpoint added in v1.9.0

type MetadataHTTPEndpoint struct {
	Name string
}

type MetadataRegisteredComponents added in v1.9.0

type MetadataRegisteredComponents struct {
	Name         string
	Type         string
	Version      string
	Capabilities []string
}

type MetadataSubscription added in v1.9.0

type MetadataSubscription struct {
	PubsubName      string
	Topic           string
	Metadata        map[string]string
	Rules           *PubsubSubscriptionRules
	DeadLetterTopic string
}

type OperationType added in v0.10.0

type OperationType int32

OperationType is the operation enum type.

func (OperationType) String added in v0.10.0

func (o OperationType) String() string

String returns the string value of the OperationType.

type PublishEventOption added in v1.3.0

type PublishEventOption func(*pb.PublishEventRequest)

PublishEventOption is the type for the functional option.

func PublishEventWithContentType added in v1.3.0

func PublishEventWithContentType(contentType string) PublishEventOption

PublishEventWithContentType can be passed as option to PublishEvent to set an explicit Content-Type.

func PublishEventWithMetadata added in v1.3.0

func PublishEventWithMetadata(metadata map[string]string) PublishEventOption

PublishEventWithMetadata can be passed as option to PublishEvent to set metadata.

func PublishEventWithRawPayload added in v1.4.0

func PublishEventWithRawPayload() PublishEventOption

PublishEventWithRawPayload can be passed as option to PublishEvent to set rawPayload metadata.

type PublishEventsEvent added in v1.8.0

type PublishEventsEvent struct {
	EntryID     string
	Data        []byte
	ContentType string
	Metadata    map[string]string
}

PublishEventsEvent is a type of event that can be published using PublishEvents.

type PublishEventsOption added in v1.8.0

type PublishEventsOption func(*pb.BulkPublishRequest)

PublishEventsOption is the type for the functional option.

func PublishEventsWithContentType added in v1.8.0

func PublishEventsWithContentType(contentType string) PublishEventsOption

PublishEventsWithContentType can be passed as option to PublishEvents to explicitly set the same Content-Type for all events.

func PublishEventsWithMetadata added in v1.8.0

func PublishEventsWithMetadata(metadata map[string]string) PublishEventsOption

PublishEventsWithMetadata can be passed as option to PublishEvents to set request metadata.

func PublishEventsWithRawPayload added in v1.8.0

func PublishEventsWithRawPayload() PublishEventsOption

PublishEventsWithRawPayload can be passed as option to PublishEvents to set rawPayload request metadata.

type PublishEventsResponse added in v1.8.0

type PublishEventsResponse struct {
	Error        error
	FailedEvents []interface{}
}

PublishEventsResponse is the response type for PublishEvents.

type PubsubSubscriptionRule added in v1.9.0

type PubsubSubscriptionRule struct {
	Match string
	Path  string
}

type PubsubSubscriptionRules added in v1.9.0

type PubsubSubscriptionRules struct {
	Rules []*PubsubSubscriptionRule
}

type QueryItem added in v1.3.1

type QueryItem struct {
	Key   string
	Value []byte
	Etag  string
	Error string
}

QueryItem represents a single query result item.

type QueryResponse added in v1.3.1

type QueryResponse struct {
	Results  []QueryItem
	Token    string
	Metadata map[string]string
}

QueryResponse represents a query result.

type RegisterActorReminderRequest added in v1.3.0

type RegisterActorReminderRequest struct {
	ActorType string
	ActorID   string
	Name      string
	DueTime   string
	Period    string
	TTL       string
	Data      []byte
}

type RegisterActorTimerRequest added in v1.3.0

type RegisterActorTimerRequest struct {
	ActorType string
	ActorID   string
	Name      string
	DueTime   string
	Period    string
	TTL       string
	Data      []byte
	CallBack  string
}

type SetStateItem added in v0.10.0

type SetStateItem struct {
	Key      string
	Value    []byte
	Etag     *ETag
	Metadata map[string]string
	Options  *StateOptions
}

SetStateItem represents a single state to be persisted.

type StateConcurrency

type StateConcurrency int32

StateConcurrency is the concurrency enum type.

func (StateConcurrency) GetPBConcurrency added in v1.2.0

func (s StateConcurrency) GetPBConcurrency() v1.StateOptions_StateConcurrency

GetPBConcurrency get concurrency pb value.

func (StateConcurrency) String

func (s StateConcurrency) String() string

String returns the string value of the StateConcurrency.

type StateConsistency

type StateConsistency int32

StateConsistency is the consistency enum type.

func (StateConsistency) GetPBConsistency added in v1.2.0

func (s StateConsistency) GetPBConsistency() v1.StateOptions_StateConsistency

GetPBConsistency get consistency pb value.

func (StateConsistency) String

func (s StateConsistency) String() string

String returns the string value of the StateConsistency.

type StateItem

type StateItem struct {
	Key      string
	Value    []byte
	Etag     string
	Metadata map[string]string
}

StateItem represents a single state item.

type StateOperation added in v0.10.0

type StateOperation struct {
	Type OperationType
	Item *SetStateItem
}

StateOperation is a collection of StateItems with a store name.

type StateOption added in v1.2.0

type StateOption func(*StateOptions)

StateOption StateOptions's function type.

func WithConcurrency added in v1.2.0

func WithConcurrency(concurrency StateConcurrency) StateOption

WithConcurrency set StateOptions's Concurrency.

func WithConsistency added in v1.2.0

func WithConsistency(consistency StateConsistency) StateOption

WithConsistency set StateOptions's consistency.

type StateOptions

type StateOptions struct {
	Concurrency StateConcurrency
	Consistency StateConsistency
}

StateOptions represents the state store persistence policy.

type Subscription added in v1.11.0

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

func (*Subscription) Close added in v1.11.0

func (s *Subscription) Close() error

func (*Subscription) Receive added in v1.11.0

func (s *Subscription) Receive() (*SubscriptionMessage, error)

type SubscriptionHandleFunction added in v1.11.0

type SubscriptionHandleFunction func(event *common.TopicEvent) common.SubscriptionResponseStatus

type SubscriptionMessage added in v1.11.0

type SubscriptionMessage struct {
	*common.TopicEvent
	// contains filtered or unexported fields
}

func (*SubscriptionMessage) Drop added in v1.11.0

func (s *SubscriptionMessage) Drop() error

func (*SubscriptionMessage) Retry added in v1.11.0

func (s *SubscriptionMessage) Retry() error

func (*SubscriptionMessage) Success added in v1.11.0

func (s *SubscriptionMessage) Success() error

type SubscriptionOptions added in v1.11.0

type SubscriptionOptions struct {
	PubsubName      string
	Topic           string
	DeadLetterTopic *string
	Metadata        map[string]string
}

type ToolChoiceAlpha2 added in v1.13.0

type ToolChoiceAlpha2 string

ToolChoiceAlpha2 defines how to handle tools in a conversation request. It can be either none, auto, required or a specific tool name (with a custom string).

const (
	ToolChoiceNoneAlpha2     ToolChoiceAlpha2 = "none"
	ToolChoiceAutoAlpha2     ToolChoiceAlpha2 = "auto"
	ToolChoiceRequiredAlpha2 ToolChoiceAlpha2 = "required"
)

type UnlockRequest added in v1.5.0

type UnlockRequest struct {
	ResourceID string
	LockOwner  string
}

UnlockRequest is the unlock request object.

type UnlockResponse added in v1.5.0

type UnlockResponse struct {
	StatusCode int32
	Status     string
}

UnlockResponse is the unlock operation response object.

type UnregisterActorReminderRequest added in v1.3.0

type UnregisterActorReminderRequest struct {
	ActorType string
	ActorID   string
	Name      string
}

type UnregisterActorTimerRequest added in v1.3.0

type UnregisterActorTimerRequest struct {
	ActorType string
	ActorID   string
	Name      string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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