scribe-rb 2.2.rc4 → 2.2.rc5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,12 @@ require "thread"
2
2
 
3
3
  module FacebookService
4
4
  class QueuedLogMessageHandler < BaseHandler
5
- attr_reader :queue
5
+ attr_reader :queue
6
+
7
+ # If message_limit is exceeded, the handler will not accept any more
8
+ # messages from Scribe. The messages will be kept by Scribe and sent
9
+ # later.
10
+ attr_accessor :message_limit
6
11
 
7
12
  def initialize(name)
8
13
  super(name)
@@ -11,11 +16,15 @@ module FacebookService
11
16
  end
12
17
 
13
18
  def Log(messages)
14
- messages.each do |message|
15
- @queue.push(message)
16
- end
19
+ if self.message_limit.nil? || self.queue.size < self.message_limit
20
+ messages.each do |message|
21
+ self.queue.push(message)
22
+ end
17
23
 
18
- ::ResultCode::OK
24
+ ::ResultCode::OK
25
+ else
26
+ ::ResultCode::TRY_LATER
27
+ end
19
28
  rescue Exception => e
20
29
  ::ResultCode::TRY_LATER
21
30
  end
data/scribe-rb.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "scribe-rb"
6
- s.version = "2.2.rc4"
6
+ s.version = "2.2.rc5"
7
7
  s.authors = ["Andy Lindeman"]
8
8
  s.email = ["andy@highgroove.com"]
9
9
  s.homepage = "http://github.com/highgroove/scribe-rb"
@@ -20,4 +20,20 @@ describe FacebookService::QueuedLogMessageHandler do
20
20
  subject.Log(["foo"]).should eq(ResultCode::OK)
21
21
  end
22
22
  end
23
+
24
+ context "with message limit" do
25
+ it "accepts messages and returns ResultCode::OK if the size limit is not exceeded" do
26
+ subject.message_limit = 1
27
+
28
+ subject.Log(["foo"]).should eq(ResultCode::OK)
29
+ subject.queue.size.should eq(1)
30
+ end
31
+
32
+ it "does not accept messages and returns ResultCode::TRY_LATER if the size limit is exceeded" do
33
+ subject.message_limit = 0
34
+
35
+ subject.Log(["foo"]).should eq(ResultCode::TRY_LATER)
36
+ subject.queue.size.should be_zero
37
+ end
38
+ end
23
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scribe-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.rc4
4
+ version: 2.2.rc5
5
5
  prerelease: 4
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-09-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thrift
16
- requirement: &2156662740 !ruby/object:Gem::Requirement
16
+ requirement: &2156647800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.7.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156662740
24
+ version_requirements: *2156647800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &2156662140 !ruby/object:Gem::Requirement
27
+ requirement: &2156647060 !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: :development
34
34
  prerelease: false
35
- version_requirements: *2156662140
35
+ version_requirements: *2156647060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2156661320 !ruby/object:Gem::Requirement
38
+ requirement: &2156645840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.6.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2156661320
46
+ version_requirements: *2156645840
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: timecop
49
- requirement: &2156660580 !ruby/object:Gem::Requirement
49
+ requirement: &2156645080 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2156660580
57
+ version_requirements: *2156645080
58
58
  description: Everything you need to build a Ruby producer/client or consumer/server
59
59
  of Scribe messages
60
60
  email:
@@ -98,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  segments:
100
100
  - 0
101
- hash: -57725399886143313
101
+ hash: -3771262154631515498
102
102
  required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  none: false
104
104
  requirements: