apiserver

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package apiserver implements the API interface of Netrix.

The package is used internally by Netrix to instantiate an API interface. The package also contains the interface to invoke directives and send messages to processes/replicas.

Index

Constants

View Source
const DefaultAddr = "0.0.0.0:7074"

DefaultAddr is the default address of the APIServer

Variables

View Source
var (
	// ErrDestUnknown is returned when a message is asked to be dispatched to an unknown replicas
	ErrDestUnknown = errors.New("destination unknown")
	// ErrFailedMarshal is returned when the message could not be marshalled
	ErrFailedMarshal = errors.New("failed to marshal data")
	// ErrDuplicateDispatch is returned when a message already sent is being dispatched again
	ErrDuplicateDispatch = errors.New("message already dispatched")
	// ErrSendFailed is returned when the request could not be created
	ErrSendFailed = errors.New("sending failed")
	// ErrResponseReadFail is returned when the response to the request could not be read
	ErrResponseReadFail = errors.New("failed to read response")
	// ErrBadResponse is returned when the request did not receive a 2** response
	ErrBadResponse = errors.New("bad response")
)

Functions

This section is empty.

Types

type APIServer

type APIServer struct {
	*types.BaseService
	// contains filtered or unexported fields
}

APIServer implements types.Service interface.

func NewAPIServer

func NewAPIServer(ctx *context.RootContext, messageParser types.MessageParser, dashboard DashboardRouter) *APIServer

NewAPIServer instantiates APIServer

func (*APIServer) ForgetSentMessages added in v0.2.1

func (a *APIServer) ForgetSentMessages()

ForgetSendMessages clears the delivered message cache.

func (*APIServer) RestartAll added in v0.2.1

func (d *APIServer) RestartAll() error

RestartAll sends a Restart directive to all replicas

func (*APIServer) RestartReplica added in v0.2.1

func (d *APIServer) RestartReplica(replica types.ReplicaID) error

RestartReplica sends the Restart directive to the replica

func (*APIServer) SendMessage added in v0.2.1

func (a *APIServer) SendMessage(msg *types.Message) error

SendMessage should be invoked to send the message to the intended replica. The MessageID is cached and subsequent invocations for the same message will result in a no-op

func (*APIServer) SendTimeout added in v0.2.1

func (d *APIServer) SendTimeout(t *types.ReplicaTimeout) error

SendTimeout sends a timeout message to the replica. This is the equivalent of ending a timeout at the replica.

func (*APIServer) Start

func (a *APIServer) Start()

Start runs the HTTP server and starts listening to the API requests.

func (*APIServer) StartReplica added in v0.2.1

func (d *APIServer) StartReplica(replica types.ReplicaID) error

StartReplica sends the Start directive to the replica

func (*APIServer) Stop

func (a *APIServer) Stop()

Stop terminates the HTTP server.

func (*APIServer) StopReplica added in v0.2.1

func (d *APIServer) StopReplica(replica types.ReplicaID) error

StopReplica sends the Stop directive to the replica

type DashboardRouter

type DashboardRouter interface {
	// Name should return the key for the dashboard type
	Name() string
	// SetupRouter should set up the routes for the dashboard
	SetupRouter(*gin.RouterGroup)
}

DashboardRouter for handling routes that are specific to the dashboard. The APIServer will be initialized with an instance of DashboardRouter. The dashboard routes depends on the mode in which the scheduler is run.

Jump to

Keyboard shortcuts

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