Skip to content
This repository was archived by the owner on May 9, 2022. It is now read-only.
/ user-tracker Public archive

Library for displaying currently active users of your application

License

Notifications You must be signed in to change notification settings

guardian/user-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e3e7a32 · Jun 17, 2014

History

3 Commits
Jun 17, 2014
Jun 17, 2014
Jun 17, 2014
Jun 17, 2014
Jun 17, 2014
Jun 17, 2014

Repository files navigation

User Tracker

Library for displaying current (logged in) users of your application.

Designed so as to be non-blocking on writes and reads, and to perform as few database operations as possible in the background. (i.e., it's supposed to be cheap to use!)

Usage

Persistence

Persistence allows your logged in user data to be propagated across a set of servers.

Either implement the Persistence layer yourself or use the provided DynamoDBPersistence with DynamoDB.

val persistence = DynamoDBPersistence(
  client = new AmazonDynamoDBAsyncClient(),
  tableName = "application_users"
)

If using DynamoDBPersistence make sure to start the GC cycle:

DynamoDBPersistence.startGarbageCollection(persistence, frequency = 5 minutes)

User Tracking

Create a single instance of UserTracker at application start up:

val userTracker = new UserTracker(
  persistence
)

Trigger the scheduled updates to the persistence layer at start up:

UserTracker.startPersistence(userTracker)

Tell the user tracker when you see a user:

userTracker.recordSeenNow(UserId("robert"))

Ask the user tracker for the currently active users:

val users = userTracker.currentlyActive

License

Copyright Guardian News & Media. Licensed under Apache 2.0.

About

Library for displaying currently active users of your application

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages