rpc/protocol/server_codec.go
crusader 3e82c65689 ing
2018-03-23 22:45:48 +09:00

27 lines
752 B
Go

package protocol
import (
"io"
)
// ServerCodec creates a ServerRequestCodec to process each request.
type ServerCodec interface {
NewRequest(r io.Reader) (ServerRequestCodec, error)
WriteNotification(w io.Writer, method string, args []interface{}) error
NewRequestB(buf []byte) (ServerRequestCodec, error)
NewNotificationB(method string, args []interface{}) ([]byte, error)
}
// ServerRequestCodec decodes a request and encodes a response using a specific
// serialization scheme.
type ServerRequestCodec interface {
RegistryCodec
NewResponseB(reply interface{}) ([]byte, error)
NewErrorB(status int, err error) ([]byte, error)
WriteResponse(w io.Writer, reply interface{}) error
WriteError(w io.Writer, status int, err error) error
}