Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoBrokerConfigured = errors.New("broker: no broker configured") ErrIllegalUnsubscribe = errors.New("broker: unsubscribe without prior subscription illegal") )
var (
ErrNoGatewayConfigured = errors.New("gateway: no gateway configured")
)
Functions ¶
This section is empty.
Types ¶
type Broker ¶
type Broker interface { Bind(*Service) Subscribe(string, ChannelHandler) error Unsubscribe(string) error Publish(string, interface{}) error Request(string, interface{}) (*Context, error) Connect() error Disconnect() error }
Broker is an abstraction to allow provider agnostic interactions with a event broker or message queue.
type ChannelHandler ¶
ChannelHandler describes the function signature of the functions that implements the logic for the channel.
type Context ¶
type Context struct { Service *Service Cloudevent *cloudevents.Event }
Context is the structure of the data that is passed to a channel.
type Gateway ¶
type Gateway interface { Bind(*Service) Route(RequestHandler) Listen() }
TODO: Create abstraction such that implementation just uses enriched TCP, such that a gateway could also support MQTT or other protocols in the future.
type Request ¶
type Request struct { Context interface{} Service *Service }
Request is an abstract interface that provides access to to high level properties of the broker implementation.
type RequestHandler ¶
RequestHandler is the abstracted method that will be implemented by the API consumer.
type Service ¶
type Service struct { Logger *zerolog.Logger Broker Broker Gateway Gateway Config Config // contains filtered or unexported fields }
Service contains the state and configuration of a microservice.
func (*Service) BrokerChannel ¶
func (svc *Service) BrokerChannel(channel string, channelHandler ChannelHandler) *Service
func (*Service) GatewayMiddleware ¶
func (svc *Service) GatewayMiddleware(requestHandler RequestHandler) *Service
func (*Service) Start ¶
func (svc *Service) Start()
Start is a blocking function that starts the service.