Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store interface {
// Increment atomically adds delta to a user's badge count and returns the
// resulting value. A user with no badge yet is treated as zero. delta is
// typically 1 per unread-eligible message, or a larger amount when several
// have been coalesced.
Increment(ctx context.Context, userID *commonpb.UserId, delta uint64) (uint64, error)
// IncrementBatch applies Increment to each of userIDs and returns the
// resulting values keyed by string(userID.Value). It exists for a chat's
// fan-out, where one message bumps many users at once: implementations run
// the per-user increments concurrently, so a batch costs a few round trips
// of latency rather than one per user, while each user's increment stays
// atomic on its own item.
//
// Best-effort per user: a failed increment leaves that user out of the
// result, and the failures are joined into the returned error alongside the
// partial result. userIDs should be distinct — a duplicate is incremented
// once per occurrence, and the reported count is that of whichever landed
// last.
IncrementBatch(ctx context.Context, userIDs []*commonpb.UserId, delta uint64) (map[string]uint64, error)
// Get returns a user's current badge count, or zero if the user has none.
Get(ctx context.Context, userID *commonpb.UserId) (uint64, error)
// Reset sets a user's badge count back to zero, e.g. when the app is opened.
Reset(ctx context.Context, userID *commonpb.UserId) error
}
Store persists per-user app-icon badge counts.
The count is a "notifications since last open" counter, not a live unread total: Increment bumps it as unread-eligible messages fan out to a user, and Reset zeroes it when the user opens the app. All mutations are atomic, so the concurrent increments produced by a noisy chat's fan-out serialize on the user's item rather than racing through a read-modify-write.
Click to show internal directories.
Click to hide internal directories.