fleet

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package fleet holds the live state of the edges: sessions, assignments and observed addresses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAssignment

func BuildAssignment(checks []store.Check, labels map[string]string) *netprobev1.Assignment

BuildAssignment keeps the checks whose selector matches labels. The generation is a hash of the content: same checks, same generation.

Types

type Addresses

type Addresses interface {
	ObserveAddress(ctx context.Context, edgeID uuid.UUID, src store.Source, family string, ip netip.Addr, info store.NetInfo, now time.Time) (bool, error)
}

Addresses is the address history.

type Assigner

type Assigner struct {
	Store Checks
	Hub   *Hub
}

Assigner computes the checks of each edge and pushes changes to live sessions.

func (*Assigner) For

func (a *Assigner) For(ctx context.Context, labels map[string]string) (*netprobev1.Assignment, error)

For builds the assignment of an edge with the given labels.

func (*Assigner) Refresh

func (a *Assigner) Refresh(ctx context.Context)

Refresh recomputes every live assignment and pushes the ones that changed.

type Checks

type Checks interface {
	ActiveChecks(ctx context.Context) ([]store.Check, error)
}

Checks lists the checks to assign; the store implements it.

type Hub

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

Hub tracks live sessions and their STUN credentials.

func NewHub

func NewHub() *Hub

func (*Hub) AssignmentStatus

func (h *Hub) AssignmentStatus(edgeID uuid.UUID) (assigned int, rejected []*netprobev1.RejectedCheck)

AssignmentStatus returns what an online edge runs and refused.

func (*Hub) Kick

func (h *Hub) Kick(edgeID uuid.UUID)

Kick closes the Session of an edge, if any.

func (*Hub) Online

func (h *Hub) Online(edgeID uuid.UUID) bool

func (*Hub) Register

func (h *Hub) Register(edgeID uuid.UUID, labels map[string]string, kick context.CancelFunc, now time.Time) *Session

Register opens a Session and kicks the previous one of the same edge.

func (*Hub) STUNCredential

func (h *Hub) STUNCredential(user string) (uuid.UUID, string, bool)

STUNCredential maps a STUN username to its edge and password.

func (*Hub) Sessions

func (h *Hub) Sessions() []*Session

Sessions returns a snapshot of the live sessions.

func (*Hub) Unregister

func (h *Hub) Unregister(s *Session)

Unregister removes s unless a newer Session replaced it.

type Recorder

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

Recorder writes address changes to the history, serialized.

func NewRecorder

func NewRecorder(s Addresses, a *asn.DB) *Recorder

func (*Recorder) Observe

func (r *Recorder) Observe(ctx context.Context, edge uuid.UUID, src store.Source, ip netip.Addr)

type Session

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

Session is the live session of one edge.

func (*Session) Assignments

func (s *Session) Assignments() <-chan *netprobev1.Assignment

Assignments delivers the assignments to send, newest only.

func (*Session) Push

func (s *Session) Push(a *netprobev1.Assignment)

Push queues an assignment unless it is already the last one queued.

func (*Session) STUNPass

func (s *Session) STUNPass() string

func (*Session) STUNUser

func (s *Session) STUNUser() string

STUNUser and STUNPass are the short-term STUN credentials of the session.

func (*Session) SetStatus

func (s *Session) SetStatus(st *netprobev1.AssignmentStatus)

SetStatus records the edge answer for the current generation.

Jump to

Keyboard shortcuts

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