-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapi.go
61 lines (46 loc) · 1.48 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package gofast
// Streamer interface to send/receive bidirectional streams of several
// messages.
type Streamer interface {
// Response to a request, to batch the response pass flush as false.
Response(msg Message, flush bool) error
// Stream a single message, to batch the message pass flush as false.
Stream(msg Message, flush bool) error
// Close this stream.
Close() error
}
// BinMessage is a tuple of {id, encodedmsg-slice}. This type is used on
// the receiver side of the transport.
type BinMessage struct {
ID uint64
Data []byte
}
// Message interface, shall implemented by all messages exchanged via
// gofast-transport.
type Message interface {
// ID return a unique message identifier.
ID() uint64
// Encode message to binary blob.
Encode(out []byte) []byte
// Decode this message from a binary blob.
Decode(in []byte) (n int64)
// Size is maximum memory foot-print needed for encoding this message.
Size() int64
// String representation of this message, used for logging.
String() string
}
// Version interface to exchange and manage transport's version.
type Version interface {
// Less than supplied version.
Less(ver Version) bool
// Equal to the supplied version.
Equal(ver Version) bool
// Encode version into array of bytes.
Encode(out []byte) []byte
// Decode array of bytes to version object.
Decode(in []byte) (n int64)
// Size return memory foot-print encoded version
Size() int64
// String representation of version, for logging.
String() string
}