Documentation
¶
Overview ¶
Package localinstances owns the OrderedLog op type that publishes the per-node container-IP -> (service, namespace) identity table the agent uses to attribute incoming connections to a managed service for policy enforcement.
Records are keyed by node ID. Each Update op replaces the entire table for that node (last-writer-wins), which is the same shape as endpoints.Publisher: the orchestrator owns the source-of-truth per-node and republishes whenever an instance starts or stops on that node.
Key prefix: "local_instances/<nodeID>" — protected by the seam-leakage lint in scripts/check_orderedlog_seam.sh.
Index ¶
Constants ¶
const ( OpUpdateLocalInstances = "local_instances.update" OpDeleteLocalInstances = "local_instances.delete" )
Reserved op type strings.
Variables ¶
var ErrNodeIDRequired = errors.New("localinstances: node ID required")
ErrNodeIDRequired is returned when an op is constructed with an empty node ID.
Functions ¶
func DecodePayload ¶
func DecodePayload(m orderedlog.Mutation) (types.LocalInstances, error)
DecodePayload unmarshals an Update mutation payload into a LocalInstances. Returns an error for delete mutations or non- local_instances mutations.
func IsLocalInstancesMutation ¶
func IsLocalInstancesMutation(m orderedlog.Mutation) bool
IsLocalInstancesMutation reports whether m was produced by this package. Used by consumers to filter the watch stream cheaply.
func Register ¶
func Register(olog orderedlog.OrderedLog) error
Register installs the local_instances op types + appliers on olog. Tolerates orderedlog.ErrAlreadyRegistered so multiple consumers in the same process can call it.
Types ¶
type Publisher ¶
type Publisher interface {
// Update replaces the table for nodeID. An empty map is allowed
// and means "this node hosts no instances right now".
Update(ctx context.Context, nodeID string, instances map[string]types.InstanceIdentity) error
// Delete removes the table for nodeID. Idempotent.
Delete(ctx context.Context, nodeID string) error
}
Publisher is the producer API. The orchestrator instance controller calls Update whenever the local-instance table for a node changes (instance Started or Stopped on that node). Implementations must be safe for concurrent use; the default OrderedLog-backed implementation is.
func NewPublisher ¶
func NewPublisher(olog orderedlog.OrderedLog) Publisher
NewPublisher returns a Publisher that writes through olog.Propose. Register must have been called on the same olog beforehand.