Help us shape the future of Go! Take the 2026 Go Developer Survey

gxfilter

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2018 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Overview

Package gxfilter provides a interface for service filter

Package gxfilter provides a interface for service filter

Package gxfilter provides a interface for service filter

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound              = jerrors.Errorf("not found")
	ErrNoneAvailable         = jerrors.Errorf("none available")
	ErrRunOutAllServiceNodes = jerrors.Errorf("has used out all provider nodes")
)

Functions

This section is empty.

Types

type Balancer

type Balancer func(ID uint64) (*gxregistry.Service, error)

Balancer returns a available node based on its load balance algorithm.

type BalancerFunc

type BalancerFunc func([]*gxregistry.Service) Balancer

func BalancerModeFunc

func BalancerModeFunc(mode BalancerMode) BalancerFunc

type BalancerMode

type BalancerMode int

BalancerMode defines the algorithm of selecting a provider from cluster

const (
	SM_BEGIN BalancerMode = iota
	SM_Random
	SM_RoundRobin
	SM_Hash
	SM_END
)

func (BalancerMode) String

func (s BalancerMode) String() string

type Filter

type Filter interface {
	Options() Options
	GetService(attr gxregistry.ServiceAttr) ([]*gxregistry.Service, error)
	Filter(attr gxregistry.ServiceAttr) (Balancer, ServiceToken, error)
	CheckTokenAlive(attr gxregistry.ServiceAttr, token ServiceToken) bool
	Close() error
}

Filter used to get service nodes from registry.

type Option

type Option func(*Options)

Option used to initialise the filter

func WithBalancerMode

func WithBalancerMode(mode BalancerMode) Option

WithBalancerMode sets the default strategy for the filter

func WithContext

func WithContext(ctx *gxcontext.ValuesContext) Option

func WithRegistry

func WithRegistry(r gxregistry.Registry) Option

WithRegistry sets the registry used by the filter

type Options

type Options struct {
	Registry gxregistry.Registry
	Mode     BalancerMode // filter mode
	Context  *gxcontext.ValuesContext
}

type ServiceToken

type ServiceToken = int64

Directories

Path Synopsis
Package gxpool provides a service pool filter Package gxpool provides a interface for service pool filter
Package gxpool provides a service pool filter Package gxpool provides a interface for service pool filter

Jump to

Keyboard shortcuts

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