node

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 58 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InitJournal at position 0 initializes the journal global var as soon as
	// the system starts, so that it's available for all other components.
	InitJournalKey = invoke(iota)

	ExtractAPIKey

	CheckFDLimit
	InitDataTables

	RunGateway
)

Invokes are called in the order they are defined.

Variables

This section is empty.

Functions

func From

func From(typ interface{}) interface{}

From(*T) -> func(t T) T {return t}

func IsType

func IsType(t repo.RepoType) func(s *Settings) bool

func LocatorHandler

func LocatorHandler(a api.Locator, permission bool) (http.Handler, error)

LocatorHandler returns a locator handler, to be mounted as-is on the server.

func MonitorShutdown

func MonitorShutdown(triggerCh <-chan struct{}, handlers ...ShutdownHandler) <-chan struct{}

MonitorShutdown manages shutdown requests, by watching signals and invoking the supplied handlers in order.

It watches SIGTERM and SIGINT OS signals, as well as the trigger channel. When any of them fire, it calls the supplied handlers in order. If any of them errors, it merely logs the error.

Once the shutdown has completed, it closes the returned channel. The caller can watch this channel

func SchedulerHandler

func SchedulerHandler(a api.Scheduler, permission bool, opts ...jsonrpc.ServerOption) (http.Handler, error)

SchedulerHandler returns a scheduler handler, to be mounted as-is on the server.

Types

type Option

type Option func(*Settings) error

Option is a functional option which can be used with the New function to change how the node is constructed

Options are applied in sequence

func ApplyIf

func ApplyIf(check func(s *Settings) bool, opts ...Option) Option

func Base

func Base() Option

func Candidate

func Candidate(out *api.Candidate) Option

func ConfigCandidate

func ConfigCandidate(c interface{}) Option

func ConfigEdge

func ConfigEdge(c interface{}) Option

func ConfigLocator

func ConfigLocator(c interface{}) Option

func ConfigScheduler

func ConfigScheduler(c interface{}) Option

func Edge

func Edge(out *api.Edge) Option

func Error

func Error(err error) Option

Error is a special option which returns an error when applied

func If

func If(b bool, opts ...Option) Option

func Locator

func Locator(out *api.Locator) Option

func Options

func Options(opts ...Option) Option

Options groups multiple options into one

func Override

func Override(typ, constructor interface{}) Option

Override option changes constructor for a given type

func Repo

func Repo(r repo.Repo) Option

func Scheduler

func Scheduler(out *api.Scheduler) Option

func Unset

func Unset(typ interface{}) Option

type Settings

type Settings struct {
	Base   bool // Base option applied
	Config bool // Config option applied
	// contains filtered or unexported fields
}

type ShutdownHandler

type ShutdownHandler struct {
	Component string
	StopFunc  StopFunc
}

type StopFunc

type StopFunc func(context.Context) error

func New

func New(ctx context.Context, opts ...Option) (StopFunc, error)

New builds and starts new Titan node

func ServeRPC

func ServeRPC(h http.Handler, id string, addr string) (StopFunc, error)

ServeRPC serves an HTTP handler over the supplied listen multiaddr.

This function spawns a goroutine to run the server, and returns immediately. It returns the stop function to be called to terminate the endpoint.

The supplied ID is used in tracing, by inserting a tag in the context.

Jump to

Keyboard shortcuts

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