localrpc

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Local RPC package.

This is a simple RPC package that uses a line-oriented protocol for encoding and decoding, and Unix sockets for transport. It is meant to be used for lightweight occasional communication between processes on the same machine.

Index

Constants

This section is empty.

Variables

View Source
var DefaultServer = NewServer()

Default server. This is a singleton server that can be used for convenience.

Functions

This section is empty.

Types

type Client

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

Client for the localrpc server.

func NewClient

func NewClient(path string) *Client

NewClient creates a new client for the given path.

func (*Client) Call

func (c *Client) Call(name string, args ...string) (url.Values, error)

Call the given method. The arguments are key-value strings, and must be provided in pairs.

func (*Client) CallWithValues

func (c *Client) CallWithValues(name string, input url.Values) (url.Values, error)

CallWithValues calls the given method.

type Handler

type Handler func(tr *trace.Trace, input url.Values) (url.Values, error)

Handler is the type of RPC request handlers.

type Server

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

Server represents the RPC server.

func NewServer

func NewServer() *Server

NewServer creates a new local RPC server.

func (*Server) Close

func (s *Server) Close() error

Close stops the server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(path string) error

ListenAndServe starts the server.

func (*Server) Register

func (s *Server) Register(name string, handler Handler)

Register a handler for the given name.

Jump to

Keyboard shortcuts

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