Refine docs

Signed-off-by: Alex Chen <minecnly@gmail.com>
This commit is contained in:
Cnly 2019-06-28 01:32:23 +08:00
parent 19f1a6fe0d
commit 530ed11ecc
3 changed files with 7 additions and 6 deletions

View file

@ -62,8 +62,8 @@ func NewNotifier(pos types.SyncPosition) *Notifier {
// Can be called with one among: a *gomatrixserverlib.Event, a room ID, or a list of user IDs.
// posUpdate contains the latest position(s) for one or more types of events.
// If a position in posUpdate is 0, it means no updates available of that type.
// Typically a consumer supplies a posUpdate with and only with the sync position
// for the type of event it handles to the latest.
// Typically a consumer supplies a posUpdate with the sync position for the
// event type it handles set to the latest, leaving other fields as 0.
func (n *Notifier) OnNewEvent(ev *gomatrixserverlib.Event, roomID string, userIDs []string, posUpdate types.SyncPosition) {
// update the current position then notify relevant /sync streams.
// This needs to be done PRIOR to waking up users as they will read this value.

View file

@ -76,9 +76,9 @@ func getTimeout(timeoutMS string) time.Duration {
// getSyncStreamPosition tries to parse a 'since' token taken from the API to a
// stream position. If the string is empty then (nil, nil) is returned.
// There are two types of token: The first is a full length one containing
// all PDU and EDU positions. The second only contains the PDU position; prev_batch
// tokens generated by the server will be in this form.
// There are two forms of tokens: The full length form containing all PDU and EDU
// positions separated by "_", and the short form containing only the PDU
// position. Short form can be used for, e.g., `prev_batch` tokens.
func getSyncStreamPosition(since string) (*types.SyncPosition, error) {
if since == "" {
return nil, nil

View file

@ -42,7 +42,8 @@ func (sp SyncPosition) IsAfter(other SyncPosition) bool {
}
// WithUpdates returns a copy of `sp` with updates represented by `other` applied.
// If a field is not 0 in `other`, it is considered an update.
// If a field is not 0 in `other`, it is considered an update and its value
// will replace the corresponding value in sp.
func (sp SyncPosition) WithUpdates(other SyncPosition) SyncPosition {
ret := sp
if other.PDUPosition != 0 {