scribe-rb 2.2.rc1 → 2.2.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -7,7 +7,7 @@ from generic *.thrift files.
7
7
  This gem tries to alleviate that slight annoyance and package everything
8
8
  you need to communicate with Scribe.
9
9
 
10
- ## Usage
10
+ ## Installation
11
11
 
12
12
  Add to Gemfile:
13
13
 
@@ -15,7 +15,7 @@ Add to Gemfile:
15
15
  gem 'scribe-rb'
16
16
  ```
17
17
 
18
- Talk to Scribe:
18
+ ## Producer (Client)
19
19
 
20
20
  ```ruby
21
21
  # Setup
@@ -35,6 +35,35 @@ client.Log([log_entry])
35
35
  transport.close
36
36
  ```
37
37
 
38
+ ## Consumer (Server)
39
+
40
+ ```ruby
41
+ # Define a handler that inherits from FacebookService::BaseHandler
42
+ class MyScribeHandler < FacebookService::BaseHandler
43
+ def Log(messages)
44
+ # messages will be an array of LogEntry instances from Scribe
45
+
46
+ # must return either ResultCode::OK or ResultCode::TRY_LATER
47
+ ResultCode::OK
48
+ end
49
+ end
50
+
51
+ # The rest is boilerplate
52
+ handler = MyScribeHandler.new("My Scribe Handler")
53
+ processor = Scribe::Processor.new(handler)
54
+
55
+ transport = Thrift::ServerSocket.new(5678) # 5678 is port number
56
+
57
+ transportFactory = Thrift::FramedTransportFactory.new
58
+ protocolFactory = Thrift::NonStrictBinaryProtocolFactory.new
59
+
60
+ # Other server options exist; check Thrift documentation for details
61
+ server = Thrift::SimpleServer.new(processor, transport, transportFactory, protocolFactory)
62
+
63
+ # Blocks thread and runs until process is stopped
64
+ server.serve
65
+ ```
66
+
38
67
  ## Hat Tips
39
68
 
40
69
  * [Installing and Using Scribe with Ruby on Mac OS](http://kpumuk.info/development/installing-and-using-scribe-with-ruby-on-mac-os/)
@@ -0,0 +1,61 @@
1
+ module FacebookService
2
+ # TODO: Not thread safe
3
+ class BaseHandler
4
+ def initialize(name)
5
+ @name = name
6
+ @alive = Time.now.to_i
7
+ @counters = Hash.new { |h, k| h[k] = 0 }
8
+ @options = Hash.new
9
+ end
10
+
11
+ def getName
12
+ @name
13
+ end
14
+
15
+ def getVersion
16
+ ""
17
+ end
18
+
19
+ def getStatus
20
+ Fb_status::ALIVE
21
+ end
22
+
23
+ def getStatusDetails
24
+ ""
25
+ end
26
+
27
+ def getCounters
28
+ @counters
29
+ end
30
+
31
+ def getCounter(key)
32
+ @counters[key]
33
+ end
34
+
35
+ def setOption(key, value)
36
+ @options[key] = value
37
+ end
38
+
39
+ def getOption(key)
40
+ @options[key]
41
+ end
42
+
43
+ def getOptions
44
+ @options
45
+ end
46
+
47
+ def getCpuProfile(*)
48
+ ""
49
+ end
50
+
51
+ def aliveSince
52
+ @alive
53
+ end
54
+
55
+ def reinitialize
56
+ end
57
+
58
+ def shutdown
59
+ end
60
+ end
61
+ end
data/lib/scribe-rb.rb CHANGED
@@ -1 +1,3 @@
1
1
  require File.join(File.dirname(__FILE__), "scribe")
2
+ require File.join(File.dirname(__FILE__), "facebook_base_handler")
3
+ require File.join(File.dirname(__FILE__), "thrift_extras")
@@ -0,0 +1,10 @@
1
+ # For some reason, strict_read and strict_write need to be disabled to
2
+ # receive messages from Scribe. The basic Thrift library generated for
3
+ # Ruby does not appear to easily allow that.
4
+ module Thrift
5
+ class NonStrictBinaryProtocolFactory < BinaryProtocolFactory
6
+ def get_protocol(trans)
7
+ return Thrift::BinaryProtocol.new(trans, false, false)
8
+ end
9
+ end
10
+ 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.rc1"
6
+ s.version = "2.2.rc2"
7
7
  s.authors = ["Andy Lindeman"]
8
8
  s.email = ["andy@highgroove.com"]
9
9
  s.homepage = "http://github.com/highgroove/scribe-rb"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scribe-rb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15424215
4
+ hash: 15424209
5
5
  prerelease: 4
6
6
  segments:
7
7
  - 2
8
8
  - 2
9
9
  - rc
10
- - 1
11
- version: 2.2.rc1
10
+ - 2
11
+ version: 2.2.rc2
12
12
  platform: ruby
13
13
  authors:
14
14
  - Andy Lindeman
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-09-08 00:00:00 Z
19
+ date: 2011-09-09 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -62,6 +62,7 @@ files:
62
62
  - Gemfile
63
63
  - README.md
64
64
  - Rakefile
65
+ - lib/facebook_base_handler.rb
65
66
  - lib/facebook_service.rb
66
67
  - lib/fb303_constants.rb
67
68
  - lib/fb303_types.rb
@@ -69,6 +70,7 @@ files:
69
70
  - lib/scribe.rb
70
71
  - lib/scribe_constants.rb
71
72
  - lib/scribe_types.rb
73
+ - lib/thrift_extras.rb
72
74
  - scribe-rb.gemspec
73
75
  homepage: http://github.com/highgroove/scribe-rb
74
76
  licenses: []