Skip to content

Instantly share code, notes, and snippets.

@thruflo
Created December 5, 2011 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thruflo/1433666 to your computer and use it in GitHub Desktop.
Save thruflo/1433666 to your computer and use it in GitHub Desktop.

Live Client

  • each client holds open one primary and potentially multiple secondary connections

  • subscribe(qid, callback):

    • stores an item mapping qid to callback

    • opens a secondary_channel with qid

    • stores an item mapping qid to secondary_channel

    • on_primary_response:

      • dedupe_callback(qid, item) for item in items
      • update seen
      • for channel in secondary_channels:
        • add qid to primary if qid not in primary
        • flag secondary as ready_to_close
    • on_secondary_response

      • dedupe_callback(qid, item) for item in items
      • close() if ready_to_close
  • unsubscribe(qid):

    • remove item mapping qid to callback
    • stores an item mapping qid to to_remove
    • for channel in secondary_channels:
      • flag as ready_to_close if channel.qid == qid
  • constructor:

    • starts a cleanup loop that removes old items
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment