dapr

package
v0.0.0-...-8cfd1f9 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	APIURL = fmt.Sprintf("http://127.0.0.1:%s/", os.Getenv("DAPR_HTTP_PORT"))
)
View Source
var ErrDuplicateDefaultRoute = errors.New("duplicate default route")
View Source
var (
	GRPCADDRESS = fmt.Sprintf("127.0.0.1:%s", os.Getenv("DAPR_GRPC_PORT"))
)

Functions

func DecodeCloudEvent

func DecodeCloudEvent(c *fiber.Ctx, ce *CloudEvent, target interface{}) error

func InvokingContext

func InvokingContext(ctx context.Context, daprAppID string) context.Context

InvokingContext returns a new context with the target Dapr App ID added to outgoing metadata.

func RegisterEventHandlers

func RegisterEventHandlers(app *fiber.App, events ...Events)

func RegisterServices

func RegisterServices(app *fiber.App, services ...Service)

func Subscribe

func Subscribe(log logr.Logger, register func(subscriptions []*Subscription), subscribers ...Subscriber)

Subscribe will gather all the subscriptions from `subscribers`, merge them, and pass them to `register`.

func SubscribeHTTPHandler

func SubscribeHTTPHandler(log logr.Logger, app *fiber.App) func(subscriptions []*Subscription)

func UnaryClientInterceptor

func UnaryClientInterceptor(
	ctx context.Context,
	method string,
	req, reply interface{},
	cc *grpc.ClientConn,
	invoker grpc.UnaryInvoker,
	opts ...grpc.CallOption) error

UnaryClientInterceptor for passing incoming metadata to outgoing metadata

Types

type Client

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

func NewSDK

func NewSDK(ctx context.Context) (*Client, error)

func (*Client) GetSecret

func (c *Client) GetSecret(ctx context.Context, store string, name string, target interface{}) error

func (*Client) GetState

func (c *Client) GetState(ctx context.Context, store string, key string, target interface{}) error

func (*Client) Name

func (c *Client) Name() string

func (*Client) SetState

func (c *Client) SetState(ctx context.Context, store string, items ...state.Item) error

type CloudEvent

type CloudEvent struct {
	ID              string          `json:"id"`
	Source          string          `json:"source"`
	SpecVersion     string          `json:"specversion"`
	Type            string          `json:"type"`
	DataContentType string          `json:"datacontenttype,omitempty"`
	DataSchema      string          `json:"dataschema,omitempty"`
	Subject         string          `json:"subject,omitempty"`
	Time            time.Time       `json:"time,omitempty"`
	Data            json.RawMessage `json:"data"`
}

CloudEvents specification can be found at https://github.com/cloudevents/spec/blob/v1.0.1/spec.md

type Events

type Events interface {
	RegisterEventHandlers(app *fiber.App)
}

type GRPC

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

func NewGRPC

func NewGRPC(ctx context.Context) (*GRPC, error)

func (*GRPC) GetSecret

func (c *GRPC) GetSecret(ctx context.Context, store string, name string, target interface{}) error

func (*GRPC) GetState

func (c *GRPC) GetState(ctx context.Context, store string, key string, target interface{}) error

func (*GRPC) Name

func (c *GRPC) Name() string

func (*GRPC) SetState

func (c *GRPC) SetState(ctx context.Context, store string, items ...state.Item) error

type HTTP

type HTTP struct{}

func NewHTTP

func NewHTTP(ctx context.Context) (*HTTP, error)

func (*HTTP) GetSecret

func (c *HTTP) GetSecret(ctx context.Context, store string, name string, target interface{}) error

func (*HTTP) GetState

func (c *HTTP) GetState(ctx context.Context, store string, key string, target interface{}) error

func (*HTTP) Name

func (c *HTTP) Name() string

func (*HTTP) SetState

func (c *HTTP) SetState(ctx context.Context, store string, items ...state.Item) error

type HandlerRegistrar

type HandlerRegistrar interface {
	RegisterTopicEventHandlers(register RegisterEventHandler)
}

type RegisterEventHandler

type RegisterEventHandler func(path string, handler TopicEventHandler)

type Routes

type Routes struct {
	Rules   []Rule `json:"rules,omitempty"`
	Default string `json:"default,omitempty"`
}

Dapr subscription response

type Rule

type Rule struct {
	Match string `json:"match"`
	Path  string `json:"path"`
}

Dapr subscription response

type Server

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

func NewServer

func NewServer(log logr.Logger) *Server

func (*Server) ListInputBindings

func (s *Server) ListInputBindings(ctx context.Context, in *empty.Empty) (*pb.ListInputBindingsResponse, error)

func (*Server) ListTopicSubscriptions

func (s *Server) ListTopicSubscriptions(ctx context.Context, in *empty.Empty) (*pb.ListTopicSubscriptionsResponse, error)

func (*Server) OnBindingEvent

func (s *Server) OnBindingEvent(ctx context.Context, in *pb.BindingEventRequest) (*pb.BindingEventResponse, error)

func (*Server) OnInvoke

func (s *Server) OnInvoke(ctx context.Context, in *cpb.InvokeRequest) (*cpb.InvokeResponse, error)

func (*Server) OnTopicEvent

func (s *Server) OnTopicEvent(ctx context.Context, in *pb.TopicEventRequest) (*pb.TopicEventResponse, error)

func (*Server) RegisterTopicEventHandler

func (s *Server) RegisterTopicEventHandler(path string, handler TopicEventHandler)

func (*Server) RegisterTopicEventHandlers

func (s *Server) RegisterTopicEventHandlers(registrars ...HandlerRegistrar)

func (*Server) Subscribe

func (s *Server) Subscribe(subscriptions []*Subscription)

type Service

type Service interface {
	RegisterService(app *fiber.App)
}

type Subscriber

type Subscriber interface {
	Subscriptions() []Subscription
}

Dapr subscription response

type Subscription

type Subscription struct {
	PubsubName string            `json:"pubsubname"`
	Topic      string            `json:"topic"`
	Metadata   map[string]string `json:"metadata,omitempty"`
	Routes     Routes            `json:"routes"`
}

Dapr subscription response

type TopicEventHandler

type TopicEventHandler func(ctx context.Context, in *pb.TopicEventRequest) (*pb.TopicEventResponse, error)

Jump to

Keyboard shortcuts

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