diff options
| author | mo khan <mo@mokhan.ca> | 2015-08-15 09:52:26 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-08-15 09:52:26 -0600 |
| commit | c4db48f23817f8ad04cc631cbd45b20d3f608e06 (patch) | |
| tree | 5b4170ff029eeb727b8e69f13b3ddd5038ca9091 | |
| parent | 99833d36eb368b706d790c315732d1b55e20c940 (diff) | |
write queries to cassandra cluster.
| -rw-r--r-- | app/models/query.rb | 7 | ||||
| -rw-r--r-- | app/workers/cassandra_writer.rb | 7 | ||||
| -rwxr-xr-x | bin/setup | 1 |
3 files changed, 15 insertions, 0 deletions
diff --git a/app/models/query.rb b/app/models/query.rb new file mode 100644 index 0000000..24836dc --- /dev/null +++ b/app/models/query.rb @@ -0,0 +1,7 @@ +class Query + include Cequel::Record + + key :agent_id, :uuid + column :path, :text + column :fingerprint, :text +end diff --git a/app/workers/cassandra_writer.rb b/app/workers/cassandra_writer.rb index 0d4057a..c2f56a8 100644 --- a/app/workers/cassandra_writer.rb +++ b/app/workers/cassandra_writer.rb @@ -3,6 +3,13 @@ class CassandraWriter from_queue "worker.cassandra" def work(event_json) + attributes = JSON.parse(event_json) + + Query.create!( + agent_id: attributes['agent_id'], + path: attributes['data']['path'], + fingerprint: attributes["data"]["fingerprint"], + ) ack! end end @@ -37,4 +37,5 @@ Dir.chdir APP_ROOT do puts "\n== Preparing cassandra ==" system "bin/rake cequel:keyspace:create" + system "bin/rake cequel:migrate" end |
