Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.
/ comet Public archive

`long polling` which idea comes from google channel

Notifications You must be signed in to change notification settings

iamsk/comet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Browser request workflow:

1. A request comes.
2. Identify which channel the request comes from.
3. Get data if available, or wait for data.
4. Response.

Web event update workflow

1. Web generates event data.
2. Identify which users should get the data.
3. Push to every channel belonging to these users.

The Comet System

A channel is identified by user_id and location, where location is the complete URL of the current page. We represent a channel in Redis using a sorted set:

Key: channel:<user_id>:<location>
Type: sorted set
Value: <sequence id>
Score: Creation Time
      (after TTL the item will be garbage collected by a separate process)

The sequence ID records the index of the actual data (a JSON object) stored in a Redis hash structure:

Key: channel_data:<user_id>:<location>
Field: <sequence id>
Value: JSON string (gzipped to reduce memory footprint)

Since we are using separate garbage collectors to cleanup these Redis keys, we do not need connections to keep track of open connections anymore.

About

`long polling` which idea comes from google channel

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages