discovery

package
v2.0.0-...-be496b8 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package discovery provides the interface to discover other groupcache nodes in the cluster

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyInitialized is used when attempting to re-initialize the discovery provider
	ErrAlreadyInitialized = errors.New("provider already initialized")
	// ErrNotInitialized is used when the provider is not initialized
	ErrNotInitialized = errors.New("provider not initialized")
	// ErrAlreadyRegistered is used when attempting to re-register the provider
	ErrAlreadyRegistered = errors.New("provider already registered")
	// ErrNotRegistered is used when attempting to de-register the provider
	ErrNotRegistered = errors.New("provider is not registered")
)

Functions

This section is empty.

Types

type Discovery

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

Discovery defines the cluster service discovery

func New

func New(provider Provider, options Options) *Discovery

New creates an instance of Discovery

func (Discovery) Options

func (s Discovery) Options() Options

Options returns the service discovery options

func (Discovery) Provider

func (s Discovery) Provider() Provider

Provider returns the service discovery provider

type Event

type Event interface {
	IsEvent()
}

Event contract

type Node

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

Node defines the discovered node

func NewNode

func NewNode(name, host string, port int32) *Node

NewNode creates an instance of Node

func Self

func Self() (*Node, error)

Self returns the Node where the discovery provider is running

func (Node) Address

func (x Node) Address() string

Address returns the Node address

func (Node) Host

func (x Node) Host() string

Host returns the peer host

func (Node) Name

func (x Node) Name() string

Name returns the Node name

func (Node) PeerURL

func (x Node) PeerURL() string

PeerURL returns the PeerURL

func (Node) Port

func (x Node) Port() int32

Port returns the Node port number

type NodeAdded

type NodeAdded struct {
	// Node specifies the added node
	Node *Node
}

NodeAdded discovery lifecycle event

func (NodeAdded) IsEvent

func (e NodeAdded) IsEvent()

type NodeModified

type NodeModified struct {
	// Node specifies the modified node
	Node *Node
	// Current specifies the existing nde
	Current *Node
}

NodeModified discovery lifecycle event

func (NodeModified) IsEvent

func (e NodeModified) IsEvent()

type NodeRemoved

type NodeRemoved struct {
	// Node specifies the removed node
	Node *Node
}

NodeRemoved discovery lifecycle event

func (NodeRemoved) IsEvent

func (e NodeRemoved) IsEvent()

type Options

type Options map[string]any

Options represents the meta information to pass to the discovery engine

func NewOptions

func NewOptions() Options

NewOptions initializes meta

func (Options) GetBool

func (m Options) GetBool(key string) (*bool, error)

GetBool returns the int value of a given key which value is a boolean If the key value is not a boolean then an error is return

func (Options) GetInt

func (m Options) GetInt(key string) (int, error)

GetInt returns the int value of a given key which value is an integer If the key value is not an integer then an error is return

func (Options) GetMapString

func (m Options) GetMapString(key string) (map[string]string, error)

GetMapString returns the map of string value of a given key which value is a map of string Map of string means that the map key value pair are both string

func (Options) GetString

func (m Options) GetString(key string) (string, error)

GetString returns the string value of a given key which value is a string If the key value is not a string then an error is return

type Provider

type Provider interface {
	// ID returns the service discovery provider name
	ID() string
	// Initialize initializes the service discovery provider.
	Initialize() error
	// Register registers the service discovery provider.
	Register() error
	// Deregister de-registers the service discovery provider.
	Deregister() error
	// SetConfig registers the underlying discovery options
	SetConfig(config Options) error
	// DiscoverNodes returns a list discovered nodes
	DiscoverNodes() ([]*Node, error)
	// Watch returns event based upon node lifecycle
	Watch(ctx context.Context) (<-chan Event, error)
	// Close closes the provider
	Close() error
}

Provider helps discover other nodes in a cloud environment

Directories

Path Synopsis
Package kubernetes defines the kubernetes discovery provider
Package kubernetes defines the kubernetes discovery provider
Package mdns defines the mdns discovery provider
Package mdns defines the mdns discovery provider

Jump to

Keyboard shortcuts

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