syncer

package
v0.0.0-...-d19560e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MorpheusStore

type MorpheusStore struct {
	gomatrix.InMemoryStore
	CacheDatabase db.Storer
}

MorpheusStore implements the gomatrix.Storer interface.

It persists the next batch token in the database, and includes a ClientConfig for the client.

func (*MorpheusStore) LoadNextBatch

func (m *MorpheusStore) LoadNextBatch(userID string) string

LoadNextBatch loads from the database.

func (*MorpheusStore) SaveNextBatch

func (m *MorpheusStore) SaveNextBatch(userID, nextBatch string)

SaveNextBatch saves to the database.

type MorpheusSyncer

type MorpheusSyncer struct {
	UserID string
	Store  gomatrix.Storer
	// contains filtered or unexported fields
}

func NewMorpheusSyncer

func NewMorpheusSyncer(userID string, store gomatrix.Storer) *MorpheusSyncer

NewMorpheusSyncer returns an instantiated MorpheusSyncer

func (*MorpheusSyncer) GetFilterJSON

func (s *MorpheusSyncer) GetFilterJSON(userID string) json.RawMessage

GetFilterJSON returns a filter with a timeline limit of 50.

func (*MorpheusSyncer) OnEventType

func (s *MorpheusSyncer) OnEventType(eventType string, callback OnEventListener)

OnEventType allows callers to be notified when there are new events for the given event type. There are no duplicate checks.

func (*MorpheusSyncer) OnFailedSync

func (s *MorpheusSyncer) OnFailedSync(res *gomatrix.RespSync, err error) (time.Duration, error)

OnFailedSync always returns a 10 second wait period between failed /syncs, never a fatal error.

func (*MorpheusSyncer) ProcessResponse

func (s *MorpheusSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (err error)

ProcessResponse processes the /sync response in a way suitable for bots. "Suitable for bots" means a stream of unrepeating events. Returns a fatal error if a listener panics.

type OnEventListener

type OnEventListener func(*gomatrix.Event)

OnEventListener can be used with DefaultSyncer.OnEventType to be informed of incoming events.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL