Created
November 27, 2011 14:18
-
-
Save kzk/1397615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e = Event.new | |
e.timestamp = Time.now.to_i | |
e.category = 'counter.blog' | |
e.key = ['net', 'kzk9', 'blog', 'tornado'] | |
e.value = 1 | |
p client.Post(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<source> | |
type counter | |
port 1463 | |
</source> | |
<match counter.**> | |
type counter | |
mongo_host localhost | |
mongo_port 27017 | |
mongo_database counter | |
mongo_collection minutely | |
</match> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Event | |
{ | |
1: i64 timestamp, | |
2: string category, | |
3: list<string> key, | |
4: i64 value | |
} | |
enum ResultCode | |
{ | |
OK, | |
TRY_LATER | |
} | |
service Counter | |
{ | |
ResultCode Post(1: Event e); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mba% mongo | |
MongoDB shell version: 2.0.0 | |
connecting to: test | |
> use counter | |
switched to db counter | |
> db.minutely.find() | |
{ "key" : "net", "time" : "201111272327", "value" : 400 } | |
{ "key" : "net:kzk9", "time" : "201111272327", "value" : 400 } | |
{ "key" : "net:kzk9:blog", "time" : "201111272327", "value" : 400 } | |
{ "key" : "net:kzk9:blog:tornado", "time" : "201111272327", "value" : 400 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment