Newer
Older
// ReaderWriter represents a single stream
// this stream can be used to send/receive an arbitrary amount of requests and notifications
type ReaderWriter interface {
Reader
Writer
}
// Reader can write JSON messages to its underlying connection
// Implementations must be safe for concurrent use
type Reader interface {
// gets the peer info
PeerInfo() PeerInfo
// json.RawMessage can be an array of requests. if it is, then it is a batch request
ReadBatch(ctx context.Context) (msgs []*Message, batch bool, err error)
// Implementations must be safe for concurrent use.
type Writer interface {
// write json blob to stream
// Flush flushes the writer to the stream between messages
Flush() error