Help us shape the future of Go! Take the 2026 Go Developer Survey

registration

package
v0.57.21 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SelectLocked

func SelectLocked[T comparable, K comparable](r *Registry, members map[uint32]T, instanceKey string, name func(T) K) []T

SelectLocked selects visible registrations by semantic name for one logical installation. Scoped definitions override global defaults; the latest ID wins within one priority. Callers hold Broadcast and clone mutable wire results.

Types

type Generation

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

Generation retains one plugin executable's private or admitted registrations. Its state is protected by the Registry broadcast lock.

func FromContext

func FromContext(ctx context.Context, pluginID string) (*Generation, error)

FromContext returns the private registration scope, or nil for ordinary registrations. A named plugin must match the scope's family.

func (*Generation) Activate

Activate publishes the whole generation in one critical section. Retrying the active generation succeeds; a retired or closed generation cannot supersede it.

func (*Generation) Close

func (g *Generation) Close()

Close hides this generation. During handover, a failed candidate restores the still-retained previous worker; once that worker retires it cannot reappear.

func (*Generation) InvokeMethod

func (g *Generation) InvokeMethod(serviceID, methodID string, strm srpc.Stream) (bool, error)

InvokeMethod binds registration calls to this private generation. Other root services are deliberately absent from a registration scope.

func (*Generation) ManifestRoot

func (g *Generation) ManifestRoot() string

ManifestRoot returns the exact implementation registered by this generation.

type Registry

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

Registry owns admission of plugin generations across the Resource registries. Participating registries use Broadcast for their records and visibility reads, so activation and a registry snapshot share one critical section.

func NewRegistry

func NewRegistry() *Registry

NewRegistry constructs an independent registration admission boundary.

func (*Registry) BindLocked

func (r *Registry) BindLocked(member any, generation *Generation) error

BindLocked associates a comparable registration pointer with its generation. A nil generation is a normal immediately visible registration. The caller holds Broadcast and must forget the member when its Resource is released.

func (*Registry) Broadcast

func (r *Registry) Broadcast() *broadcast.Broadcast

Broadcast returns the lock shared by generation admission and registry records.

func (*Registry) CanShareNameLocked

func (r *Registry) CanShareNameLocked(member any, candidate *Generation) bool

CanShareNameLocked permits independent installation scopes and private replacement candidates of the same family. It rejects duplicates within one generation and competing families within one scope. The caller holds Broadcast.

func (*Registry) ForgetLocked

func (r *Registry) ForgetLocked(member any)

ForgetLocked removes a released registration's generation association. The caller holds Broadcast.

func (*Registry) GenerationLocked

func (r *Registry) GenerationLocked(member any) *Generation

GenerationLocked returns a registration's group, or nil for an ungrouped registration. The caller holds Broadcast.

func (*Registry) InstanceKeyLocked

func (r *Registry) InstanceKeyLocked(member any) string

InstanceKeyLocked returns the plugin instance that serves a registration, empty for a global registration. A scoped registration's plugin runs in its installation, so loads of its handler carry this key. The caller holds Broadcast.

func (*Registry) OnChange

func (r *Registry) OnChange(changed func())

OnChange adds a notification called under Broadcast when visibility changes. Install notifications during construction, before serving any requests.

func (*Registry) Register

func (r *Registry) Register(root srpc.Mux) error

Register installs preparation on root. Private scopes forward the existing registry services to root with their generation bound to the call context.

Jump to

Keyboard shortcuts

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