my_stuff-fb303 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
@@ -16,6 +16,23 @@ module MyStuff
|
|
16
16
|
rescue => e
|
17
17
|
@s.increment_counter "#{meth}.exception"
|
18
18
|
@s.increment_counter "#{meth}.exception.#{e.class.name}"
|
19
|
+
|
20
|
+
if e.is_a? Thrift::Exception
|
21
|
+
# Presumably defined in the Thrift interface file
|
22
|
+
level = :warn
|
23
|
+
else
|
24
|
+
# Definitely not :(
|
25
|
+
level = :error
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
# MyStuff::Logger exception, allowing us to specify the
|
30
|
+
# backtrace.
|
31
|
+
@s.logger.raw_log e.backtrace, level, e
|
32
|
+
rescue NoMethoderror
|
33
|
+
@s.logger.send level, e
|
34
|
+
end
|
35
|
+
|
19
36
|
raise
|
20
37
|
end
|
21
38
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Copyright 2011-present Fred Emmott. See COPYING file.
|
2
|
+
|
3
|
+
# Monkey-patch Thrift::Processor to not completely bail on undefined
|
4
|
+
# exceptions.
|
5
|
+
|
6
|
+
module MyStuff
|
7
|
+
module Fb303
|
8
|
+
module ResilientProcessor
|
9
|
+
class SpyIProt
|
10
|
+
def initialize iprot
|
11
|
+
@iprot = iprot
|
12
|
+
@mode = :capture
|
13
|
+
end
|
14
|
+
|
15
|
+
def read_message_begin
|
16
|
+
case @mode
|
17
|
+
when :capture
|
18
|
+
@header = @iprot.read_message_begin
|
19
|
+
@mode = :replay
|
20
|
+
@header
|
21
|
+
when :replay
|
22
|
+
@mode = :normal
|
23
|
+
@header
|
24
|
+
when :normal
|
25
|
+
@iprot.read_message_begin
|
26
|
+
else
|
27
|
+
raise "Reached a bad state: %s" % @mode
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def method_missing *args
|
32
|
+
@iprot.send *args
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def resilient_process iprot, oprot
|
37
|
+
spy = SpyIProt.new(iprot)
|
38
|
+
name, type, seqid = spy.read_message_begin
|
39
|
+
|
40
|
+
begin
|
41
|
+
unresilient_process(spy, oprot)
|
42
|
+
rescue => e
|
43
|
+
ae = Thrift::ApplicationException.new(
|
44
|
+
Thrift::ApplicationException::UNKNOWN,
|
45
|
+
e.inspect
|
46
|
+
)
|
47
|
+
oprot.write_message_begin(name, Thrift::MessageTypes::EXCEPTION, seqid)
|
48
|
+
ae.write oprot
|
49
|
+
oprot.write_message_end
|
50
|
+
oprot.trans.flush
|
51
|
+
false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.extended other
|
56
|
+
class <<other
|
57
|
+
alias :unresilient_process :process
|
58
|
+
alias :process :resilient_process
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -57,8 +57,12 @@ module MyStuff
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def method_missing *args
|
60
|
+
unless self.getStatus == Fb_status::ALIVE
|
61
|
+
raise 'Handler unavailable in current status.'
|
62
|
+
end
|
63
|
+
|
60
64
|
if self.handler != self
|
61
|
-
|
65
|
+
self.handler.send *args
|
62
66
|
else
|
63
67
|
super *args
|
64
68
|
end
|
metadata
CHANGED
@@ -1,62 +1,79 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_stuff-fb303
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 7
|
9
|
+
version: 0.0.7
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Fred Emmott
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
|
17
|
+
date: 2011-09-04 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: thrift
|
16
|
-
requirement: &70167224791480 !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
25
32
|
description: Basic implementation of fb303 for Ruby services
|
26
|
-
email:
|
33
|
+
email:
|
27
34
|
- mail@fredemmott.co.uk
|
28
35
|
executables: []
|
36
|
+
|
29
37
|
extensions: []
|
38
|
+
|
30
39
|
extra_rdoc_files: []
|
31
|
-
|
40
|
+
|
41
|
+
files:
|
32
42
|
- COPYING
|
33
43
|
- README.rdoc
|
34
44
|
- lib/my_stuff/fb303/proxy_handler.rb
|
45
|
+
- lib/my_stuff/fb303/resilient_processor.rb
|
35
46
|
- lib/my_stuff/fb303/server.rb
|
36
47
|
- lib/my_stuff/fb303_server.rb
|
48
|
+
has_rdoc: true
|
37
49
|
homepage: https://github.com/fredemmott/my_stuff-fb303
|
38
|
-
licenses:
|
50
|
+
licenses:
|
39
51
|
- ISC
|
40
52
|
post_install_message:
|
41
53
|
rdoc_options: []
|
42
|
-
|
54
|
+
|
55
|
+
require_paths:
|
43
56
|
- lib
|
44
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
requirements:
|
53
|
-
- -
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
56
71
|
requirements: []
|
72
|
+
|
57
73
|
rubyforge_project:
|
58
|
-
rubygems_version: 1.
|
74
|
+
rubygems_version: 1.3.6
|
59
75
|
signing_key:
|
60
76
|
specification_version: 3
|
61
77
|
summary: MyStuff.ws's Ruby fb303 implementation
|
62
78
|
test_files: []
|
79
|
+
|