bindings

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: MIT Imports: 3 Imported by: 76

README

Bindings

Bindings provide a common way to trigger an application with events from external systems, or invoke an external system with optional data payloads. Bindings are great for event-driven, on-demand compute and help reduce boilerplate code.

To get started with bindings visit the How To Guide.

To view all the currently supported bindings visit: Dapr bindings.

For detailed binding specs visit Dapr binding specs.

Implementing a new binding

A compliant binding needs to implement one or more interfaces, depending on the type of binding (Input or Output):

Input binding:

type InputBinding interface {
	Init(metadata Metadata) error
	Read(handler func(*ReadResponse) ([]byte, error)) error
}

Output binding:

An output binding can be used to invoke an external system and also to return data from it. Each output binding can decide which operations it supports. This information is communicated to the caller via the Operations() method.

type OutputBinding interface {
	Init(metadata Metadata) error
	Invoke(req *InvokeRequest) (*InvokeResponse, error)
	Operations() []OperationKind
}

When creating an Output Binding, a list of OperationKind items needs to be returned. For example, if running a component that takes in a SQL query and returns a result set, the OperationKind can be query.

While components are not restricted to a list of supported operations, it's best to use common ones if the operation kind falls under that operation definition. The list of common operations can be found here.

After implementing a binding, the specification docs need to be updated via a PR: Dapr docs.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppResponse

type AppResponse struct {
	Data        interface{}        `json:"data"`
	To          []string           `json:"to"`
	StoreName   string             `json:"storeName"`
	State       []state.SetRequest `json:"state"`
	Concurrency string             `json:"concurrency"`
}

AppResponse is the object describing the response from user code after a bindings event.

type InputBinding

type InputBinding interface {
	// Init passes connection and properties metadata to the binding implementation
	Init(metadata Metadata) error
	// Read is a blocking method that triggers the callback function whenever an event arrives
	Read(handler func(*ReadResponse) ([]byte, error)) error
}

InputBinding is the interface to define a binding that triggers on incoming events.

type InvokeRequest

type InvokeRequest struct {
	Data      []byte            `json:"data"`
	Metadata  map[string]string `json:"metadata"`
	Operation OperationKind     `json:"operation"`
}

InvokeRequest is the object given to a dapr output binding.

func (*InvokeRequest) GetMetadataAsBool added in v1.4.4

func (r *InvokeRequest) GetMetadataAsBool(key string) (bool, error)

GetMetadataAsBool parses metadata as bool.

func (*InvokeRequest) GetMetadataAsInt64 added in v1.4.4

func (r *InvokeRequest) GetMetadataAsInt64(key string, bitSize int) (int64, error)

GetMetadataAsInt64 parses metadata as int64.

type InvokeResponse

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

InvokeResponse is the response object returned from an output binding.

type Metadata

type Metadata struct {
	Name       string
	Properties map[string]string `json:"properties"`
}

Metadata represents a set of binding specific properties.

type OperationKind

type OperationKind string

OperationKind defines an output binding operation.

const (
	GetOperation    OperationKind = "get"
	CreateOperation OperationKind = "create"
	DeleteOperation OperationKind = "delete"
	ListOperation   OperationKind = "list"
)

Non exhaustive list of operations. A binding can add operations that are not in this list.

type OutputBinding

type OutputBinding interface {
	Init(metadata Metadata) error
	Invoke(req *InvokeRequest) (*InvokeResponse, error)
	Operations() []OperationKind
}

OutputBinding is the interface for an output binding, allowing users to invoke remote systems with optional payloads.

type ReadResponse

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

ReadResponse is the return object from an dapr input binding.

Directories

Path Synopsis
alicloud
oss
Package apns implements an output binding for Dapr that allows services to send push notifications to Apple devices and Mac computers using Apple's Push Notification Service (APNS).
Package apns implements an output binding for Dapr that allows services to send push notifications to Apple devices and Mac computers using Apple's Push Notification Service (APNS).
aws
s3
ses
sns
sqs
azure
gcp
rethinkdb
twilio
sms

Jump to

Keyboard shortcuts

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