barnyard_logger 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ruby-1.9.3-p125@barnyard
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in barnyard_logger.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jon Gillies
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # BarnyardLogger
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'barnyard_logger'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install barnyard_logger
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/barnyard_logger/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jon Gillies"]
6
+ gem.email = ["supercoder@gmail.com"]
7
+ gem.description = %q{Deliver subscriptions to queues.}
8
+ gem.summary = %q{Help}
9
+ gem.homepage = "https://github.com/jongillies/barnyard/tree/master/barnyard_logger"
10
+
11
+ gem.rubyforge_project = "barnyard_logger"
12
+
13
+ gem.files = `git ls-files`.split($\)
14
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.name = "barnyard_logger"
17
+ gem.require_paths = ["lib"]
18
+ gem.version = BarnyardLogger::VERSION
19
+
20
+ # specify any dependencies here; for example:
21
+ gem.add_development_dependency "rspec"
22
+ gem.add_runtime_dependency "aws-sdk"
23
+ gem.add_runtime_dependency "barnyard_ccfeeder"
24
+ gem.add_runtime_dependency "barnyard_harvester"
25
+ gem.add_runtime_dependency "crack"
26
+ gem.add_runtime_dependency "uuid"
27
+
28
+
29
+ end
@@ -0,0 +1,3 @@
1
+ module BarnyardLogger
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,97 @@
1
+ require "barnyard_logger/version"
2
+
3
+ require "barnyard_logger/version"
4
+ require "barnyard_ccfeeder"
5
+ require "barnyard_harvester"
6
+ require "crack"
7
+ require "aws-sdk"
8
+ require "uuid"
9
+ require "json"
10
+
11
+ module BarnyardLogger
12
+ class Logs
13
+
14
+ def initialize(args)
15
+
16
+ @debug = args.fetch(:debug) { false }
17
+ @log = args.fetch(:logger) { Logger.new(STDOUT) }
18
+
19
+ @sqs_settings = args.fetch(:sqs_settings) { raise "You must provide :sqs_settings" }
20
+ @dynamodb_settings = args.fetch(:dynamodb_settings) { raise "You must provide :dynamodb_settings" }
21
+ @cachecow_settings = args.fetch(:cachecow_settings) { raise "You must provide :cachecow_settings" }
22
+
23
+ @cachecow = BarnyardCcfeeder::CacheCow.new(@cachecow_settings)
24
+
25
+ @sqs = AWS::SQS.new(@sqs_settings)
26
+
27
+ @changes_queue = @sqs.queues.create("barnyard-changes")
28
+ @transaction_queue = @sqs.queues.create("barnyard-transactions")
29
+ @harvests_queue = @sqs.queues.create("barnyard-harvests")
30
+
31
+ end
32
+
33
+
34
+ def process_harvests
35
+
36
+ while (msg = @harvests_queue.receive_message) do
37
+
38
+ payload = Crack::JSON.parse(msg.body)
39
+
40
+ @cachecow.push_harvester_stats(payload['harvester_uuid'],
41
+ payload['crop_number'],
42
+ payload['began_at'],
43
+ payload['ended_at'],
44
+ payload['source_count'],
45
+ payload['change_count'],
46
+ payload['add_count'],
47
+ payload['delete_count'])
48
+
49
+ end
50
+
51
+ end
52
+
53
+ def process_changes
54
+
55
+ while (msg = @changes_queue.receive_message) do
56
+
57
+ payload = Crack::JSON.parse(msg.body)
58
+
59
+ @cachecow.push_change(payload['queued_at'],
60
+ payload['harvester_uuid'],
61
+ payload['change_uuid'],
62
+ payload['crop_number'],
63
+ payload['primary_key'],
64
+ payload['transaction_type'],
65
+ payload['value'],
66
+ payload['old_value'])
67
+
68
+
69
+ end
70
+ end
71
+
72
+ def process_transactions
73
+
74
+ while (msg = @changes_queue.receive_message) do
75
+
76
+ payload = Crack::JSON.parse(msg.body)
77
+
78
+ @cachecow.push_transaction(payload['subscription_id'],
79
+ payload['queued_at'],
80
+ payload['change_uuid'],
81
+ payload['transaction_uuid'],
82
+ payload['crop_number'],
83
+ payload['primary_key'],
84
+ payload['transaction_type'],
85
+ payload['value'],
86
+ payload['old_value'])
87
+
88
+ end
89
+
90
+ end
91
+
92
+ end
93
+ end
94
+
95
+
96
+
97
+
@@ -0,0 +1,39 @@
1
+ require "rspec"
2
+ require "barnyard_logger"
3
+
4
+ DYNAMODB_SETTINGS = {
5
+ :dynamo_db_endpoint => "dynamodb.us-west-1.amazonaws.com",
6
+ :access_key_id => ENV["AWS_ACCESS_KEY_ID"],
7
+ :secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
8
+ }
9
+
10
+ SQS_SETTINGS = {
11
+ :sqs_endpoint => "sqs.us-west-1.amazonaws.com",
12
+ :access_key_id => ENV["AWS_ACCESS_KEY_ID"],
13
+ :secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
14
+ }
15
+
16
+ CACHECOW_SETTINGS = {
17
+ :url => "http://localhost:3000"
18
+ }
19
+
20
+ describe "i should" do
21
+
22
+ it "should work" do
23
+
24
+ my_logger = Logger.new(STDOUT)
25
+ my_logger.level = Logger::DEBUG
26
+
27
+ l = BarnyardLogger::Logs.new(:queueing => :sqs,
28
+ :sqs_settings => SQS_SETTINGS,
29
+ :backend => :dynamodb,
30
+ :debug => true,
31
+ :dynamodb_settings => DYNAMODB_SETTINGS,
32
+ :cachecow_settings => CACHECOW_SETTINGS,
33
+ :logger => my_logger)
34
+
35
+ l.process_changes
36
+
37
+
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ require "rspec"
2
+ require "barnyard_logger"
3
+
4
+ DYNAMODB_SETTINGS = {
5
+ :dynamo_db_endpoint => "dynamodb.us-west-1.amazonaws.com",
6
+ :access_key_id => ENV["AWS_ACCESS_KEY_ID"],
7
+ :secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
8
+ }
9
+
10
+ SQS_SETTINGS = {
11
+ :sqs_endpoint => "sqs.us-west-1.amazonaws.com",
12
+ :access_key_id => ENV["AWS_ACCESS_KEY_ID"],
13
+ :secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
14
+ }
15
+
16
+ CACHECOW_SETTINGS = {
17
+ :url => "http://localhost:3000"
18
+ }
19
+
20
+ describe "i should" do
21
+
22
+ it "should work" do
23
+
24
+ my_logger = Logger.new(STDOUT)
25
+ my_logger.level = Logger::DEBUG
26
+
27
+ l = BarnyardLogger::Logs.new(:queueing => :sqs,
28
+ :sqs_settings => SQS_SETTINGS,
29
+ :backend => :dynamodb,
30
+ :debug => true,
31
+ :dynamodb_settings => DYNAMODB_SETTINGS,
32
+ :cachecow_settings => CACHECOW_SETTINGS,
33
+ :logger => my_logger)
34
+
35
+ l.process_harvests
36
+
37
+
38
+ end
39
+ end
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
@@ -0,0 +1,38 @@
1
+ require "rspec"
2
+ require "barnyard_logger"
3
+
4
+ DYNAMODB_SETTINGS = {
5
+ :dynamo_db_endpoint => "dynamodb.us-west-1.amazonaws.com",
6
+ :access_key_id => ENV["AWS_ACCESS_KEY_ID"],
7
+ :secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
8
+ }
9
+
10
+ SQS_SETTINGS = {
11
+ :sqs_endpoint => "sqs.us-west-1.amazonaws.com",
12
+ :access_key_id => ENV["AWS_ACCESS_KEY_ID"],
13
+ :secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
14
+ }
15
+
16
+ CACHECOW_SETTINGS = {
17
+ :url => "http://localhost:3000"
18
+ }
19
+
20
+ describe "i should" do
21
+
22
+ it "should work" do
23
+
24
+ my_logger = Logger.new(STDOUT)
25
+ my_logger.level = Logger::DEBUG
26
+
27
+ l = BarnyardLogger::Logs.new(:queueing => :sqs,
28
+ :sqs_settings => SQS_SETTINGS,
29
+ :backend => :dynamodb,
30
+ :debug => true,
31
+ :dynamodb_settings => DYNAMODB_SETTINGS,
32
+ :cachecow_settings => CACHECOW_SETTINGS,
33
+ :logger => my_logger)
34
+
35
+ l.process_transactions
36
+
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: barnyard_logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jon Gillies
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70101542134500 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70101542134500
25
+ - !ruby/object:Gem::Dependency
26
+ name: aws-sdk
27
+ requirement: &70101542131340 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70101542131340
36
+ - !ruby/object:Gem::Dependency
37
+ name: barnyard_ccfeeder
38
+ requirement: &70101542130300 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70101542130300
47
+ - !ruby/object:Gem::Dependency
48
+ name: barnyard_harvester
49
+ requirement: &70101542277280 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70101542277280
58
+ - !ruby/object:Gem::Dependency
59
+ name: crack
60
+ requirement: &70101542276860 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *70101542276860
69
+ - !ruby/object:Gem::Dependency
70
+ name: uuid
71
+ requirement: &70101542276440 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: *70101542276440
80
+ description: Deliver subscriptions to queues.
81
+ email:
82
+ - supercoder@gmail.com
83
+ executables: []
84
+ extensions: []
85
+ extra_rdoc_files: []
86
+ files:
87
+ - .gitignore
88
+ - .rvmrc
89
+ - Gemfile
90
+ - LICENSE
91
+ - README.md
92
+ - Rakefile
93
+ - barnyard_logger.gemspec
94
+ - lib/barnyard_logger.rb
95
+ - lib/barnyard_logger/version.rb
96
+ - spec/changes_spec.rb
97
+ - spec/harvests_spec.rb
98
+ - spec/spec_helper.rb
99
+ - spec/transactions_spec.rb
100
+ homepage: https://github.com/jongillies/barnyard/tree/master/barnyard_logger
101
+ licenses: []
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project: barnyard_logger
120
+ rubygems_version: 1.8.11
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: Help
124
+ test_files:
125
+ - spec/changes_spec.rb
126
+ - spec/harvests_spec.rb
127
+ - spec/spec_helper.rb
128
+ - spec/transactions_spec.rb