Documentation
¶
Overview ¶
Package amqprpc is an AMQP driver for net/rpc. It provides an implementation of the rpc.ClientCodec and rpc.ServerCodec interfaces, which send and respond to RPC calls respecteively on a given AMQP connection.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoConsumers = errors.New("amqprpc: No consumers in queue")
Functions ¶
func NewClientCodec ¶
func NewClientCodec(conn *amqp.Connection, serverRouting string, encodingCodec EncodingCodec) (rpc.ClientCodec, error)
NewClientCodec returns a new rpc.ClientCodec using AMQP on conn. serverRouting is the routing key with with RPC calls are sent, it should be the same routing key used with NewServerCodec. encodingCodec is an EncodingCoding implementation. This package provdes JSONCodec and GobCodec for the JSON and Gob encodings respectively.
Example ¶
conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/") if err != nil { log.Fatal(err) } clientCodec, err := amqprpc.NewClientCodec(conn, "rpc_queue", amqprpc.GobCodec{}) if err != nil { log.Fatal(err) } client := rpc.NewClientWithCodec(clientCodec) client.Call("Foo.Bar", struct{}{}, &struct{}{})
Output:
func NewServerCodec ¶
func NewServerCodec(conn *amqp.Connection, serverRouting string, encodingCodec EncodingCodec) (rpc.ServerCodec, error)
NewServerCodec returns a new rpc.ClientCodec using AMQP on conn. serverRouting is the routing key with with RPC calls are received, encodingCodec is an EncodingCoding implementation. This package provdes JSONCodec and GobCodec for the JSON and Gob encodings respectively.
Example ¶
conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/") if err != nil { log.Fatal(err) } serverCodec, err := amqprpc.NewServerCodec(conn, "rpc_queue", amqprpc.GobCodec{}) if err != nil { log.Fatal(err) } go rpc.ServeCodec(serverCodec)
Output:
Types ¶
type EncodingCodec ¶
type EncodingCodec interface { Marshal(interface{}) ([]byte, error) Unmarshal([]byte, interface{}) error }
EncodingCodec implements marshaling and unmarshaling of seralized data.