<commit_before>---
layout:     post
title:      "Pusher - Realtime message service"
subtitle:   "Build a realtime message service"
date:       2014-12-12 12:00:00
author:     "miraclew"
header-img: "img/post-bg-06.jpg"
---

<h2>Components</h2>
 1. Connector (Golang)
 2. Hub (PHP)
 3. Message Queue (Beanstalkd)

 Connector <--> Redis <--> Hub

<h3>Connector</h3>
 1. Connect with token
 2. Authenticate client
 3. Update online/offline status of client into Redis

<h3>Redis</h3>
 1. Tokens (Type: string, K/V: token/uid, TTL: 12h)
 2. Users (Type: hash, K/V: uid/{online, nickname, avatar etc.}, TTL: 7d)
 3. Channels (Type: set, K/V: cid/uids, TTL: EVER)
 4. Connectors: 
 5. Connector Queue: (Type: list, K/V: connector_id/messages )
 6. Device bindings

<h3>Test with PHP</h3>

Create PHP project with composer
`mkdir `

<commit_msg>sdfksdf<commit_after>---
layout:     post
title:      "Pusher - Realtime message service"
subtitle:   "Build a realtime message service"
date:       2014-12-12 12:00:00
author:     "miraclew"
header-img: "img/post-bg-06.jpg"
---

<h2>Components</h2>
 1. Connector (Golang)
 2. Hub (PHP)
 3. Message Queue (Beanstalkd)

 Connector <--> Redis <--> Hub

<h3>Connector</h3>
 1. Connect with token
 2. Authenticate client
 3. Update online/offline status of client into Redis

<h3>Redis</h3>
 1. Tokens (Type: string, K/V: token/uid, TTL: 12h)
 2. Users (Type: hash, K/V: uid/{online, nickname, avatar etc.}, TTL: 7d)
 3. Channels (Type: set, K/V: cid/uids, TTL: EVER)
 4. Connectors: 
 5. Connector Queue: (Type: list, K/V: connector_id/messages)
 6. Device bindings

<h3>Hub API</h3>
 1. Token
    * NewToken
    * RefreshToken
    * RevokeToken
 2. Push
    * ToUser
    * ToChannel
 3. Channel
    * NewChannel
    * AddMember
    * RemoveMember
    * Members
 4. 


{'fraction_non_alphanumeric': 0.14254021075984472, 'fraction_numerical': 0.04547975596228508, 'mean_word_length': 3.053932584269663, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5987870', 'n_tokens_mistral': 762, 'n_tokens_neox': 693, 'n_words': 209}