gcmcacher

package
v0.1.5-rc1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: ISC Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cacher

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

Cacher caches GC messages fetched immediately after going online to improve UX of notifications of new messages.

func New

func New(maxLifetime, updateDelay, initialDelay time.Duration,
	log slog.Logger, handler func(Msg)) *Cacher

New creates a new GC message cacher. delayTimeout is the time between messages which causes the cacher to delay delivering messages. maxDelayTimeout is a max delay after which messages will be delivered, regardless of being received within delayDuration of each other.

func (*Cacher) GCMessageReceived

func (c *Cacher) GCMessageReceived(uid clientintf.UserID, gcm rpc.RMGroupMessage, ts time.Time)

GCMessageReceived should be called whenever a new GC message is externally received.

func (*Cacher) RMReceived added in v0.1.4

func (c *Cacher) RMReceived(uid clientintf.UserID, ts time.Time)

RMReceived should be called whenever an RM for a user is received.

func (*Cacher) Run

func (c *Cacher) Run(ctx context.Context) error

Run runs the cacher operations.

func (*Cacher) SessionChanged

func (c *Cacher) SessionChanged(connected bool)

SessionChanged should be called whenever the session changes.

type Msg

type Msg struct {
	UID clientintf.UserID
	GCM rpc.RMGroupMessage
	TS  time.Time
}

Msg is an individual message stored by the GC Message cacher.

Jump to

Keyboard shortcuts

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