registry

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceMetaOverride = "service-override"
)

Variables

This section is empty.

Functions

func NewBalancer

func NewBalancer(r Registry)

Types

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 Endpoint

type Endpoint interface {
	Name() string
	Metadata() map[string]string
}

type Item

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

type Node

type Node interface {
	Item

	Address() []string
	Endpoints() []string
}

type NodeRegistry

type NodeRegistry interface {
	RegisterNode(Node) error
	DeregisterNode(Node) error
	GetNode(string) (Node, error)
	ListNodes() ([]Node, error)
	As(interface{}) bool
}

type Option

type Option func(*Options) error

func WithFilter

func WithFilter(f func(Item) bool) 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
	Name    string
	Type    pb.ItemType
	Filter  func(item Item) bool
}

type Registry

type Registry interface {
	Start(Item) error
	Stop(Item) error
	Register(Item) error
	Deregister(Item) error
	Get(string, ...Option) (Item, error)
	List(...Option) ([]Item, error)
	Watch(...Option) (Watcher, error)

	As(interface{}) bool
}

func NewRegistry

func NewRegistry(r Registry) 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() string
	Item() Item
}

type Service

type Service interface {
	Item

	Version() string
	Nodes() []Node
	Tags() []string
	Metadata() map[string]string

	Start() error
	Stop() error

	IsGeneric() bool
	IsGRPC() bool
	IsREST() bool
}

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)

OpenTopic calls OpenTopicURL with the URL parsed from urlstr. OpenTopic 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()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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