8460: Merge branch 'master' into 8460-websocket-go
[arvados.git] / services / ws / session.go
1 package main
2
3 type session interface {
4         // Receive processes a message received from the client. If a
5         // non-nil error is returned, the connection will be
6         // terminated.
7         Receive([]byte) error
8
9         // Filter returns true if the event should be queued for
10         // sending to the client. It should return as fast as
11         // possible, and must not block.
12         Filter(*event) bool
13
14         // EventMessage encodes the given event (from the front of the
15         // queue) into a form suitable to send to the client. If a
16         // non-nil error is returned, the connection is terminated. If
17         // the returned buffer is empty, nothing is sent to the client
18         // and the event is not counted in statistics.
19         //
20         // Unlike Filter, EventMessage can block without affecting
21         // other connections. If EventMessage is slow, additional
22         // incoming events will be queued. If the event queue fills
23         // up, the connection will be dropped.
24         EventMessage(*event) ([]byte, error)
25 }