controlplane

package
v0.0.0-...-c124da1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package controlplane defines versioned snapshots for service discovery, configuration and governance policy distribution.

Index

Constants

View Source
const DefaultSnapshotVersion = "gofly-control-plane.v1"

Variables

This section is empty.

Functions

func DeduplicateSnapshotEvents

func DeduplicateSnapshotEvents(ctx context.Context, in <-chan SnapshotEvent) <-chan SnapshotEvent

Types

type CompositeProvider

type CompositeProvider struct {
	Version       string
	Name          string
	Contributors  []SnapshotContributor
	WatchInterval time.Duration
}

func (CompositeProvider) Load

func (CompositeProvider) Source

func (p CompositeProvider) Source() string

func (CompositeProvider) Watch

func (p CompositeProvider) Watch(ctx context.Context) (<-chan SnapshotEvent, error)

type ConfigContributor

type ConfigContributor struct {
	Configs map[string]json.RawMessage
}

func (ConfigContributor) ContributeSnapshot

func (c ConfigContributor) ContributeSnapshot(_ context.Context, snapshot *Snapshot) error

type DiscoveryContributor

type DiscoveryContributor struct {
	Registry DiscoverySnapshotSource
}

func (DiscoveryContributor) ContributeSnapshot

func (c DiscoveryContributor) ContributeSnapshot(_ context.Context, snapshot *Snapshot) error

type DiscoverySnapshotSource

type DiscoverySnapshotSource interface {
	Snapshot() map[string][]discovery.Instance
}

type EndpointSnapshot

type EndpointSnapshot struct {
	Address  string            `json:"address"`
	Weight   int               `json:"weight,omitempty"`
	Zone     string            `json:"zone,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

type GovernanceContributor

type GovernanceContributor struct {
	Rules GovernanceRuleSource
}

func (GovernanceContributor) ContributeSnapshot

func (c GovernanceContributor) ContributeSnapshot(_ context.Context, snapshot *Snapshot) error

type GovernanceRuleSource

type GovernanceRuleSource interface {
	Snapshot() []governance.Rule
}

type MetadataContributor

type MetadataContributor struct {
	Metadata map[string]string
}

func (MetadataContributor) ContributeSnapshot

func (c MetadataContributor) ContributeSnapshot(_ context.Context, snapshot *Snapshot) error

type Provider

type Provider interface {
	Load(context.Context) (Snapshot, error)
	Watch(context.Context) (<-chan SnapshotEvent, error)
}

type ProviderSource

type ProviderSource interface {
	Source() string
}

type ServiceSnapshot

type ServiceSnapshot struct {
	Name      string             `json:"name"`
	Endpoints []EndpointSnapshot `json:"endpoints,omitempty"`
	Metadata  map[string]string  `json:"metadata,omitempty"`
}

type Snapshot

type Snapshot struct {
	Version   string                     `json:"version,omitempty"`
	Checksum  string                     `json:"checksum,omitempty"`
	Services  []ServiceSnapshot          `json:"services,omitempty"`
	Configs   map[string]json.RawMessage `json:"configs,omitempty"`
	Policies  []governance.Rule          `json:"policies,omitempty"`
	UpdatedAt time.Time                  `json:"updatedAt,omitempty"`
	Metadata  map[string]string          `json:"metadata,omitempty"`
}

func DecodeSnapshotJSON

func DecodeSnapshotJSON(data []byte) (Snapshot, error)

func (Snapshot) StableChecksum

func (s Snapshot) StableChecksum() string

func (Snapshot) WithChecksum

func (s Snapshot) WithChecksum() Snapshot

type SnapshotConsumerAction

type SnapshotConsumerAction struct {
	ChangeType            string   `json:"changeType"`
	Action                string   `json:"action"`
	Reason                string   `json:"reason"`
	Scopes                []string `json:"scopes,omitempty"`
	RequiresFullReconcile bool     `json:"requiresFullReconcile"`
	NextActions           []string `json:"nextActions,omitempty"`
}

func ConsumerActionForDiff

func ConsumerActionForDiff(diff SnapshotDiff) SnapshotConsumerAction

func DefaultConsumerActions

func DefaultConsumerActions() []SnapshotConsumerAction

type SnapshotConsumerDispatch

type SnapshotConsumerDispatch struct {
	ChangeType            string   `json:"changeType"`
	Action                string   `json:"action"`
	Invoked               []string `json:"invoked,omitempty"`
	Skipped               bool     `json:"skipped"`
	RequiresFullReconcile bool     `json:"requiresFullReconcile"`
}

func DispatchSnapshotConsumerAction

func DispatchSnapshotConsumerAction(ctx context.Context, action SnapshotConsumerAction, snapshot Snapshot, hooks SnapshotConsumerHooks) (SnapshotConsumerDispatch, error)

func DispatchSnapshotDiff

func DispatchSnapshotDiff(ctx context.Context, diff SnapshotDiff, snapshot Snapshot, hooks SnapshotConsumerHooks) (SnapshotConsumerDispatch, error)

type SnapshotConsumerHooks

type SnapshotConsumerHooks struct {
	LoadBaseline           SnapshotConsumerHook
	InspectSnapshot        SnapshotConsumerHook
	RefreshConfigPlanner   SnapshotConsumerHook
	RefreshRoutingModel    SnapshotConsumerHook
	ReloadGovernanceGates  SnapshotConsumerHook
	RefreshCapabilityCache SnapshotConsumerHook
	FullReconcile          SnapshotConsumerHook
}

type SnapshotContributor

type SnapshotContributor interface {
	ContributeSnapshot(context.Context, *Snapshot) error
}

type SnapshotContributorFunc

type SnapshotContributorFunc func(context.Context, *Snapshot) error

func (SnapshotContributorFunc) ContributeSnapshot

func (f SnapshotContributorFunc) ContributeSnapshot(ctx context.Context, snapshot *Snapshot) error

type SnapshotDiff

type SnapshotDiff struct {
	FromChecksum  string   `json:"fromChecksum,omitempty"`
	ToChecksum    string   `json:"toChecksum,omitempty"`
	Changed       bool     `json:"changed"`
	ChangeType    string   `json:"changeType"`
	ChangedFields []string `json:"changedFields,omitempty"`
}

func DiffSnapshotChecksum

func DiffSnapshotChecksum(fromChecksum string, to Snapshot) SnapshotDiff

func DiffSnapshots

func DiffSnapshots(from, to Snapshot) SnapshotDiff

type SnapshotEvent

type SnapshotEvent struct {
	Snapshot Snapshot `json:"snapshot,omitempty"`
	Source   string   `json:"source,omitempty"`
	Error    string   `json:"error,omitempty"`
}

type StaticProvider

type StaticProvider struct {
	Snapshot Snapshot
	Name     string
}

func (StaticProvider) Load

func (p StaticProvider) Load(ctx context.Context) (Snapshot, error)

func (StaticProvider) Source

func (p StaticProvider) Source() string

func (StaticProvider) Watch

func (p StaticProvider) Watch(ctx context.Context) (<-chan SnapshotEvent, error)

Jump to

Keyboard shortcuts

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