handler

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSessionID = "default"

Variables

View Source
var (
	// The max number of events the client is eligible to read (unfiltered) which we are willing to
	// buffer on this connection. Too large and we consume lots of memory. Too small and busy accounts
	// will trip the connection knifing.
	MaxPendingEventUpdates = 200
)

Functions

This section is empty.

Types

type ConnState

type ConnState struct {
	// contains filtered or unexported fields
}

ConnState tracks all high-level connection state for this connection, like the combined request and the underlying sorted room list. It doesn't track positions of the connection.

func NewConnState

func NewConnState(
	userID, deviceID string, userCache *caches.UserCache, globalCache *caches.GlobalCache,
	ex extensions.HandlerInterface, joinChecker JoinChecker,
) *ConnState

func (*ConnState) Alive

func (s *ConnState) Alive() bool

func (*ConnState) Destroy

func (s *ConnState) Destroy()

Called when the connection is torn down

func (*ConnState) OnIncomingRequest

func (s *ConnState) OnIncomingRequest(ctx context.Context, cid sync3.ConnID, req *sync3.Request, isInitial bool) (*sync3.Response, error)

OnIncomingRequest is guaranteed to be called sequentially (it's protected by a mutex in conn.go)

func (*ConnState) OnRoomUpdate

func (s *ConnState) OnRoomUpdate(up caches.RoomUpdate)

Called by the user cache when updates arrive

func (*ConnState) OnUpdate

func (s *ConnState) OnUpdate(up caches.Update)

func (*ConnState) UserID

func (s *ConnState) UserID() string

type JoinChecker

type JoinChecker interface {
	IsUserJoined(userID, roomID string) bool
}

type SyncLiveHandler

type SyncLiveHandler struct {
	V2         sync2.Client
	Storage    *state.Storage
	V2Store    *sync2.Storage
	PollerMap  *sync2.PollerMap
	ConnMap    *sync3.ConnMap
	Extensions *extensions.Handler

	Dispatcher *sync3.Dispatcher

	GlobalCache *caches.GlobalCache
	// contains filtered or unexported fields
}

This is a net.http Handler for sync v3. It is responsible for pairing requests to Conns and to ensure that the sync v2 poller is running for this client.

func NewSync3Handler

func NewSync3Handler(v2Client sync2.Client, postgresDBURI string, debug bool) (*SyncLiveHandler, error)

func (*SyncLiveHandler) Accumulate

func (h *SyncLiveHandler) Accumulate(roomID, prevBatch string, timeline []json.RawMessage)

Called from the v2 poller, implements V2DataReceiver

func (*SyncLiveHandler) AddToDeviceMessages

func (h *SyncLiveHandler) AddToDeviceMessages(userID, deviceID string, msgs []json.RawMessage)

Called from the v2 poller, implements V2DataReceiver Add messages for this device. If an error is returned, the poll loop is terminated as continuing would implicitly acknowledge these messages.

func (*SyncLiveHandler) Initialise

func (h *SyncLiveHandler) Initialise(roomID string, state []json.RawMessage)

Called from the v2 poller, implements V2DataReceiver

func (*SyncLiveHandler) OnAccountData

func (h *SyncLiveHandler) OnAccountData(userID, roomID string, events []json.RawMessage)

func (*SyncLiveHandler) OnInvite

func (h *SyncLiveHandler) OnInvite(userID, roomID string, inviteState []json.RawMessage)

func (*SyncLiveHandler) OnRetireInvite

func (h *SyncLiveHandler) OnRetireInvite(userID, roomID string)

func (*SyncLiveHandler) ServeHTTP

func (h *SyncLiveHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*SyncLiveHandler) SetTyping

func (h *SyncLiveHandler) SetTyping(roomID string, userIDs []string)

Called from the v2 poller, implements V2DataReceiver

func (*SyncLiveHandler) Teardown added in v0.1.1

func (h *SyncLiveHandler) Teardown()

used in tests to close postgres connections

func (*SyncLiveHandler) UpdateDeviceSince

func (h *SyncLiveHandler) UpdateDeviceSince(deviceID, since string)

Called from the v2 poller, implements V2DataReceiver

func (*SyncLiveHandler) UpdateUnreadCounts

func (h *SyncLiveHandler) UpdateUnreadCounts(roomID, userID string, highlightCount, notifCount *int)

Jump to

Keyboard shortcuts

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