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

gxfilter

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 8 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")
)
View Source
var (
	ErrServiceArrayEmpty = jerrors.New("ServiceArray empty")
)

Functions

This section is empty.

Types

type Filter

type Filter interface {
	Options() Options
	GetService(gxregistry.ServiceAttr) ([]*gxregistry.Service, error)
	Filter(gxregistry.ServiceAttr) (*ServiceArray, error)
	CheckServiceAlive(gxregistry.ServiceAttr, *ServiceArray) bool
	Close() error
}

Filter used to get service nodes from registry.

type Option

type Option func(*Options)

Option used to initialise 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
	Context  *gxcontext.ValuesContext
}

type ServiceArray added in v0.3.1

type ServiceArray struct {
	Arr    []*gxregistry.Service
	Active time.Time
	// contains filtered or unexported fields
}

func NewServiceArray added in v0.3.1

func NewServiceArray(Arr []*gxregistry.Service) *ServiceArray

func (*ServiceArray) Add added in v0.3.1

func (s *ServiceArray) Add(service *gxregistry.Service, ttl time.Duration)

func (*ServiceArray) Del added in v0.3.1

func (s *ServiceArray) Del(service *gxregistry.Service, ttl time.Duration)

func (*ServiceArray) Select added in v0.3.1

func (s *ServiceArray) Select(ctx context.Context, hash ServiceHash) (*gxregistry.Service, error)

func (ServiceArray) String added in v0.3.1

func (s ServiceArray) String() string

type ServiceHash added in v0.3.1

type ServiceHash func(context.Context, *ServiceArray) (*gxregistry.Service, error)

ServiceHash is a user service hash interface to select a service provider. @context is transfered from ServiceArray::Select

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