Documentation ¶
Overview ¶
Package store takes care of storing pending notifications.
Index ¶
- Constants
- Variables
- func FilterOutByMsgId(orig, targets []protocol.Notification) []protocol.Notification
- func FilterOutObsolete(notifications []protocol.Notification, meta []Metadata) []protocol.Notification
- func InternalChannelIdToHex(chanId InternalChannelId) string
- type InMemoryPendingStore
- func (sto *InMemoryPendingStore) AppendToChannel(chanId InternalChannelId, notificationPayload json.RawMessage, ...) error
- func (sto *InMemoryPendingStore) AppendToUnicastChannel(chanId InternalChannelId, appId string, notificationPayload json.RawMessage, ...) error
- func (sto *InMemoryPendingStore) Close()
- func (sto *InMemoryPendingStore) DropByMsgId(chanId InternalChannelId, targets []protocol.Notification) error
- func (sto *InMemoryPendingStore) GetChannelSnapshot(chanId InternalChannelId) (int64, []protocol.Notification, error)
- func (sto *InMemoryPendingStore) GetChannelUnfiltered(chanId InternalChannelId) (int64, []protocol.Notification, []Metadata, error)
- func (sto *InMemoryPendingStore) GetInternalChannelId(name string) (InternalChannelId, error)
- func (sto *InMemoryPendingStore) GetInternalChannelIdFromToken(token, appId, userId, deviceId string) (InternalChannelId, error)
- func (sto *InMemoryPendingStore) Register(deviceId, appId string) (string, error)
- func (sto *InMemoryPendingStore) Scrub(chanId InternalChannelId, criteria ...string) error
- func (sto *InMemoryPendingStore) Unregister(deviceId, appId string) error
- type InternalChannelId
- type Metadata
- type PendingStore
Constants ¶
const SystemInternalChannelId = InternalChannelId("0")
Variables ¶
var ErrExpected128BitsHexRepr = errors.New("expected 128 bits hex repr")
var ErrFull = errors.New("channel is full")
var ErrUnknownChannel = errors.New("unknown channel name")
var ErrUnknownToken = errors.New("unknown token")
Functions ¶
func FilterOutByMsgId ¶
func FilterOutByMsgId(orig, targets []protocol.Notification) []protocol.Notification
FilterOutByMsgId returns the notifications from orig whose msg id is not mentioned in targets.
func FilterOutObsolete ¶
func FilterOutObsolete(notifications []protocol.Notification, meta []Metadata) []protocol.Notification
FilterOutObsolete filters out expired notifications and superseded notifications sharing a replace tag based on paired meta information.
func InternalChannelIdToHex ¶
func InternalChannelIdToHex(chanId InternalChannelId) string
Types ¶
type InMemoryPendingStore ¶
type InMemoryPendingStore struct {
// contains filtered or unexported fields
}
InMemoryPendingStore is a basic in-memory pending notification store.
func NewInMemoryPendingStore ¶
func NewInMemoryPendingStore() *InMemoryPendingStore
NewInMemoryPendingStore returns a new InMemoryStore.
func (*InMemoryPendingStore) AppendToChannel ¶
func (sto *InMemoryPendingStore) AppendToChannel(chanId InternalChannelId, notificationPayload json.RawMessage, expiration time.Time) error
func (*InMemoryPendingStore) AppendToUnicastChannel ¶
func (sto *InMemoryPendingStore) AppendToUnicastChannel(chanId InternalChannelId, appId string, notificationPayload json.RawMessage, msgId string, meta Metadata) error
func (*InMemoryPendingStore) Close ¶
func (sto *InMemoryPendingStore) Close()
func (*InMemoryPendingStore) DropByMsgId ¶
func (sto *InMemoryPendingStore) DropByMsgId(chanId InternalChannelId, targets []protocol.Notification) error
func (*InMemoryPendingStore) GetChannelSnapshot ¶
func (sto *InMemoryPendingStore) GetChannelSnapshot(chanId InternalChannelId) (int64, []protocol.Notification, error)
func (*InMemoryPendingStore) GetChannelUnfiltered ¶
func (sto *InMemoryPendingStore) GetChannelUnfiltered(chanId InternalChannelId) (int64, []protocol.Notification, []Metadata, error)
func (*InMemoryPendingStore) GetInternalChannelId ¶
func (sto *InMemoryPendingStore) GetInternalChannelId(name string) (InternalChannelId, error)
func (*InMemoryPendingStore) GetInternalChannelIdFromToken ¶
func (sto *InMemoryPendingStore) GetInternalChannelIdFromToken(token, appId, userId, deviceId string) (InternalChannelId, error)
func (*InMemoryPendingStore) Register ¶
func (sto *InMemoryPendingStore) Register(deviceId, appId string) (string, error)
func (*InMemoryPendingStore) Scrub ¶
func (sto *InMemoryPendingStore) Scrub(chanId InternalChannelId, criteria ...string) error
func (*InMemoryPendingStore) Unregister ¶
func (sto *InMemoryPendingStore) Unregister(deviceId, appId string) error
type InternalChannelId ¶
type InternalChannelId string
func HexToInternalChannelId ¶
func HexToInternalChannelId(hexRepr string) (InternalChannelId, error)
func UnicastInternalChannelId ¶
func UnicastInternalChannelId(userId, deviceId string) InternalChannelId
UnicastInternalChannelId builds a channel id for the userId, deviceId pair.
func (InternalChannelId) BroadcastChannel ¶
func (icid InternalChannelId) BroadcastChannel() bool
BroadcastChannel returns whether the id represents a broadcast channel.
func (InternalChannelId) UnicastChannel ¶
func (icid InternalChannelId) UnicastChannel() bool
UnicastChannel returns whether the id represents a unicast channel.
func (InternalChannelId) UnicastUserAndDevice ¶
func (icid InternalChannelId) UnicastUserAndDevice() (userId, deviceId string)
UnicastUserAndDevice returns the user and device ids of a unicast channel.
type PendingStore ¶
type PendingStore interface { // Register returns a token for a device id, application id pair. Register(deviceId, appId string) (token string, err error) // Unregister forgets the token for a device id, application id pair. Unregister(deviceId, appId string) error // GetInternalChannelId returns the internal store id for a channel // given the name. GetInternalChannelId(name string) (InternalChannelId, error) // AppendToChannel appends a notification to the channel. AppendToChannel(chanId InternalChannelId, notification json.RawMessage, expiration time.Time) error // GetInternalChannelIdFromToken returns the matching internal store // id for a channel given a registered token and application id or // directly a device id, user id pair. GetInternalChannelIdFromToken(token, appId, userId, deviceId string) (InternalChannelId, error) // AppendToUnicastChannel appends a notification to the unicast channel. AppendToUnicastChannel(chanId InternalChannelId, appId string, notification json.RawMessage, msgId string, meta Metadata) error // GetChannelSnapshot gets all the current notifications and // current top level in the channel. GetChannelSnapshot(chanId InternalChannelId) (topLevel int64, notifications []protocol.Notification, err error) // GetChannelUnfiltered gets all the stored notifications with // metadata and current top level in the channel. GetChannelUnfiltered(chanId InternalChannelId) (topLevel int64, notifications []protocol.Notification, metadata []Metadata, err error) // Scrub removes notifications from the channel based on criteria. // Usages: // Scrub(chanId) removes all expired notifications. // Scrub(chanId, appId) removes all expired notifications and // all notifications for appId. // Scrub(chanId, appId, replaceTag) removes all expired notifications // and all notifications matching both appId and replaceTag. Scrub(chanId InternalChannelId, criteria ...string) error // DropByMsgId drops notifications from a unicast channel // based on message ids. DropByMsgId(chanId InternalChannelId, targets []protocol.Notification) error // Close is to be called when done with the store. Close() }
PendingStore let store notifications into channels.