Skip to content

Instantly share code, notes, and snippets.

@kzk
Created November 27, 2011 14:18
Show Gist options
  • Save kzk/1397615 to your computer and use it in GitHub Desktop.
Save kzk/1397615 to your computer and use it in GitHub Desktop.
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)
<source>
type counter
port 1463
</source>
<match counter.**>
type counter
mongo_host localhost
mongo_port 27017
mongo_database counter
mongo_collection minutely
</match>
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);
}
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