barnyard_logger 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module BarnyardLogger
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -5,8 +5,10 @@ require "crack"
5
5
  require "aws-sdk"
6
6
  require "uuid"
7
7
  require "json"
8
+ require "bunny"
8
9
 
9
10
  module BarnyardLogger
11
+
10
12
  class Logs
11
13
 
12
14
  def initialize(args)
@@ -14,26 +16,35 @@ module BarnyardLogger
14
16
  @debug = args.fetch(:debug) { false }
15
17
  @log = args.fetch(:logger) { Logger.new(STDOUT) }
16
18
 
17
- @sqs_settings = args.fetch(:sqs_settings) { raise "You must provide :sqs_settings" }
18
- @dynamodb_settings = args.fetch(:dynamodb_settings) { raise "You must provide :dynamodb_settings" }
19
19
  @cachecow_settings = args.fetch(:cachecow_settings) { raise "You must provide :cachecow_settings" }
20
20
 
21
21
  @cachecow = BarnyardCcfeeder::CacheCow.new(@cachecow_settings)
22
22
 
23
- @sqs = AWS::SQS.new(@sqs_settings)
24
-
25
- @changes_queue = @sqs.queues.create("barnyard-changes")
26
- @transaction_queue = @sqs.queues.create("barnyard-transactions")
27
- @harvests_queue = @sqs.queues.create("barnyard-harvests")
23
+ @q = BarnyardHarvester::GenericQueue.new(args)
24
+
25
+ #@debug = args.fetch(:debug) { false }
26
+ #@log = args.fetch(:logger) { Logger.new(STDOUT) }
27
+ #
28
+ #@sqs_settings = args.fetch(:sqs_settings) { raise "You must provide :sqs_settings" }
29
+ #@dynamodb_settings = args.fetch(:dynamodb_settings) { raise "You must provide :dynamodb_settings" }
30
+ #@cachecow_settings = args.fetch(:cachecow_settings) { raise "You must provide :cachecow_settings" }
31
+ #
32
+ #@cachecow = BarnyardCcfeeder::CacheCow.new(@cachecow_settings)
33
+ #
34
+ #@sqs = AWS::SQS.new(@sqs_settings)
35
+ #
36
+ #@changes_queue = @sqs.queues.create("barnyard-changes")
37
+ #@transaction_queue = @sqs.queues.create("barnyard-transactions")
38
+ #@harvests_queue = @sqs.queues.create("barnyard-harvests")
28
39
 
29
40
  end
30
41
 
31
42
 
32
43
  def process_harvests
33
44
 
34
- while (msg = @harvests_queue.receive_message) do
45
+ while (msg = @q.pop("barnyard-harvests")) do
35
46
 
36
- payload = Crack::JSON.parse(msg.body)
47
+ payload = Crack::JSON.parse(msg)
37
48
 
38
49
  begin
39
50
  @cachecow.push_harvester_stats(payload['harvester_uuid'],
@@ -44,9 +55,8 @@ module BarnyardLogger
44
55
  payload['change_count'],
45
56
  payload['add_count'],
46
57
  payload['delete_count'])
47
- msg.delete
48
58
 
49
- rescue e
59
+ rescue Exception => e
50
60
  $stderr.puts e
51
61
  end
52
62
 
@@ -56,9 +66,9 @@ module BarnyardLogger
56
66
 
57
67
  def process_changes
58
68
 
59
- while (msg = @changes_queue.receive_message) do
69
+ while (msg = @q.pop("barnyard-changes")) do
60
70
 
61
- payload = Crack::JSON.parse(msg.body)
71
+ payload = Crack::JSON.parse(msg)
62
72
 
63
73
  begin
64
74
  @cachecow.push_change(payload['queued_at'],
@@ -69,9 +79,8 @@ module BarnyardLogger
69
79
  payload['transaction_type'],
70
80
  payload['value'],
71
81
  payload['old_value'])
72
- msg.delete
73
82
 
74
- rescue e
83
+ rescue Exception => e
75
84
  $stderr.puts e
76
85
  end
77
86
 
@@ -80,19 +89,17 @@ module BarnyardLogger
80
89
 
81
90
  def process_transactions
82
91
 
83
- while (msg = @transaction_queue.receive_message) do
92
+ while (msg = @q.pop("barnyard-transactions")) do
84
93
 
85
- payload = Crack::JSON.parse(msg.body)
94
+ payload = Crack::JSON.parse(msg)
86
95
 
87
- # subscription_id, queued_at, $change_uuid, $transaction_uuid
88
96
  begin
89
97
  @cachecow.push_transaction(payload['subscription_id'],
90
98
  payload['queued_at'],
91
99
  payload['change_uuid'],
92
100
  payload['transaction_uuid'])
93
- msg.delete
94
101
 
95
- rescue e
102
+ rescue Exception => e
96
103
  $stderr.puts e
97
104
  end
98
105
 
data/spec/changes_spec.rb CHANGED
@@ -13,10 +13,22 @@ SQS_SETTINGS = {
13
13
  :secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
14
14
  }
15
15
 
