Documentation
¶
Index ¶
- type DummyOutSample
- type ServiceReadWriter
- func (rw *ServiceReadWriter[In, Out]) Call(data In) (*Out, error)
- func (rw *ServiceReadWriter[In, Out]) Close() error
- func (rw *ServiceReadWriter[In, Out]) Init(token ...string) error
- func (rw *ServiceReadWriter[In, Out]) Messages() (<-chan Out, <-chan error, error)
- func (rw *ServiceReadWriter[In, Out]) NextMessage(readyChan chan<- interface{}) (*Out, error)
- func (rw *ServiceReadWriter[In, Out]) Send(data In) error
- type WebSocketRouter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DummyOutSample ¶
type DummyOutSample struct{}
func (DummyOutSample) DecodeAbstract ¶
func (DummyOutSample) DecodeAbstract(*[]byte) (encoder.UserFacingHermodUnit, error)
func (DummyOutSample) GetDefinition ¶
func (DummyOutSample) GetDefinition() *encoder.Unit
type ServiceReadWriter ¶
type ServiceReadWriter[In encoder.UserFacingHermodUnit, Out encoder.UserFacingHermodUnit] struct { Router *WebSocketRouter Endpoint uint16 HasIn bool OutSample Out Context context.Context // contains filtered or unexported fields }
ServiceReadWriter is the user-facing frontend for the Hermod client and is referenced in generated code.
func (*ServiceReadWriter[In, Out]) Call ¶
func (rw *ServiceReadWriter[In, Out]) Call(data In) (*Out, error)
Call opens the session, sends one message, and reads one message. Best for unary-in unary-out functions.
func (*ServiceReadWriter[In, Out]) Close ¶
func (rw *ServiceReadWriter[In, Out]) Close() error
Close closes the route. Re-opening is not supported and may result in unexpected behaviour.
func (*ServiceReadWriter[In, Out]) Init ¶
func (rw *ServiceReadWriter[In, Out]) Init(token ...string) error
Init is called in generated code and must always be run before any other method will work as expected. It calls rw.Router.initRoute to reserve a new client ID and create the route struct.
func (*ServiceReadWriter[In, Out]) Messages ¶
func (rw *ServiceReadWriter[In, Out]) Messages() (<-chan Out, <-chan error, error)
Messages opens the session and returns a pair of channels: one for data values and another for session-specific errors. It blocks until the session has been opened, and returns an error (as the 3rd return value) if the session handshake times out.
func (*ServiceReadWriter[In, Out]) NextMessage ¶
func (rw *ServiceReadWriter[In, Out]) NextMessage(readyChan chan<- interface{}) (*Out, error)
NextMessage reads a single new message. readyChan is a channel that gets closed once the session has been opened. If NextMessage is called after the session has already been opened, readyChan will be closed instantaneously.
func (*ServiceReadWriter[In, Out]) Send ¶
func (rw *ServiceReadWriter[In, Out]) Send(data In) error
Send sends typed data on the session. The session must be open, or this will return an error.
type WebSocketRouter ¶
type WebSocketRouter struct { URL url.URL Timeout time.Duration // contains filtered or unexported fields }
func (*WebSocketRouter) Close ¶
func (router *WebSocketRouter) Close() error
func (*WebSocketRouter) Connect ¶
func (router *WebSocketRouter) Connect(token ...string) error