rpc/protocol/server_codec.go

27 lines
752 B
Go
Raw Normal View History

2017-10-31 09:25:44 +00:00
package protocol
import (
"io"
)
2017-11-26 10:15:51 +00:00
// ServerCodec creates a ServerRequestCodec to process each request.
2017-10-31 09:25:44 +00:00
type ServerCodec interface {
2018-03-23 09:53:47 +00:00
NewRequest(r io.Reader) (ServerRequestCodec, error)
2018-03-20 06:31:54 +00:00
WriteNotification(w io.Writer, method string, args []interface{}) error
2018-03-23 13:45:48 +00:00
NewRequestB(buf []byte) (ServerRequestCodec, error)
NewNotificationB(method string, args []interface{}) ([]byte, error)
2017-10-31 09:25:44 +00:00
}
2017-11-26 10:15:51 +00:00
// ServerRequestCodec decodes a request and encodes a response using a specific
2017-10-31 09:25:44 +00:00
// serialization scheme.
2017-11-26 10:15:51 +00:00
type ServerRequestCodec interface {
2017-10-31 09:25:44 +00:00
RegistryCodec
2017-11-28 16:19:03 +00:00
2018-03-23 13:45:48 +00:00
NewResponseB(reply interface{}) ([]byte, error)
NewErrorB(status int, err error) ([]byte, error)
2017-10-31 09:25:44 +00:00
WriteResponse(w io.Writer, reply interface{}) error
WriteError(w io.Writer, status int, err error) error
}