Documentation ¶
Overview ¶
Package action implements the Cloudstate Action protocol.
Index ¶
- type CancelFunc
- type CloseFunc
- type CommandID
- type Context
- func (c *Context) Cancel()
- func (c *Context) CancellationFunc(cancel CancelFunc)
- func (c *Context) CloseFunc(close CloseFunc)
- func (c *Context) Command() *entity.ActionCommand
- func (c *Context) Forward(forward *protocol.Forward)
- func (c *Context) Metadata() *protocol.Metadata
- func (c *Context) Respond(err error) error
- func (c *Context) RespondWith(response *any.Any)
- func (c *Context) SideEffect(effect *protocol.SideEffect)
- type Entity
- type EntityHandler
- type EntityID
- type RespondFunc
- type Server
- func (s *Server) HandleStreamed(stream entity.ActionProtocol_HandleStreamedServer) error
- func (s *Server) HandleStreamedIn(stream entity.ActionProtocol_HandleStreamedInServer) error
- func (s *Server) HandleStreamedOut(command *entity.ActionCommand, ...) error
- func (s *Server) HandleUnary(ctx context.Context, command *entity.ActionCommand) (*entity.ActionResponse, error)
- func (s *Server) Register(e *Entity) error
- type ServiceName
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CancelFunc ¶
type Context ¶
type Context struct { // Entity describes the instance that is used as an entity. Entity *Entity // Instance is the instance of the entity this context is for. Instance EntityHandler // contains filtered or unexported fields }
func (*Context) CancellationFunc ¶
func (c *Context) CancellationFunc(cancel CancelFunc)
func (*Context) CloseFunc ¶
CloseFunc registers a function that is called whenever a client closes a stream.
func (*Context) Command ¶
func (c *Context) Command() *entity.ActionCommand
func (*Context) RespondWith ¶
func (*Context) SideEffect ¶
func (c *Context) SideEffect(effect *protocol.SideEffect)
type Entity ¶
type Entity struct { // ServiceName is the fully qualified name of the service that implements // this entities interface. Setting it is mandatory. ServiceName ServiceName // EntityFunc creates a new entity. EntityFunc func() EntityHandler }
type EntityHandler ¶
type RespondFunc ¶
type Server ¶
type Server struct { // internal marker enforced by go-grpc. entity.UnimplementedActionProtocolServer // contains filtered or unexported fields }
Server is the implementation of the Server server API for the CRDT service.
func (*Server) HandleStreamed ¶
func (s *Server) HandleStreamed(stream entity.ActionProtocol_HandleStreamedServer) error
HandleStreamed handles a full duplex streamed command.
The first message in will contain the request metadata, including the service name and command name. It will not have an associated payload set. This will be followed by zero to many messages in with a payload, but no service name or command name set.
Zero or more replies may be sent, each containing either a direct reply, a forward or a failure, and each may contain many side effects.
If the underlying transport supports per stream metadata, rather than per message metadata, then that metadata will only be included in the metadata of the first message. In contrast, if the underlying transport supports per message metadata, there will be no metadata on the first message, the metadata will instead be found on each subsequent message.
The semantics of stream closure in this protocol map 1:1 with the semantics of gRPC stream closure, that is, when the client closes the stream, the stream is considered half closed, and the server should eventually, but not necessarily immediately, close the stream with a status code and trailers.
If however the server closes the stream with a status code and trailers, the stream is immediately considered completely closed, and no further messages sent by the client will be handled by the server.
Either the client or the server may cancel the stream at any time, cancellation is indicated through an HTTP2 stream RST message.
func (*Server) HandleStreamedIn ¶
func (s *Server) HandleStreamedIn(stream entity.ActionProtocol_HandleStreamedInServer) error
HandleStreamedIn handles a streamed in command. The first message in will contain the request metadata, including the service name and command name. It will not have an associated payload set. This will be followed by zero to many messages in with a payload, but no service name or command name set.
If the underlying transport supports per stream metadata, rather than per message metadata, then that metadata will only be included in the metadata of the first message. In contrast, if the underlying transport supports per message metadata, there will be no metadata on the first message, the metadata will instead be found on each subsequent message.
The semantics of stream closure in this protocol map 1:1 with the semantics of gRPC stream closure, that is, when the client closes the stream, the stream is considered half closed, and the server should eventually, but not necessarily immediately, send a response message with a status code and trailers. If however the server sends a response message before the client closes the stream, the stream is completely closed, and the client should handle this and stop sending more messages.
Either the client or the server may cancel the stream at any time, cancellation is indicated through an HTTP2 stream RST message.
func (*Server) HandleStreamedOut ¶
func (s *Server) HandleStreamedOut(command *entity.ActionCommand, stream entity.ActionProtocol_HandleStreamedOutServer) error
HandleStreamedOut handles a streamed out command. The input command will contain the service name, command name, request metadata and the command payload. Zero or more replies may be sent, each containing either a direct reply, a forward or a failure, and each may contain many side effects. The stream to the client will be closed when the this stream is closed, with the same status as this stream is closed with.
Either the client or the server may cancel the stream at any time, cancellation is indicated through an HTTP2 stream RST message.
func (*Server) HandleUnary ¶
func (s *Server) HandleUnary(ctx context.Context, command *entity.ActionCommand) (*entity.ActionResponse, error)
HandleUnary handles an unary command. The input command will contain the service name, command name, request metadata and the command payload. The reply may contain a direct reply, a forward or a failure, and it may contain many side effects.
type ServiceName ¶
type ServiceName string
func (ServiceName) String ¶
func (sn ServiceName) String() string