mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-15 19:03:09 -06:00
Refine docs
Signed-off-by: Alex Chen <minecnly@gmail.com>
This commit is contained in:
parent
19f1a6fe0d
commit
530ed11ecc
|
|
@ -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.
|
// 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.
|
// 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.
|
// 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
|
// Typically a consumer supplies a posUpdate with the sync position for the
|
||||||
// for the type of event it handles to the latest.
|
// 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) {
|
func (n *Notifier) OnNewEvent(ev *gomatrixserverlib.Event, roomID string, userIDs []string, posUpdate types.SyncPosition) {
|
||||||
// update the current position then notify relevant /sync streams.
|
// 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.
|
// This needs to be done PRIOR to waking up users as they will read this value.
|
||||||
|
|
|
||||||
|
|
@ -76,9 +76,9 @@ func getTimeout(timeoutMS string) time.Duration {
|
||||||
|
|
||||||
// getSyncStreamPosition tries to parse a 'since' token taken from the API to a
|
// 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.
|
// 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
|
// There are two forms of tokens: The full length form containing all PDU and EDU
|
||||||
// all PDU and EDU positions. The second only contains the PDU position; prev_batch
|
// positions separated by "_", and the short form containing only the PDU
|
||||||
// tokens generated by the server will be in this form.
|
// position. Short form can be used for, e.g., `prev_batch` tokens.
|
||||||
func getSyncStreamPosition(since string) (*types.SyncPosition, error) {
|
func getSyncStreamPosition(since string) (*types.SyncPosition, error) {
|
||||||
if since == "" {
|
if since == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,8 @@ func (sp SyncPosition) IsAfter(other SyncPosition) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithUpdates returns a copy of `sp` with updates represented by `other` applied.
|
// 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 {
|
func (sp SyncPosition) WithUpdates(other SyncPosition) SyncPosition {
|
||||||
ret := sp
|
ret := sp
|
||||||
if other.PDUPosition != 0 {
|
if other.PDUPosition != 0 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue