Documentation ¶
Overview ¶
Package rpc implements all available requests and handler for communication
Index ¶
- func AddItem(c *rpc.Client, arg string) error
- func BuildRouter() map[string]func(*rpc.Client, string) error
- func GetAllItems(c *rpc.Client, arg string) error
- func GetItem(c *rpc.Client, arg string) error
- func NewClientCodec(conn *amqp.Connection, cfg *configs.Config, encodingCodec EncodingCodec) (rpc.ClientCodec, error)
- func NewClientWithCodec(codec rpc.ClientCodec) *rpc.Client
- func NewServerCodec(conn *amqp.Connection, cfg *configs.Config, encodingCodec EncodingCodec) (rpc.ServerCodec, error)
- func Register(receiver interface{}) error
- func RemoveItem(c *rpc.Client, arg string) error
- func ServeCodec(codec rpc.ServerCodec)
- type EncodingCodec
- type GobCodec
- type Items
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRouter ¶
BuildRouter creates map for instant finding handler to any command
func GetAllItems ¶
GetAllItems sends request over rpc for retrieving all items in the order they were added
func NewClientCodec ¶
func NewClientCodec(conn *amqp.Connection, cfg *configs.Config, 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.
func NewClientWithCodec ¶
func NewClientWithCodec(codec rpc.ClientCodec) *rpc.Client
NewClientWithCodec returns rpc client
func NewServerCodec ¶
func NewServerCodec(conn *amqp.Connection, cfg *configs.Config, 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.
func Register ¶
func Register(receiver interface{}) error
Register publishes the receiver's methods in the rpc.DefaultServer.
func RemoveItem ¶
RemoveItem sends request over rpc for deleting requested item from store
func ServeCodec ¶
func ServeCodec(codec rpc.ServerCodec)
ServeCodec is like ServeConn but uses the specified codec to decode requests and encode responses.
Types ¶
type EncodingCodec ¶
type EncodingCodec interface { Marshal(interface{}) ([]byte, error) Unmarshal([]byte, interface{}) error }
EncodingCodec implements marshaling and unmarshaling of seralized data.
type GobCodec ¶
type GobCodec struct{}
GobCodec is an EncodingCodec implementation to send/receive Gob data over AMQP.
type Items ¶
type Items struct {
// contains filtered or unexported fields
}
Items stores ordered map and uses for rpc handling
func (Items) GetAllItems ¶
GetAllItems returns items in order they were added