ensign

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Overview

Package ensign implements the Ensign single node server.

Index

Constants

View Source
const BufferSize = 16384

Variables

This section is empty.

Functions

This section is empty.

Types

type PubSub

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

PubSub is a simple dispatcher that has a publish queue that fans in events from different publisher streams and assigns event ids then fans the events out to send them to one or more subscriber streams with an outgoing buffer. Backpressure is applied to the publisher streams when the buffers get full.

func NewPubSub

func NewPubSub() (ps *PubSub)

func (*PubSub) Finish

func (ps *PubSub) Finish(id uuid.UUID)

Finish closes a subscribe channel and removes it so that the PubSub no longer sends.

func (*PubSub) Publish

func (ps *PubSub) Publish(event *api.Event) rlid.RLID

Publish puts an event on the input queue and waits until the event is handled and an ID is assigned then returns the ID of the event to the caller.

func (*PubSub) Subscribe

func (ps *PubSub) Subscribe() (id uuid.UUID, c buffer.Channel)

Subscribe creates returns a channel that the caller can use to fetch events off of the in memory queue from. It also returns an ID so that the caller can close and cleanup the channel when it is done listenting for events.

type Server

type Server struct {
	api.UnimplementedEnsignServer
	// contains filtered or unexported fields
}

An Ensign server implements the Ensign service as defined by the wire protocol.

func New

func New(conf config.Config) (s *Server, err error)

New creates a new ensign server with the given configuration. Most server setup is conducted in this method including setting up logging, connecting to databases, etc. If this method succeeds without an error, the server is ready to be served, but it will not listen to or handle requests until the Serve() method is called.

func (*Server) Publish

func (s *Server) Publish(stream api.Ensign_PublishServer) (err error)

Publish implements the streaming endpoint for the API.

func (*Server) Run

func (s *Server) Run(sock net.Listener)

Run the gRPC server on the specified socket. This method can be used to serve TCP requests or to connect to a bufconn for testing purposes. This method blocks while the server is running so it should be run in a go routine.

func (*Server) Serve

func (s *Server) Serve() (err error)

Serve RPC requests on the bind address specified in the configuration.

func (*Server) Shutdown

func (s *Server) Shutdown() (err error)

Shutdown stops the ensign server and all long running processes gracefully. May return a multierror if there were multiple problems during shutdown but it will attempt to close all open services and processes.

func (*Server) Status

func (s *Server) Status(ctx context.Context, in *api.HealthCheck) (out *api.ServiceState, err error)

Status implements a simple heartbeat mechanism for checking on the state of the Ensign server and making sure that the node is up and responding.

func (*Server) StreamInterceptors

func (s *Server) StreamInterceptors() []grpc.StreamServerInterceptor

Prepares the interceptors (middleware) for the unary RPC endpoints of the server. The first interceptor will be the outer most, while the last interceptor will be the inner most wrapper around the real call. All stream interceptors returned by this method should be chained using grpc.ChainStreamInterceptor().

func (*Server) Subscribe

func (s *Server) Subscribe(stream api.Ensign_SubscribeServer) (err error)

Subscribe implements the streaming endpoint for the API

func (*Server) UnaryInterceptors

func (s *Server) UnaryInterceptors() []grpc.UnaryServerInterceptor

Prepares the interceptors (middleware) for the unary RPC endpoings of the server. The first interceptor will be the outer most, while the last interceptor will be the inner most wrapper around the real call. All unary interceptors returned by this method should be chained using grpc.ChainUnaryInterceptor().

Directories

Path Synopsis
Package mock implements an in-memory gRPC mock Ensign server that can be connected to using a bufconn.
Package mock implements an in-memory gRPC mock Ensign server that can be connected to using a bufconn.
Package o11y (a numeronym for "observability") exports server-specific metric collectors to Prometheus for monitoring of the service and Ensign nodes.
Package o11y (a numeronym for "observability") exports server-specific metric collectors to Prometheus for monitoring of the service and Ensign nodes.

Jump to

Keyboard shortcuts

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