Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Autoupdate ¶
type Autoupdate struct {
// contains filtered or unexported fields
}
Autoupdate holds the state of the serice.
The Service caches all data in its newest version. This means, that only the newst data ist returned, even when old change ids are requested. The change id system only desices, which keys have changed.
func New ¶
func New(datastore Datastore, restricter Restricter, closed <-chan struct{}) (*Autoupdate, error)
New create a new autoupdate instance.
func (*Autoupdate) Projectors ¶
func (a *Autoupdate) Projectors(ctx context.Context, tid uint64, pids []int) (ntid uint64, data map[int]json.RawMessage, cid int, err error)
Projectors returns the renderd data for a list of projectors. The attribute pids i sthe list of requested projectors. Only the projectors that changed are returned.
The attribute tid tells the last version the caller has seen. 0 Means, no data has to be seen, so all requested projectors are returned.
This method blocks until the service is closed, the given context exists or there are data to return.
func (*Autoupdate) Receive ¶
func (a *Autoupdate) Receive(ctx context.Context, uid int, changeID int) (bool, map[string]json.RawMessage, int, error)
Receive returns all changed data and the new changeid since the given change id. If there is no new data, then this method blocks until the context is done, the service is closed or new data is received.
If the returned value is nil, then the context or the service was closed.
The returned data is restricted for the given uid.
type Datastore ¶
type Datastore interface { LowestID() int CurrentID() int KeysChanged() ([]string, int, error) GetMany([]string) map[string]json.RawMessage GetAll() map[string]json.RawMessage ChangedKeys(from, to int) ([]string, error) ProjectorData(ctx context.Context, tid uint64) (uint64, map[int]json.RawMessage, error) }
Datastore holds the current data.
type Restricter ¶
type Restricter interface {
Restrict(uid int, data map[string]json.RawMessage)
}
Restricter restricts data for one user.