ncrpc

package
v0.0.0-...-f3d8a94 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

The ncrpc package layers client-server and server-client RPC interfaces on top of netchan.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Importer *netchan.Importer
	Server   *rpc.Client
}

Client represents an ncrpc client. Importer holds the underlying netchan connection, and Server can be used to make calls to the server RPC interface.

func Import

func Import(network, addr string) (*Client, error)

Import makes a connection to an ncrpc server and calls NewClient on it.

func NewClient

func NewClient(conn io.ReadWriter) (*Client, error)

NewClient makes a netchan connection from the given connection, imports the rpc service from that, and returns both in a new Client instance. It assumes that the server has been started with Server.

func (*Client) Serve

func (c *Client) Serve(clientName string, rpcServer *rpc.Server) error

Serve announces an RPC service on the client using the given name (which must currently be unique amongst all clients).

type Server

type Server struct {
	Exporter  *netchan.Exporter
	RPCServer *rpc.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(acceptClientRPC bool) (*Server, error)

NewServer creates a new RPC-over-netchan server. It returns a new Server instance containing a netchan.Exporter and an rpc.Server which is listening on a channel within it. It reserves the use of netchan channels with the prefix "ncrpc".

If acceptClientRPC is true, the server will accept incoming client RPC registrations made by Client.Serve.

Conventionally Register is called on the rpc.Server to export some server RPC methods, and ListenAndServe is then called on the netchan.Exporter to listen on the network.

func (*Server) Client

func (srv *Server) Client(name string) (c *rpc.Client)

Client gets the RPC connection for a given client.

func (*Server) ClientNames

func (srv *Server) ClientNames() (a []string)

ClientNames returns the list of all clients that have published RPC connections to the server.

Jump to

Keyboard shortcuts

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