registry

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: BSD-2-Clause Imports: 3 Imported by: 1 module, 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

Overview

Package registry tracks the workers a runner knows about, its own and those belonging to other runners, so a worker can find another by name and be told when one it is waiting for becomes ready.

A runner owns one registry and shares it with its workers. Workers are kept under the runner they belong to, so a local one is told apart from a remote one, and each name is registered at most once.

Experimental: this package may still change in a minor release.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WatchHandler

type WatchHandler func(ctx context.Context, data WorkerReadyData)

WatchHandler is called with a worker's data when that worker registers.

type WorkerErrorData

type WorkerErrorData struct {
	// WorkerName is the name of the worker that failed.
	WorkerName string
	// Error describes the failure.
	Error string
}

WorkerErrorData describes a worker that failed.

type WorkerReadyData

type WorkerReadyData struct {
	// WorkerName is the worker's name.
	WorkerName string
	// Runner is the name of the runner managing it.
	Runner string
}

WorkerReadyData is what a worker reports about itself when it becomes ready.

type WorkerRegistry

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

WorkerRegistry tracks the workers known to one runner.

It is safe for concurrent use.

func New

func New(runnerName string) *WorkerRegistry

New builds a registry owned by the named runner.

func (*WorkerRegistry) Contains

func (r *WorkerRegistry) Contains(workerName string) bool

Contains reports whether a worker of that name is registered.

func (*WorkerRegistry) Get

func (r *WorkerRegistry) Get(workerName string) (WorkerReadyData, bool)

Get looks a worker up by name, reporting whether it is registered at all.

func (*WorkerRegistry) LocalWorkers

func (r *WorkerRegistry) LocalWorkers() []string

LocalWorkers are the names of the workers registered under this runner.

func (*WorkerRegistry) Register

func (r *WorkerRegistry) Register(ctx context.Context, data WorkerReadyData) bool

Register records a worker and tells whoever was watching for it. It reports whether the worker was new; registering one already known changes nothing.

func (*WorkerRegistry) RemoteWorkers

func (r *WorkerRegistry) RemoteWorkers() []string

RemoteWorkers are the names of the workers registered under other runners.

func (*WorkerRegistry) RunnerName

func (r *WorkerRegistry) RunnerName() string

RunnerName is the name of the runner that owns this registry.

func (*WorkerRegistry) Watch

func (r *WorkerRegistry) Watch(ctx context.Context, workerName, key string, handler WatchHandler)

Watch asks to be told when the named worker registers, and calls handler straight away when it already has.

key identifies the watcher, so watching the same worker twice from the same place is a no-op rather than firing the handler twice. Upstream compares the handler functions themselves; Go cannot, so the caller names the interest instead. It matters because a parent can reach the same watch by two routes, adding a child worker and declaring a ready handler for it by name.

type WorkerRegistryEntry

type WorkerRegistryEntry struct {
	// Name is the worker's name.
	Name string
	// Parent is the name of the worker's parent, empty for a root worker.
	Parent string
	// Active reports whether the worker is currently active.
	Active bool
	// Bridged reports whether the worker is bridged.
	Bridged bool
	// StartedAt is when the worker became ready, as a Unix timestamp, and zero
	// when it has not.
	StartedAt float64
}

WorkerRegistryEntry is one worker in a snapshot of the registry.

Jump to

Keyboard shortcuts

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