8784: Fix test for latest firefox.
[arvados.git] / services / ws / session.go
1 package main
2
3 import (
4         "database/sql"
5
6         "git.curoverse.com/arvados.git/sdk/go/arvados"
7 )
8
9 type session interface {
10         // Receive processes a message received from the client. If a
11         // non-nil error is returned, the connection will be
12         // terminated.
13         Receive([]byte) error
14
15         // Filter returns true if the event should be queued for
16         // sending to the client. It should return as fast as
17         // possible, and must not block.
18         Filter(*event) bool
19
20         // EventMessage encodes the given event (from the front of the
21         // queue) into a form suitable to send to the client. If a
22         // non-nil error is returned, the connection is terminated. If
23         // the returned buffer is empty, nothing is sent to the client
24         // and the event is not counted in statistics.
25         //
26         // Unlike Filter, EventMessage can block without affecting
27         // other connections. If EventMessage is slow, additional
28         // incoming events will be queued. If the event queue fills
29         // up, the connection will be dropped.
30         EventMessage(*event) ([]byte, error)
31 }
32
33 type sessionFactory func(wsConn, chan<- interface{}, *sql.DB, permChecker, *arvados.Client) (session, error)