segreg

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	LogLevelDebug logLevel = "debug"
	LogLevelInfo  logLevel = "info"
	LogLevelError logLevel = "error"
)
View Source
const DefaultPluginID string = "default"

DefaultPluginID is the id for the default segment registration plugin. It is used for the policies that do not have any registration policies.

Variables

This section is empty.

Functions

func RegisterSegmentRegPlugin

func RegisterSegmentRegPlugin(p SegmentRegistrationPlugin)

RegisterSegmentRegPlugin registers a segment registration plugin using its unique ID. It panics if a plugin with the same ID is already registered.

Types

type IgnoreSegmentRegistrar

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

func (*IgnoreSegmentRegistrar) RegisterSegments

func (r *IgnoreSegmentRegistrar) RegisterSegments(
	ctx context.Context,
	segments []beacon.Beacon,
	peers []uint16,
) *RegistrationSummary

type IgnoreSegmentRegistrationPlugin

type IgnoreSegmentRegistrationPlugin struct{}

func (IgnoreSegmentRegistrationPlugin) ID

func (IgnoreSegmentRegistrationPlugin) New

func (IgnoreSegmentRegistrationPlugin) Validate

func (p IgnoreSegmentRegistrationPlugin) Validate(
	config map[string]any,
) error

type RegistrationSummary

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

func NewSummary

func NewSummary() *RegistrationSummary

func (*RegistrationSummary) GetCount

func (s *RegistrationSummary) GetCount() int

func (*RegistrationSummary) GetIfIDs

func (s *RegistrationSummary) GetIfIDs() []uint16

func (*RegistrationSummary) GetSrcs

func (s *RegistrationSummary) GetSrcs() map[addr.IA]struct{}

func (*RegistrationSummary) RecordBeacon

func (s *RegistrationSummary) RecordBeacon(beacon *beacon.Beacon)

func (*RegistrationSummary) RecordSegment

func (s *RegistrationSummary) RecordSegment(segment *seg.PathSegment)

type SegmentRegistrar

type SegmentRegistrar interface {
	// RegisterSegments registers the given segments with the given type according
	// to the plugin's logic. It should either log or handle the errors.
	RegisterSegments(
		ctx context.Context,
		segments []beacon.Beacon,
		peers []uint16,
	) *RegistrationSummary
}

type SegmentRegistrars

type SegmentRegistrars map[beacon.RegPolicyType]map[string]SegmentRegistrar

SegmentRegistrars maps a policy type to a map of registration policy names to their corresponding segment registrars.

func (SegmentRegistrars) GetSegmentRegistrar

func (s SegmentRegistrars) GetSegmentRegistrar(
	policyType beacon.RegPolicyType, registrationPolicy string,
) (SegmentRegistrar, error)

GetSegmentRegistrar returns the segment registrar for the given policy type and registration policy. It should be registered with either RegisterSegmentRegistrar or RegisterDefaultRegistrar first.

func (SegmentRegistrars) RegisterDefaultSegmentRegistrar

func (s SegmentRegistrars) RegisterDefaultSegmentRegistrar(
	policyType beacon.RegPolicyType, registrar SegmentRegistrar,
) error

RegisterDefaultSegmentRegistrar registers a default registrar for a given policy type. The default registrar should be registered when no specific registration policy is defined for policyType. The default registrar is associated with the name beacon.DefaultGroup.

func (SegmentRegistrars) RegisterSegmentRegistrar

func (s SegmentRegistrars) RegisterSegmentRegistrar(
	policyType beacon.RegPolicyType,
	registrationPolicy string,
	registrar SegmentRegistrar,
) error

RegisterSegmentRegistrar registers a segment registrar for a given policy type and registration policy.

type SegmentRegistrationPlugin

type SegmentRegistrationPlugin interface {
	// ID returns the unique identifier of the plugin.
	ID() string
	// New creates a new instance of the plugin with the provided configuration.
	New(
		ctx context.Context,
		policyType beacon.RegPolicyType,
		config map[string]any,
	) (SegmentRegistrar, error)
	// Validate validates the configuration of the plugin.
	Validate(config map[string]any) error
}

func GetDefaultSegmentRegPlugin

func GetDefaultSegmentRegPlugin() (SegmentRegistrationPlugin, bool)

GetDefaultSegmentRegPlugin retrieves the segment registration plugin that has the id DefaultPluginID.

func GetSegmentRegPlugin

func GetSegmentRegPlugin(id string) (SegmentRegistrationPlugin, bool)

GetSegmentRegPlugin retrieves a segment registration plugin by its ID. It should be registered with RegisterSegmentRegPlugin first. The second return value is false if no plugin with the given ID is found in the registry.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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