Skip to content

cmcoffee/go-ezipc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ezipc

import "github.com/cmcoffee/go-ezipc"

Package ezipc provides a simple framework to allow for communication between multiple background processes.

EzIPC has similar requirements for exporting functions that Go's native "rpc" package provides, however ezipc maps both functions and object methods.

1)the method or function requires two arguments, both exported (or builtin) types.
2)the method or function's second argument is a pointer.
3)the method or function has a return type of error.

Registered methods or functions should look like:

func (*T) Name(argType T1, replyType *T2) error

and respectively ...

func name(argType T1, replyType *T2) error

Exported functions & methods should be made thread safe.

Variables

var ErrClosed = errors.New("Connection closed.")
var ErrFail = errors.New("Call failed.")

type EzIPC

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

EzIPC is common to both IPC clients and servers.

func New

func New() *EzIPC

Creates a new ezipc router.

func (*EzIPC) Call

func (e *EzIPC) Call(name string, arg interface{}, reply interface{}) (err error)

Call invokes a registered method/function, blocks while actively checking for for completion, returns err on failure.

func (*EzIPC) Dial

func (e *EzIPC) Dial(socketf string) error

Dial is the client function of EzIPC, it opens a connection to the socket file.

func (*EzIPC) Listen

func (e *EzIPC) Listen(socketf string) (err error)

Listens is the server function of EzIPC, it opens a connection and blocks while listening for requests.

func (*EzIPC) Register

func (e *EzIPC) Register(fptr interface{}) error

Registers local methods or function, informs Broker of registration. Function/method template should follow: func name(argType T1, replyType *T2) error func (*T) Name(argType T1, replyType *T2) error

func (*EzIPC) RegisterName

func (e *EzIPC) RegisterName(name string, fptr interface{}) (err error)

RegisterName operates exactly as Register but allows changing the name of the object or function.


Generated by godoc2md

About

Simple Inter-Process Communication (IPC) Messaging Library for Go. (golang ipc)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages