ensign

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: BSD-3-Clause Imports: 39 Imported by: 0

Documentation

Overview

Package ensign implements the Ensign single node server.

Index

Constants

View Source
const BufferSize = 16384
View Source
const EventMaxDataSize int = 5.243e6

Cannot publish events > 5MiB long

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 {
	health.ProbeServer
	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) CreateTopic added in v0.5.0

func (s *Server) CreateTopic(ctx context.Context, in *api.Topic) (_ *api.Topic, err error)

CreateTopic is a user-facing request to create a Topic. Ensign first verifies that the topic is eligible to be created, then stores the topic in a pending state to disk and returns success to the user. Afterwards, Ensign sends a notification to the placement service in order to figure out where the topic should be assigned so that it can start receiving events.

func (*Server) DeleteTopic added in v0.5.0

func (s *Server) DeleteTopic(ctx context.Context, in *api.TopicMod) (out *api.TopicTombstone, err error)

DeleteTopic is a user-facing request to modify a topic and either archive it, which will make it read-only permanently or to destroy it, which will also have the effect of removing all of the data in the topic. This method is a stateful method, e.g. the topic will be updated to the current status then the Ensign placement server will take action from there.

func (*Server) ListTopics added in v0.5.0

func (s *Server) ListTopics(ctx context.Context, in *api.PageInfo) (out *api.TopicsPage, err error)

ListTopics associated with the project ID in the claims of the request. This unary request is paginated to prevent a huge amount of data transfer.

func (*Server) Publish

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

Publish implements the streaming endpoint for the API.

func (*Server) RetrieveTopic added in v0.5.1

func (s *Server) RetrieveTopic(ctx context.Context, in *api.Topic) (out *api.Topic, err error)

RetrieveTopic is a user-face request to fetch a single Topic and is typically used for existence checks; e.g. does this topic exist or not. The user only has to specify a TopicID in the request and then a complete topic is returned. If the topic is not found a status error with codes.NotFound is returned.

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) StoreMock added in v0.5.0

func (s *Server) StoreMock() *mock.Store

StoreMock returns the underlying store for testing purposes. Can only be accessed in storage testing mode otherwise the method panics.

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) TopicExists added in v0.5.1

func (s *Server) TopicExists(ctx context.Context, in *api.TopicName) (out *api.TopicExistsInfo, err error)

TopicExists does a quick check to see if the topic ID or name exists in the project and returns a simple yes or no bool with the original query. If both ID and name are specified then this method checks if a topic with the specified name has the specified ID (e.g. it is a more strict existence check). The claims must have any of the topics:read, publisher, or subscriber permissions in order to access this endpoint.

func (*Server) TopicNames added in v0.5.1

func (s *Server) TopicNames(ctx context.Context, in *api.PageInfo) (out *api.TopicNamesPage, err error)

TopicNames returns a paginated response that maps topic names to IDs for all topics in the project. The claims must have any of the topics:read, publisher, or subscriber permissions in order to access this endpoint.

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().

func (*Server) WaitForQuarterdeck added in v0.5.0

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

Creates a quarterdeck client connected to the same host as the Auth KeysURL and waits until Quarterdeck returns a healthy response or the exponential timeout backoff limit is reached before returning.

Directories

Path Synopsis
api
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.
Ensign maintains two separate storage locations on disk: the event store which is intended to be an append-only fast disk write for incoming events and a meta store which is used to persist operational metadata such as topic and placement information.
Ensign maintains two separate storage locations on disk: the event store which is intended to be an append-only fast disk write for incoming events and a meta store which is used to persist operational metadata such as topic and placement information.
errors
Package errors implements standard database read/write errors for the store package.
Package errors implements standard database read/write errors for the store package.

Jump to

Keyboard shortcuts

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