rpc

package module
v0.0.0-...-1ff2185 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2017 License: MIT Imports: 11 Imported by: 0

README

rpc

GO RPC package

Documentation

Overview

Package lastbackend/prc implements an amqp queue based messaging system. Like the standard AMQP application rpc.Router matches incoming messages against a list of registered routes and upstream and calls a handler for the route or upstream that matches the route name or upstream or other conditions. The main features are:

  • Messages routing can be matched based received router, upstream.
  • You can send many types of messages, with or without confirmation.

Each app automatically join in a group by its name, you can set uuid of registered app to provide better delivery.

You should start with your app registering:

func main() {
	r := rpc.Register()
	r.SetHandler("handler",   SomeHandler)
}

Setup handler and upstream examples:

r := rpc.Register()
r.SetHandler("handler",   SomeHandler)
r.SetUpstream("upstream", SomeUpstream)

Handlers and Upstreams examples:

	// SomeHandler definition
 	func SomeHandler(s rpc.Sender, message []byte) error {

 	}

 	// SomeUpstream definition
 	func SomeUpstream(s rpc.Sender, r rpc.Recipient, message []byte) error {

 	}

Index

Constants

This section is empty.

Variables

View Source
var (
	ERRINVALIDLENGTH = errors.New("Invalid length of message field")
	ERRINVALIDTOKEN  = errors.New("Invalid authentication token")
)

Functions

This section is empty.

Types

type Destination

type Destination struct {
	Name    string
	UUID    string
	Handler string
	All     bool
}

func (*Destination) Sign

func (d *Destination) Sign() ([]byte, error)

type Handler

type Handler func(Sender, []byte) error

type RPC

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

func Register

func Register(name string, uuid string, token string) (*RPC, error)

Register application in RPC

func (*RPC) Call

func (r *RPC) Call(d Destination, message interface{}) error

Call - send message with delivery guarantee

func (*RPC) CallBinary

func (r *RPC) CallBinary(d Destination, message []byte) error

CallBinary - send binary message with delivery guarantee

func (*RPC) CallSigned

func (r *RPC) CallSigned(s Sender, d Destination, message interface{}) error

CallSigned - send signed message with delivery guarantee

func (*RPC) CallSignedBinary

func (r *RPC) CallSignedBinary(s Sender, d Destination, message []byte) error

CallSignedBinary - send signed binary message with delivery guarantee

func (*RPC) Cast

func (r *RPC) Cast(d Destination, message interface{}) error

Cast - send message without delivery guarantee

func (*RPC) CastBinary

func (r *RPC) CastBinary(d Destination, message []byte) error

CastBinary - send binary message without delivery guarantee

func (*RPC) CastSigned

func (r *RPC) CastSigned(s Sender, d Destination, message interface{}) error

CastSigned - send signed message without delivery guarantee

func (*RPC) CastSignedBinary

func (r *RPC) CastSignedBinary(s Sender, d Destination, message []byte) error

CastSignedBinary - send signed binary message without delivery guarantee

func (*RPC) Cleanup

func (r *RPC) Cleanup()

func (*RPC) Connected

func (r *RPC) Connected() chan bool

func (*RPC) Listen

func (r *RPC) Listen()

Start listening for incoming messages

func (*RPC) ProxyCall

func (r *RPC) ProxyCall(d Destination, p Receiver, message interface{}) error

Proxy send message methods ProxyCall - send message throw another application with delivery guarantee

func (*RPC) ProxyCallBinary

func (r *RPC) ProxyCallBinary(d Destination, p Receiver, message []byte) error

ProxyCallBinary - send binary message throw another application with delivery guarantee

func (*RPC) ProxyCast

func (r *RPC) ProxyCast(d Destination, p Receiver, message interface{}) error

ProxyCast - send message throw another application without delivery guarantee

func (*RPC) ProxyCastBinary

func (r *RPC) ProxyCastBinary(d Destination, p Receiver, message []byte) error

ProxyCastBinary - send message throw another application without delivery guarantee

func (*RPC) SetHandler

func (r *RPC) SetHandler(h string, f Handler)

SetHeader - set handler routing

func (*RPC) SetLimit

func (r *RPC) SetLimit(limit int)

func (*RPC) SetURI

func (r *RPC) SetURI(uri string)

SetURI - set URI connection

func (*RPC) SetUpstream

func (r *RPC) SetUpstream(u string, f Upstream)

SetUpstream - set upstream routing

func (*RPC) Shutdown

func (r *RPC) Shutdown()

type Receiver

type Receiver struct {
	Name    string
	UUID    string
	Handler string
	All     bool
}

func (*Receiver) Sign

func (p *Receiver) Sign() ([]byte, error)

type Sender

type Sender struct {
	Name string
	UUID string
}

func (*Sender) Sign

func (s *Sender) Sign() ([]byte, error)

type Upstream

type Upstream func(Sender, Destination, []byte) error

Jump to

Keyboard shortcuts

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