16
+ REDIS_SETTINGS = {
17
+ :host => "localhost",
18
+ :port => 6379
19
+ }
20
+
21
+ RABBITMQ_SETTINGS = {
22
+ :host => "localhost"
23
+ # :port => 6163
24
+ }
25
+
16
26
  CACHECOW_SETTINGS = {
17
- :url => "http://localhost:3000"
27
+ #:url => "http://localhost:3000"
28
+ :url => "https://cachecow.c.qaapollogrp.edu"
18
29
  }
19
30
 
31
+
20
32
  describe "i should" do
21
33
 
22
34
  it "should work" do
@@ -24,14 +36,21 @@ describe "i should" do
24
36
  my_logger = Logger.new(STDOUT)
25
37
  my_logger.level = Logger::DEBUG
26
38
 
27
- l = BarnyardLogger::Logs.new(:queueing => :sqs,
28
- :sqs_settings => SQS_SETTINGS,
29
- :backend => :dynamodb,
39
+ l = BarnyardLogger::Logs.new(:queueing => :rabbitmq,
40
+ :rabbitmq_settings => RABBITMQ_SETTINGS,
30
41
  :debug => true,
31
- :dynamodb_settings => DYNAMODB_SETTINGS,
42
+ :redis_settings => REDIS_SETTINGS,
32
43
  :cachecow_settings => CACHECOW_SETTINGS,
33
44
  :logger => my_logger)
34
45
 
46
+ #l = BarnyardLogger::Logs.new(:queueing => :sqs,
47
+ # :sqs_settings => SQS_SETTINGS,
48
+ # :backend => :dynamodb,
49
+ # :debug => true,
50
+ # :dynamodb_settings => DYNAMODB_SETTINGS,
51
+ # :cachecow_settings => CACHECOW_SETTINGS,
52
+ # :logger => my_logger)
53
+
35
54
  l.process_changes
36
55
 
37
56
 
@@ -13,8 +13,19 @@ SQS_SETTINGS = {
13
13
  :secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
14
14
  }
15
15
 
16
+ REDIS_SETTINGS = {
17
+ :host => "localhost",
18
+ :port => 6379
19
+ }
20
+
21
+ RABBITMQ_SETTINGS = {
22
+ :host => "localhost"
23
+ # :port => 6163
24
+ }
25
+
16
26
  CACHECOW_SETTINGS = {
17
- :url => "http://localhost:3000"
27
+ #:url => "http://localhost:3000"
28
+ :url => "https://cachecow.c.qaapollogrp.edu"
18
29
  }
19
30
 
20
31
  describe "i should" do
@@ -24,14 +35,21 @@ describe "i should" do
24
35
  my_logger = Logger.new(STDOUT)
25
36
  my_logger.level = Logger::DEBUG
26
37
 
27
- l = BarnyardLogger::Logs.new(:queueing => :sqs,
28
- :sqs_settings => SQS_SETTINGS,
29
- :backend => :dynamodb,
38
+ #l = BarnyardLogger::Logs.new(:queueing => :sqs,
39
+ # :sqs_settings => SQS_SETTINGS,
40
+ # :backend => :dynamodb,
41
+ # :debug => true,
42
+ # :dynamodb_settings => DYNAMODB_SETTINGS,
43
+ # :cachecow_settings => CACHECOW_SETTINGS,
44
+ # :logger => my_logger)
45
+ l = BarnyardLogger::Logs.new(:queueing => :rabbitmq,
46
+ :rabbitmq_settings => RABBITMQ_SETTINGS,
30
47
  :debug => true,
31
- :dynamodb_settings => DYNAMODB_SETTINGS,
48
+ :redis_settings => REDIS_SETTINGS,
32
49
  :cachecow_settings => CACHECOW_SETTINGS,
33
50
  :logger => my_logger)
34
51
 
52
+
35
53
  l.process_harvests
36
54
 
37
55
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barnyard_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-30 00:00:00.000000000 Z
12
+ date: 2012-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70221620950100 !ruby/object:Gem::Requirement
16
+ requirement: &70273676284260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70221620950100
24
+ version_requirements: *70273676284260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: aws-sdk
27
- requirement: &70221620949600 !ruby/object:Gem::Requirement
27
+ requirement: &70273676282780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70221620949600
35
+ version_requirements: *70273676282780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: barnyard_ccfeeder
38
- requirement: &70221620948980 !ruby/object:Gem::Requirement
38
+ requirement: &70273676281880 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70221620948980
46
+ version_requirements: *70273676281880
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: barnyard_harvester
49
- requirement: &70221620947920 !ruby/object:Gem::Requirement
49
+ requirement: &70273680394060 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70221620947920
57
+ version_requirements: *70273680394060
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: crack
60
- requirement: &70221620947440 !ruby/object:Gem::Requirement
60
+ requirement: &70273680391980 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70221620947440
68
+ version_requirements: *70273680391980
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: uuid
71
- requirement: &70221620946760 !ruby/object:Gem::Requirement
71
+ requirement: &70273680388520 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70221620946760
79
+ version_requirements: *70273680388520
80
80
  description: Deliver subscriptions to queues.
81
81
  email:
82
82
  - supercoder@gmail.com