clientselector

package
v0.0.0-...-8216691 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2016 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(key uint64, buckets int32) int32

Hash consistently chooses a hash bucket number in the range [0, numBuckets) for the given key. numBuckets must be >= 1.

func HashString

func HashString(s string) uint64

HashString get a hash value of a string

func JumpConsistentHash

func JumpConsistentHash(len int, options ...interface{}) int

JumpConsistentHash selects a server by serviceMethod and args

Types

type ConsulClientSelector

type ConsulClientSelector struct {
	ConsulAddress string

	Servers     []*api.AgentService
	ServiceName string
	SelectMode  rpcx.SelectMode

	HashServiceAndArgs HashServiceAndArgs
	Client             *rpcx.Client
	// contains filtered or unexported fields
}

ConsulClientSelector is used to select a rpc server from consul. This registry is experimental and has not been test.

func NewConsulClientSelector

func NewConsulClientSelector(consulAddress string, serviceName string, sessionTimeout time.Duration, sm rpcx.SelectMode, timeout time.Duration) *ConsulClientSelector

NewConsulClientSelector creates a ConsulClientSelector

func (*ConsulClientSelector) Select

func (s *ConsulClientSelector) Select(clientCodecFunc rpcx.ClientCodecFunc, options ...interface{}) (*rpc.Client, error)

Select returns a rpc client

func (*ConsulClientSelector) SetClient

func (s *ConsulClientSelector) SetClient(c *rpcx.Client)

type EtcdClientSelector

type EtcdClientSelector struct {
	EtcdServers []string
	KeysAPI     client.KeysAPI

	BasePath   string //should endwith serviceName
	Servers    []string
	SelectMode rpcx.SelectMode

	HashServiceAndArgs HashServiceAndArgs
	Client             *rpcx.Client
	// contains filtered or unexported fields
}

EtcdClientSelector is used to select a rpc server from etcd.

func NewEtcdClientSelector

func NewEtcdClientSelector(etcdServers []string, basePath string, sessionTimeout time.Duration, sm rpcx.SelectMode, timeout time.Duration) *EtcdClientSelector

NewEtcdClientSelector creates a EtcdClientSelector

func (*EtcdClientSelector) Select

func (s *EtcdClientSelector) Select(clientCodecFunc rpcx.ClientCodecFunc, options ...interface{}) (*rpc.Client, error)

Select returns a rpc client

func (*EtcdClientSelector) SetClient

func (s *EtcdClientSelector) SetClient(c *rpcx.Client)

type HashServiceAndArgs

type HashServiceAndArgs func(len int, options ...interface{}) int

HashServiceAndArgs define a hash function

type MultiClientSelector

type MultiClientSelector struct {
	Servers    []ServerPair
	SelectMode rpcx.SelectMode

	HashServiceAndArgs HashServiceAndArgs
	Client             *rpcx.Client
	// contains filtered or unexported fields
}

MultiClientSelector is used to select a direct rpc server from a list.

func NewMultiClientSelector

func NewMultiClientSelector(servers []ServerPair, sm rpcx.SelectMode, timeout time.Duration) *MultiClientSelector

NewMultiClientSelector creates a MultiClientSelector

func (*MultiClientSelector) Select

func (s *MultiClientSelector) Select(clientCodecFunc rpcx.ClientCodecFunc, options ...interface{}) (*rpc.Client, error)

Select returns a rpc client

func (*MultiClientSelector) SetClient

func (s *MultiClientSelector) SetClient(c *rpcx.Client)

type ServerPair

type ServerPair struct {
	Network, Address string
}

ServerPair is

type ZooKeeperClientSelector

type ZooKeeperClientSelector struct {
	ZKServers []string

	BasePath   string //should endwith serviceName
	Servers    []string
	SelectMode rpcx.SelectMode

	HashServiceAndArgs HashServiceAndArgs
	Client             *rpcx.Client
	// contains filtered or unexported fields
}

ZooKeeperClientSelector is used to select a rpc server from zookeeper.

func NewZooKeeperClientSelector

func NewZooKeeperClientSelector(zkServers []string, basePath string, sessionTimeout time.Duration, sm rpcx.SelectMode, timeout time.Duration) *ZooKeeperClientSelector

NewZooKeeperClientSelector creates a ZooKeeperClientSelector sessionTimeout is timeout configuration for zookeeper. timeout is timeout configuration for TCP connection to RPC servers.

func (*ZooKeeperClientSelector) Select

func (s *ZooKeeperClientSelector) Select(clientCodecFunc rpcx.ClientCodecFunc, options ...interface{}) (*rpc.Client, error)

Select returns a rpc client

func (*ZooKeeperClientSelector) SetClient

func (s *ZooKeeperClientSelector) SetClient(c *rpcx.Client)

Jump to

Keyboard shortcuts

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