registry

package
v5.0.0-...-3a36e7d Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextKey registryKey = iota
	ContextSOTWKey
)
View Source
const (
	MetaStatusKey             = "status"
	StatusStopped      Status = "stopped"
	StatusStarting     Status = "starting"
	StatusReady        Status = "ready"
	StatusError        Status = "error"
	StatusStopping     Status = "stopping"
	StatusTransient    Status = "transient"
	StatusWaiting      Status = "waiting"
	MetaDescriptionKey        = "description"
	MetaUniqueKey             = "unique"
	MetaTimestampKey          = "timestamp"
)
View Source
const (
	ServiceMetaOverride = "service-override"
)

Variables

This section is empty.

Functions

func ItemsAs

func ItemsAs[T any](ii []Item) (converted []T)

func NewBalancer

func NewBalancer(r Registry)

Types

type AdjacentItemOption

type AdjacentItemOption func(options *AdjacentItemOptions)

func WithAdjacentEdgeItems

func WithAdjacentEdgeItems(items []Item) AdjacentItemOption

func WithAdjacentEdgeOptions

func WithAdjacentEdgeOptions(opts ...Option) AdjacentItemOption

func WithAdjacentSourceItems

func WithAdjacentSourceItems(items []Item) AdjacentItemOption

func WithAdjacentSourceOptions

func WithAdjacentSourceOptions(opts ...Option) AdjacentItemOption

func WithAdjacentTargetItems

func WithAdjacentTargetItems(items []Item) AdjacentItemOption

func WithAdjacentTargetOptions

func WithAdjacentTargetOptions(opts ...Option) AdjacentItemOption

type AdjacentItemOptions

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

type Backend

type Backend struct {
	Alive bool

	ReverseProxy *httputil.ReverseProxy
	// contains filtered or unexported fields
}

type Balancer

type Balancer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type Context

type Context interface {
	Context(context.Context)
}

type Convertible

type Convertible interface {
	As(interface{}) bool
}

type Dao

type Dao interface {
	Item

	Driver() string
	DSN() string
}

Dao stores a DAO in the registry

type Edge

type Edge interface {
	Item

	Vertices() []string
}

Edge links two vertices together

type Endpoint

type Endpoint interface {
	Item

	Handler() any
}

type FuncWrapper

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

func (*FuncWrapper) Deregister

func (m *FuncWrapper) Deregister(item Item, opts ...RegisterOption) error

func (*FuncWrapper) Register

func (m *FuncWrapper) Register(item Item, opts ...RegisterOption) error

type FuncWrapperOption

type FuncWrapperOption func(*FuncWrapperOptions)

func OnDeregister

func OnDeregister(fn func(*Item, *[]RegisterOption)) FuncWrapperOption

func OnRegister

func OnRegister(fn func(*Item, *[]RegisterOption)) FuncWrapperOption

type FuncWrapperOptions

type FuncWrapperOptions struct {
	OnRegister   []func(*Item, *[]RegisterOption)
	OnDeregister []func(*Item, *[]RegisterOption)
}

type Generic

type Generic interface {
	Item

	Type() registry.ItemType
}

Generic is the simplest Item implementation

type Item

type Item interface {
	Name() string
	ID() string
	Metadata() map[string]string
	As(interface{}) bool
}

Item is the main interface for registry items

func NewRichItem

func NewRichItem[T any](id string, name string, typ registry.ItemType, base T) Item

type MetaSetter

type MetaSetter interface {
	SetMetadata(map[string]string)
}

type MetaWrapper

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

func (*MetaWrapper) Register

func (m *MetaWrapper) Register(item Item, opts ...RegisterOption) error

type Node

type Node interface {
	Item
	Hostname() string
	IPs() []string
	AdvertiseIP() string
}

type Option

type Option func(*Options)

func WithAction

func WithAction(a pb.ActionType) Option

func WithContext

func WithContext(ctx context.Context) Option

func WithFailFast

func WithFailFast() Option

func WithFilter

func WithFilter(f func(Item) bool) Option

func WithID

func WithID(id string) Option

func WithMeta

func WithMeta(name, value string) Option

func WithName

func WithName(n string) Option

func WithType

func WithType(t pb.ItemType) Option

type Options

type Options struct {
	Context  context.Context
	FailFast bool
	Actions  []pb.ActionType
	IDs      []string
	Names    []string
	Types    []pb.ItemType
	Filters  []func(item Item) bool
}

func (*Options) ActionsMatch

func (o *Options) ActionsMatch(eventAction pb.ActionType) bool

ActionsMatch checks if an Action filter matches input

func (*Options) Matches

func (o *Options) Matches(name, itemName string) bool

type RawRegistry

type RawRegistry interface {
	Start(Item) error
	Stop(Item) error
	Register(Item, ...RegisterOption) error
	Deregister(Item, ...RegisterOption) error
	Get(string, ...Option) (Item, error)
	List(...Option) ([]Item, error)
	Watch(...Option) (Watcher, error)
	NewLocker(name string) sync.Locker

	Close() error
	Done() <-chan struct{}

	As(interface{}) bool
}

