server

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HealthHandler added in v0.15.0

func HealthHandler(s *Server) http.Handler

Types

type Endpoint added in v0.15.0

type Endpoint struct {
	LED
	// contains filtered or unexported fields
}

func (*Endpoint) Run added in v0.15.0

func (e *Endpoint) Run(ctx context.Context) error

type LED added in v0.12.0

type LED interface {
	Set(bool) error
}

type Leader added in v0.15.0

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

func (*Leader) IsLeading added in v0.15.0

func (l *Leader) IsLeading() bool

func (*Leader) Run added in v0.15.0

func (l *Leader) Run(ctx context.Context) error

func (*Leader) SetLeader added in v0.15.0

func (l *Leader) SetLeader(leaderName string)

type Registrant added in v0.11.0

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

func (*Registrant) Run added in v0.15.0

func (r *Registrant) Run(ctx context.Context) error

type Registry added in v0.11.0

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

A Registry performs two functions. Firstly, it maintains the list of active nodes. Secondly, it registers the local node with the active registry.

func (*Registry) Nodes added in v0.15.0

func (r *Registry) Nodes() []string

func (*Registry) Run added in v0.15.0

func (r *Registry) Run(ctx context.Context) error

Run listens for incoming 'node' events and registers them. Old nodes are removed regularly.

type Schedule added in v0.15.0

type Schedule interface {
	Next(int) []bool
}

type Server

type Server struct {
	Leader
	Endpoint
	Registrant
	Registry
}

func NewServer added in v0.15.0

func NewServer(
	nodeName string,
	schedule Schedule,
	client *redis.Client,
	led LED,
	ledInterval time.Duration,
	registrationInterval time.Duration,
	nodeExpiration time.Duration,
	r prometheus.Registerer,
	logger *slog.Logger,
) *Server

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

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