client

package
v0.0.0-...-e215c4f Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WriteTimeout = 10 * time.Second

	ReadTimeout = 31 * time.Second

	HeartbeatInterval = 9 * time.Second

	ReadTimeoutShort  = 20 * time.Second  // For requests that read/write several key-values.
	ReadTimeoutMedium = 60 * time.Second  // For requests that may need scan region.
	ReadTimeoutLong   = 150 * time.Second // For requests that may need scan region multiple times.
)
View Source
const (
	DefaultIdleTimeout = 1200 * time.Second
	// 128 KB
	DefaultInitialWindowSize int32 = 1024 * 64
	DefaultPoolSize          int   = 1

	// 40 KB
	DefaultWriteSize = 40960
	// 40 KB
	DefaultReadSize = 40960
)
View Source
const (
	LINK_INIT = iota
	LINK_CONN
	LINK_CLOSED
	LINK_BAN_CONN
)
View Source
const DefLog = 1
View Source
const (
	TempSendQueueLen = 20
)

Variables

View Source
var (
	ErrClientClosed    = errors.New("client closed")
	ErrClientBusy      = errors.New("client is busy")
	ErrRequestTimeout  = errors.New("request timeout")
	ErrConnIdleTimeout = errors.New("conn idle timeout")
	ErrInvalidMessage  = errors.New("invalid message")
	ErrConnUnavailable = errors.New("the connection is unavailable")
	ErrConnClosing     = errors.New("the connection is closing")
	ErrNetworkIO       = errors.New("failed with network I/O error")
)

Functions

func NewRpcError

func NewRpcError(err error) error

Types

type AdminClient

type AdminClient interface {
	// Close should release all data.
	Close() error

	// SetConfig set config
	SetConfig(addr string, configs []*dspb.ConfigItem) error
}

AdminClient admin client

func NewAdminClient

func NewAdminClient(token string, poolSize int) AdminClient

NewAdminClient new admin client

type ConnTimeout

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

func DialTimeout

func DialTimeout(addr string, timeout time.Duration) (*ConnTimeout, error)

func NewConnTimeout

func NewConnTimeout(conn net.Conn) *ConnTimeout

func (*ConnTimeout) Close

func (c *ConnTimeout) Close() error

func (*ConnTimeout) Read

func (c *ConnTimeout) Read(p []byte) (n int, err error)

func (*ConnTimeout) RemoteAddr

func (c *ConnTimeout) RemoteAddr() string

func (*ConnTimeout) SetReadTimeout

func (c *ConnTimeout) SetReadTimeout(timeout time.Duration)

func (*ConnTimeout) SetWriteTimeout

func (c *ConnTimeout) SetWriteTimeout(timeout time.Duration)

func (*ConnTimeout) Write

func (c *ConnTimeout) Write(p []byte) (n int, err error)

type DSRpcClient

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

func NewDSRpcClient

func NewDSRpcClient(addr string, dialFunc DialFunc) *DSRpcClient

func (*DSRpcClient) Admin

func (*DSRpcClient) Close

func (c *DSRpcClient) Close()

func (*DSRpcClient) GetClientId

func (c *DSRpcClient) GetClientId() int64

func (*DSRpcClient) IsAlive

func (*DSRpcClient) NodeInfo

func (*DSRpcClient) Send

func (c *DSRpcClient) Send(ctx context.Context, msg *Message) ([]byte, error)

type DialFunc

type DialFunc func(addr string) (*ConnTimeout, error)

type List

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

func NewList

func NewList() *List

func (*List) AddElement

func (l *List) AddElement(m *Message) error

func (*List) Cleanup

func (l *List) Cleanup(err error)

func (*List) DelElement

func (l *List) DelElement(id uint64) (*Message, bool)

func (*List) FindElement

func (l *List) FindElement(id uint64) (*Message, bool)

func (*List) Size

func (l *List) Size() int

type Message

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

func (*Message) Back

func (m *Message) Back(err error)

func (*Message) GetData

func (m *Message) GetData() []byte

func (*Message) GetFlags

func (m *Message) GetFlags() uint8

func (*Message) GetFuncId

func (m *Message) GetFuncId() uint16

func (*Message) GetMsgId

func (m *Message) GetMsgId() uint64

func (*Message) GetMsgType

func (m *Message) GetMsgType() uint16

