sections

package
v0.6.59 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package sections is discovery the product defines: a service offers a section — a proto message of the product's under a name — and any service follows that name across the installation, without a registry of its own.

sections.Offer(root, "komeet.module", &modulev1.Manifest{Name: "media", ...})

modules := sections.Follow[*modulev1.Manifest](root, "komeet.module")
for service, m := range modules.Get() { ... }

The section goes into the service's manifest. Backplane publishes, by name, the sections of every serving service (its highest serving version) to Consul KV backplane/sections/<name>; Follow watches that key while the service runs. Without Consul nothing is known.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Offer

func Offer(scope deps.Scope, name string, msg proto.Message)

Offer declares the service's section name with msg. A name is offered once per service; a msg that does not marshal is a declaration error (Run fails, Service.Validate reports it).

Types

type Live added in v0.6.45

type Live[T proto.Message] struct {
	// contains filtered or unexported fields
}

Live is a section the service offers whose value changes while it runs, e.g. with its live configuration. It is immutable and safe for concurrent use; the zero Live sets nothing.

func OfferLive added in v0.6.45

func OfferLive[T proto.Message](scope deps.Scope, name string) Live[T]

OfferLive declares the service's section name as T, with a value the service sets while it runs (Live.Set). The manifest, shared by every instance of a version, holds T's empty message; each instance publishes its value with its state, and followers see the value of the service's highest serving version, from one of its instances. Until an instance sets it, followers see the empty message.

func (Live[T]) Set added in v0.6.45

func (l Live[T]) Set(msg T) error

Set publishes msg as the section's value; setting an equal value again changes nothing.

type Ref

type Ref[T proto.Message] struct {
	// contains filtered or unexported fields
}

Ref follows one section name: the section of every serving service that offers it. Its methods are safe for concurrent use.

func Follow

func Follow[T proto.Message](scope deps.Scope, name string) Ref[T]

Follow follows section name, decoded as T (a pointer to a generated message). A service that offers name with another message is left out. It is a declaration: call it before Run (in a constructor, not in a component's goroutine); after Run it panics.

func (Ref[T]) Changes

func (r Ref[T]) Changes(ctx context.Context) <-chan struct{}

Changes signals after every change of the set until ctx ends; one pending signal at most.

func (Ref[T]) Get

func (r Ref[T]) Get() map[string]T

Get is the section of every serving service that offers it, by service; empty until known, or when none does.

func (Ref[T]) Known

func (r Ref[T]) Known() bool

Known reports whether the published set was read: false before the first read and without Consul.

Jump to

Keyboard shortcuts

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