type RegisterOption

type RegisterOption func(options *RegisterOptions)

func WithContextR

func WithContextR(ctx context.Context) RegisterOption

func WithDeregisterFull

func WithDeregisterFull() RegisterOption

func WithEdgeTo

func WithEdgeTo(id, label string, meta map[string]string) RegisterOption

func WithRegisterFailFast

func WithRegisterFailFast() RegisterOption

func WithWatch

func WithWatch(wi StatusReporter) RegisterOption

type RegisterOptions

type RegisterOptions struct {
	Context        context.Context
	Edges          []registerEdge
	Watch          interface{}
	FailFast       bool
	DeregisterFull bool
}

type Registry

type Registry interface {
	RawRegistry
	RegisterEdge(item1, item2, edgeLabel string, metadata map[string]string, oo ...RegisterOption) (Edge, error)
	ListAdjacentItems(options ...AdjacentItemOption) (items []Item)
}

func GraphRegistry

func GraphRegistry(r RawRegistry) Registry

func NewCombinedRegistry

func NewCombinedRegistry(main Registry, next Registry) Registry

func NewFuncWrapper

func NewFuncWrapper(reg Registry, opt ...FuncWrapperOption) Registry

func NewMetaWrapper

func NewMetaWrapper(reg Registry, f func(map[string]string), opts ...Option) Registry

func NewTransientWrapper

func NewTransientWrapper(reg Registry, opts ...Option) Registry

func OpenRegistry

func OpenRegistry(ctx context.Context, urlstr string) (Registry, error)

OpenRegistry opens the Registry identified by the URL given. See the URLOpener documentation in driver subpackages for details on supported URL formats, and https://gocloud.dev/concepts/urls for more information.

type Result

type Result interface {
	Action() pb.ActionType
	Items() []Item
}

func NewResult

func NewResult(action pb.ActionType, items []Item) Result

type RichItem

type RichItem[T any] struct {
	UUID     string
	RichName string
	Meta     map[string]string
	Typ      registry.ItemType
	// contains filtered or unexported fields
}

func (*RichItem[T]) As

func (r *RichItem[T]) As(t any) bool

func (*RichItem[T]) ID

func (r *RichItem[T]) ID() string

func (*RichItem[T]) Metadata

func (r *RichItem[T]) Metadata() map[string]string

func (*RichItem[T]) Name

func (r *RichItem[T]) Name() string

func (*RichItem[T]) SetMetadata

func (r *RichItem[T]) SetMetadata(meta map[string]string)

func (*RichItem[T]) Type

func (r *RichItem[T]) Type() registry.ItemType

type Server

type Server interface {
	Item
	Server()
}

Server represents a running server

type Service

type Service interface {
	Item

	Version() string
	Tags() []string

	Start(oo ...RegisterOption) error
	Stop(oo ...RegisterOption) error

	ServerScheme() string
}

Service represents an instantiated service in the registry

type Status

type Status string

type StatusReporter

type StatusReporter interface {
	WatchStatus() (StatusWatcher, error)
}

type StatusWatcher

type StatusWatcher interface {
	Next() (Item, error)
	Stop()
}

type TransientWrapper

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

func (*TransientWrapper) Register

func (m *TransientWrapper) Register(item Item, opts ...RegisterOption) error

type URLMux

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

URLMux is a URL opener multiplexer. It matches the scheme of the URLs against a set of registered schemes and calls the opener that matches the URL's scheme. See https://gocloud.dev/concepts/urls/ for more information.

The zero value is a multiplexer with no registered schemes.

func DefaultURLMux

func DefaultURLMux() *URLMux

DefaultURLMux returns the URLMux used by OpenTopic and OpenSubscription.

Driver packages can use this to register their TopicURLOpener and/or SubscriptionURLOpener on the mux.

func (*URLMux) OpenRegistry

func (mux *URLMux) OpenRegistry(ctx context.Context, urlstr string) (Registry, error)

OpenRegistry calls OpenTopicURL with the URL parsed from urlstr. OpenRegistry is safe to call from multiple goroutines.

func (*URLMux) Register

func (mux *URLMux) Register(scheme string, opener URLOpener)

Register registers the opener with the given scheme. If an opener already exists for the scheme, Register panics.

func (*URLMux) Schemes

func (mux *URLMux) Schemes() []string

Schemes returns a sorted slice of the registered schemes.

func (*URLMux) ValidScheme

func (mux *URLMux) ValidScheme(scheme string) bool

ValidScheme returns true if scheme has been registered.

type URLOpener

type URLOpener interface {
	OpenURL(ctx context.Context, u *url.URL) (Registry, error)
}

URLOpener represents types than can open Registries based on a URL. The opener must not modify the URL argument. OpenURL must be safe to call from multiple goroutines.

This interface is generally implemented by types in driver packages.

type Watcher

type Watcher interface {
	Next() (Result, error)
	Stop()
}

func NewWatcher

func NewWatcher(id string, opts Options, res chan Result) Watcher

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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