func (*Message) GetProtoType

func (m *Message) GetProtoType() uint8

func (*Message) GetTimeout

func (m *Message) GetTimeout() uint32

func (*Message) SetData

func (m *Message) SetData(data []byte)

func (*Message) SetFlags

func (m *Message) SetFlags(flags uint8)

func (*Message) SetFuncId

func (m *Message) SetFuncId(funcId uint16)

func (*Message) SetMsgId

func (m *Message) SetMsgId(msgId uint64)

func (*Message) SetMsgType

func (m *Message) SetMsgType(msgType uint16)

func (*Message) SetProtoType

func (m *Message) SetProtoType(protoType uint8)

func (*Message) SetTimeout

func (m *Message) SetTimeout(timeout uint32)

type MsgTypeGroup

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

func (*MsgTypeGroup) GetRequestMsgType

func (m *MsgTypeGroup) GetRequestMsgType() uint16

func (*MsgTypeGroup) GetResponseMsgType

func (m *MsgTypeGroup) GetResponseMsgType() uint16

type Pool

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

func NewPool

func NewPool(size int, addr string, fun createConnFunc) (*Pool, error)

func (*Pool) Close

func (p *Pool) Close()

func (*Pool) GetConn

func (p *Pool) GetConn() RpcClient

type ResourcePool

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

func NewResourcePool

func NewResourcePool(size int) *ResourcePool

func (*ResourcePool) Close

func (rp *ResourcePool) Close()

func (*ResourcePool) GetConn

func (rp *ResourcePool) GetConn(addr string) (RpcClient, error)

type RpcError

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

func (*RpcError) Error

func (re *RpcError) Error() string

type SchClient

type SchClient interface {
	// Close should release all data.
	Close() error
	// SendKVReq sends kv request.
	CreateRange(ctx context.Context, addr string, r *basepb.Range) error
	DeleteRange(ctx context.Context, addr string, rangeId uint64, peerID uint64) error
	ChangeMember(ctx context.Context, addr string, r *dspb.ChangeRaftMemberRequest) error
	TransferLeader(ctx context.Context, addr string, rangeId uint64) error
	GetPeerInfo(addr string, rangeId uint64) (*dspb.GetPeerInfoResponse, error)
	IsAlive(ctx context.Context, addr string) bool
	NodeInfo(ctx context.Context, addr string) (*dspb.NodeInfoResponse, error)
}

Client is a client that sends RPC. It should not be used after calling Close().

func NewSchRPCClient

func NewSchRPCClient(size int) SchClient

type SchRpcClient

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

func (*SchRpcClient) ChangeMember

func (c *SchRpcClient) ChangeMember(ctx context.Context, addr string, r *dspb.ChangeRaftMemberRequest) (err error)

func (*SchRpcClient) Close

func (c *SchRpcClient) Close() error

func (*SchRpcClient) CreateRange

func (c *SchRpcClient) CreateRange(ctx context.Context, addr string, r *basepb.Range) (err error)

func (*SchRpcClient) DeleteRange

func (c *SchRpcClient) DeleteRange(ctx context.Context, addr string, rangeId uint64, peerID uint64) (err error)

func (*SchRpcClient) GetPeerInfo

func (c *SchRpcClient) GetPeerInfo(addr string, rangeId uint64) (*dspb.GetPeerInfoResponse, error)

func (*SchRpcClient) IsAlive

func (c *SchRpcClient) IsAlive(ctx context.Context, addr string) bool

func (*SchRpcClient) NodeInfo

func (c *SchRpcClient) NodeInfo(ctx context.Context, addr string) (*dspb.NodeInfoResponse, error)

func (*SchRpcClient) TransferLeader

func (c *SchRpcClient) TransferLeader(ctx context.Context, addr string, rangeId uint64) (err error)

type WaitList

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

func NewWaitList

func NewWaitList(size int) *WaitList

func (*WaitList) AddElement

func (wl *WaitList) AddElement(m *Message) error

func (*WaitList) Cleanup

func (wl *WaitList) Cleanup(err error)

func (*WaitList) DelElement

func (wl *WaitList) DelElement(id uint64) (*Message, bool)

func (*WaitList) ElemSize

func (wl *WaitList) ElemSize() int

func (*WaitList) FindElement

func (wl *WaitList) FindElement(id uint64) (*Message, bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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