rpc/protocol/client_codec.go
crusader 2286a5021e ing
2017-11-26 19:15:51 +09:00

46 lines
915 B
Go

package protocol
import (
"io"
)
type MessageType int
const (
MessageTypeUnknown MessageType = iota
MessageTypeRequest
MessageTypeResponse
MessageTypeNotification
)
// ClientCodec creates a ClientCodecRequest to process each request.
type ClientCodec interface {
WriteRequest(w io.Writer, method string, args interface{}, id interface{}) error
NewMessage(rc io.Reader) (ClientMessageCodec, error)
}
type ClientRequestCodec interface {
RegistryCodec
}
// ClientMessageCodec decodes a response or notification using a specific
// serialization scheme.
type ClientMessageCodec interface {
MessageType() MessageType
// Reads the message filling the RPC response or notification.
MessageCodec() (interface{}, error)
Close()
}
type ClientResponseCodec interface {
Result(result interface{}) error
Error() error
ID() interface{}
Close()
}
type ClientNotificationCodec interface {
RegistryCodec
}