selector

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MulanPSL-2.0 Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balancer

type Balancer func([]*reg.Service) Next

type Filter

type Filter func([]*reg.Service) []*reg.Service

type Next

type Next func() (*reg.Node, error)

type Option

type Option func(*Options)

func Registry

func Registry(r reg.Registry) Option

type Options

type Options struct {
	Watcher  Watcher
	Registry reg.Registry
	Balancer Balancer

	Context context.Context
}

type SelectOption

type SelectOption func(*SelectOptions)

SelectOption used when making a select call

type SelectOptions

type SelectOptions struct {
	Filters  []Filter
	Balancer Balancer

	Param   []interface{}
	Context context.Context
}

type Selector

type Selector interface {
	Init(opts ...Option) error
	Options() Options
	// Select returns a function which should return the next node
	Select(service string, opts ...SelectOption) (Next, error)

	GetService(name string) ([]*reg.Service, error)

	// Mark sets the success/error against a node
	Mark(service string, node *reg.Node, err error)
	// Reset returns state back to zero for a service
	Reset(service string)
	// Close renders the selector unusable
	Close() error
	// Name of the selector
	String() string
}

type Watcher

type Watcher func(node *reg.Node)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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