ipc

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2019 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package ipc implements a simple IPC system based on VOM.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPC

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

IPC provides interprocess rpcs. One process must act as the "server" by listening for connections. However once connected rpcs can flow in either direction.

func NewIPC

func NewIPC() *IPC

Create a new IPC object. After calling new you can register handlers with Serve(). Then call Listen() or Connect().

func (*IPC) Close

func (ipc *IPC) Close()

Close the IPC and all it's connections.

func (*IPC) Connect

func (ipc *IPC) Connect(path string, timeout time.Duration) (*IPCConn, error)

Connect to a listening socket at 'path'. If timeout is non-zero and the initial connection fails because the socket is not ready, Connect will retry once per second until the timeout expires.

func (*IPC) Connections

func (ipc *IPC) Connections() []*IPCConn

Connections returns all the current connections in this IPC.

func (*IPC) IdleStartTime

func (ipc *IPC) IdleStartTime() time.Time

IdleStartTime returns the time when this IPC became idle (no connections). If there are connections currently, returns the zero time instant.

func (*IPC) Listen

func (ipc *IPC) Listen(path string) error

Listen for connections by creating a UNIX domain socket at 'path'.

func (*IPC) Serve

func (ipc *IPC) Serve(x interface{}) error

Serve registers rpc handlers. All exported methods in 'x' are registered for rpc. All arguments and results for these methods must be VOM serializable. Additionally each method must have at least one return value, and the final return value must be an 'error'. Serve must be called before Listen() or Connect().

type IPCConn

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

IPCConn represents a connection to a process. It can be used to make rpcs to the other process. It also dispatches rpcs from that process to handlers registered with the parent IPC object.

func (*IPCConn) Call

func (c *IPCConn) Call(method string, args []interface{}, results ...interface{}) error

Perform an rpc with the given name and arguments. 'args' must correspond with the method registered in the other process, and results must contain pointers to the return types of the method. All rpc methods must have a final error result, which is not included in 'results'. It is the return value of Call().

func (*IPCConn) Close

func (c *IPCConn) Close()

Close the connection to the process. All outstanding rpcs will return errors.

Jump to

Keyboard shortcuts

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