README ¶
MsgPack RPC Codec
Usage
Import the codec and set within the client/server
package main
import (
"github.com/micro/go-plugins/codec/msgpackrpc"
"github.com/micro/go-micro"
"github.com/micro/go-micro/client"
"github.com/micro/go-micro/server"
)
func main() {
client := client.NewClient(
client.Codec("application/msgpack", msgpackrpc.NewCodec),
client.ContentType("application/msgpack"),
)
server := server.NewServer(
server.Codec("application/msgpack", msgpackrpc.NewCodec),
)
service := micro.NewService(
micro.Client(client),
micro.Server(server),
)
// ...
}
Generating Request/Response types
The msgpack codec is much like protobuf. It expects the request/response types to conform to a specific interface. Usually this means defining some IDL and generating the required types.
Learn how to do that at github.com/tinylib/msgp
Documentation ¶
Overview ¶
Package msgpackrpc provides a msgpack-rpc codec
Index ¶
Constants ¶
View Source
const ( RequestType = 0 ResponseType = 1 NotificationType = 2 RequestPackSize = 4 ResponsePackSize = 4 NotificationPackSize = 3 )
The msgpack-rpc specification: https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md
Variables ¶
View Source
var ( ErrBadPackSize = errors.New("Bad pack size") ErrBadMessageType = errors.New("Bad message type") ErrBadErrorType = errors.New("Bad error type") ErrUnexpectedParams = errors.New("Unexpected params") ErrNotEncodable = errors.New("Not encodable") ErrNotDecodable = errors.New("Not decodable") )
Functions ¶
Types ¶
type Notification ¶
type Notification struct { Method string Body interface{} // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.