llrpc

package module
v0.0.0-...-dcc811d Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

README

llrpc

rpc component

Documentation

Index

Constants

View Source
const MagicNumber = 0x3bef5c

Variables

View Source
var DefaultOption = &Option{
	MagicNumber:   MagicNumber,
	CodecType:     codec.GobType,
	ConnecTimeout: time.Second * 10,
}
View Source
var DefaultServer = NewServer()
View Source
var ErrShutdown = errors.New("connection is shut down")

Functions

func Accept

func Accept(lis net.Listener)

func Register

func Register(rcvr interface{}) error

Types

type Call

type Call struct {
	Seq           uint64
	ServiceMethod string      // format "<service>.<method>"
	Args          interface{} // arguments to the function
	Reply         interface{} // reply from the function
	Error         error       // if error ocurs, it will be set
	Done          chan *Call  // Strobes when call is camplete.
}

type Client

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

Client represents an RPC Client. There may be multiple outstanding Calls associated with a single Client, and a Client may be used by multiple goroutines simultaneously.

func Dial

func Dial(network, address string, opts ...*Option) (client *Client, err error)

func DialHTTP

func DialHTTP(network, address string, opts ...*Option) (*Client, error)

func NewClient

func NewClient(conn net.Conn, opt *Option) (*Client, error)

func NewHTTPClient

func NewHTTPClient(conn net.Conn, opt *Option) (*Client, error)

func XDial

func XDial(rpcAddr string, opts ...*Option) (*Client, error)

func (*Client) Call

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

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

func (*Client) Close

func (client *Client) Close() error

Close the connection

func (*Client) Go

func (client *Client) Go(ServiceMethod string, args, reply interface{}, done chan *Call) *Call

Go invokes the function asynchronously. It returns the Call structure representing the invocation.

func (*Client) IsAvailable

func (client *Client) IsAvailable() bool

IsAvailable return true if the client does work

type Option

type Option struct {
	MagicNumber   int           // MagicNumber marks this's a llrpc request
	CodecType     codec.Type    // client may choose different Codec to encode body
	ConnecTimeout time.Duration // 0 means no limit
	HandleTimeout time.Duration
}

type Server

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

func NewServer

func NewServer() *Server

func (*Server) Accept

func (s *Server) Accept(lis net.Listener)

func (*Server) HandleHTTP

func (s *Server) HandleHTTP()

func (*Server) Register

func (s *Server) Register(rcvr interface{}) error

func (*Server) ServeConn

func (s *Server) ServeConn(conn io.ReadWriteCloser)

func (*Server) ServerHTTP

func (s *Server) ServerHTTP(w http.ResponseWriter, req *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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