server

package
v0.16.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HealthHandler

func HealthHandler(s *Server) http.Handler

Types

type Endpoint

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

func (*Endpoint) Run

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

type LED

type LED interface {
	Set(bool) error
}

type Leader

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

func (*Leader) IsLeading

func (l *Leader) IsLeading() bool

func (*Leader) Run

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

func (*Leader) SetLeader

func (l *Leader) SetLeader(leaderName string)

type Registrant

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

func (*Registrant) Run

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

type Registry

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

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

func (*Registry) Run

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

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

type Schedule

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

type Server

type Server struct {
	Leader
	Endpoint
	Registrant
	Registry
}

func NewServer

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