client

package
v0.0.0-...-4ad104f Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2018 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BuffSizeReader = 64 * 1024 //64K

	ReadTimeout = 5 * time.Second
)
View Source
const (
	SelectTypeRandom selectType = iota
	SelectTypeWeightedRandom
	SelectTypeRoundRobin
	SelectTypeSpecified
)

Variables

View Source
var ErrBeClosed = errors.New("connection closed by peer")
View Source
var ErrNetClosing = errors.New("use of closed network connection")
View Source
var ErrShutdown = errors.New("shut down")

Functions

func WithIndex

func WithIndex(index int) fnOptionService

func WithSelectType

func WithSelectType(styp selectType) fnOptionService

func WithVersion

func WithVersion(version string) fnOptionService

func WithVersionAll

func WithVersionAll() fnOptionService

Types

type Args

type Args struct {
	A, B int
}

type Call

type Call struct {
	ServiceMethod string      // The name of the service and method to call.
	Args          interface{} // The argument to the function (*struct).
	Reply         interface{} // The reply from the function (*struct).
	Error         error       // After completion, the error status.
	Done          chan *Call  // Strobes when call is complete.

	Seq uint16
	// contains filtered or unexported fields
}

Call represents an active RPC.

type Client

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

func New

func New(regConfig interface{}) *Client

func (*Client) Service

func (c *Client) Service(service, group string, opts ...fnOptionService) *SvcClient

type FnCallback

type FnCallback func(a interface{}, r interface{}, e error)

type RPCClient

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

func (*RPCClient) Call

func (rc *RPCClient) Call(ctx context.Context, serviceMethod string, args interface{}, reply interface{}) error

同步阻塞调用

func (*RPCClient) Close

func (rc *RPCClient) Close() error

func (*RPCClient) Go

func (rc *RPCClient) Go(ctx context.Context, serviceMethod string, args interface{}, reply interface{}, fn FnCallback)

异步非阻塞调用

type SvcClient

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

func (*SvcClient) Call

func (sc *SvcClient) Call(serviceMethod string, args interface{}, reply interface{}) error

func (*SvcClient) OnNodeChange

func (sc *SvcClient) OnNodeChange(key string, node *registry.Node)

func (*SvcClient) OnServiceChange

func (sc *SvcClient) OnServiceChange(adds map[string]*registry.Node, dels []string)

func (*SvcClient) Subscribe

func (sc *SvcClient) Subscribe() error

Jump to

Keyboard shortcuts

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