rpc

package
v0.0.0-...-eb64f0e Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRPCNotAvailable represents rpc service not available.
	ErrRPCNotAvailable = errors.New("rpc service not available")

	// ErrRPCTimeout represents rpc server timer out.
	ErrRPCTimeout = errors.New("rpc dial timeout")
)
View Source
var (
	// ErrRPCNoClientAvailable represents no client left in collection.
	ErrRPCNoClientAvailable = errors.New("no rpc client available now")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	*rpc.Client
	// contains filtered or unexported fields
}

Client represents rpc client

func Dial

func Dial(opt Options) *Client

Dial dial to rpc server.

func (*Client) Call

func (c *Client) Call(serviceMethod string, args interface{}, reply interface{}) error

Call invoke the remote method by name, wait for the reply.

func (*Client) Close

func (c *Client) Close()

Close shutdown the rpc client.

func (*Client) Error

func (c *Client) Error() error

Error return error of the rpc client.

func (*Client) Ping

func (c *Client) Ping(ping string)

Ping ping the rpc server or reconnect when has an error.

type Clients

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

Clients represents rpc client collections.

func Dials

func Dials(opts []Options) *Clients

Dials dial to rpc servers.

func (*Clients) Call

func (cs *Clients) Call(serviceMethod string, args interface{}, reply interface{}) error

Call invokes the named function, waits for it to complete, and returns its error status.

func (*Clients) Get

func (cs *Clients) Get(addr string) (*Client, error)

Get get a usable rpc client based on specified addr.

func (*Clients) IsAvailable

func (cs *Clients) IsAvailable() bool

IsAvailable checks if exists a available client.

func (*Clients) Ping

func (cs *Clients) Ping(ping string)

Ping ping the rpc connect and reconnect when has an error.

type KeepAlive

type KeepAlive interface {
	Ping(req *ReqKeepAlive, resp *RespKeepAlive) error
}

KeepAlive is general rpc ping interface.

type Options

type Options struct {
	Proto string
	Addr  string
}

Options represents rpc client options.

type ReqKeepAlive

type ReqKeepAlive struct{}

ReqKeepAlive represents keepAlive request.

type RespKeepAlive

type RespKeepAlive struct{}

RespKeepAlive represents keepAlive response.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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