right_support 1.4.1 → 2.0.0
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.rdoc +94 -68
- data/lib/right_support.rb +1 -1
- data/lib/right_support/{config.rb → data.rb} +4 -6
- data/lib/right_support/data/uuid.rb +175 -0
- data/lib/right_support/log.rb +0 -1
- data/lib/right_support/log/system_logger.rb +1 -1
- data/lib/right_support/net.rb +1 -1
- data/lib/right_support/net/http_client.rb +118 -32
- data/lib/right_support/net/{balancing.rb → lb.rb} +4 -4
- data/lib/right_support/net/{balancing → lb}/health_check.rb +1 -1
- data/lib/right_support/net/{balancing → lb}/round_robin.rb +1 -1
- data/lib/right_support/net/{balancing/sticky_policy.rb → lb/sticky.rb} +2 -3
- data/lib/right_support/net/request_balancer.rb +1 -1
- data/lib/right_support/rack.rb +2 -1
- data/lib/right_support/rack/{custom_logger.rb → log_setter.rb} +21 -33
- data/lib/right_support/rack/request_logger.rb +47 -21
- data/lib/right_support/{config/recursive_true_class.rb → rack/request_tracker.rb} +33 -33
- data/lib/right_support/ruby/object_extensions.rb +0 -22
- data/lib/right_support/stats/helpers.rb +36 -65
- data/lib/right_support/validation/ssh.rb +2 -2
- data/right_support.gemspec +3 -3
- metadata +15 -16
- data/lib/right_support/config/feature_set.rb +0 -95
- data/lib/right_support/config/yaml_config.rb +0 -62
- data/lib/right_support/log/tag_logger.rb +0 -72
@@ -20,7 +20,7 @@
|
|
20
20
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
|
23
|
-
|
23
|
+
if require_succeeds?('net/ssh')
|
24
24
|
module RightSupport::Validation
|
25
25
|
# Validation methods pertaining to the Secure Shell (SSH) protocol.
|
26
26
|
module SSH
|
@@ -68,4 +68,4 @@ if_require_succeeds('net/ssh') do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
71
|
-
end
|
71
|
+
end
|
data/right_support.gemspec
CHANGED
@@ -7,10 +7,10 @@ spec = Gem::Specification.new do |s|
|
|
7
7
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
8
8
|
|
9
9
|
s.name = 'right_support'
|
10
|
-
s.version = '
|
11
|
-
s.date = '2012-
|
10
|
+
s.version = '2.0.0'
|
11
|
+
s.date = '2012-03-23'
|
12
12
|
|
13
|
-
s.authors = ['Tony Spataro', 'Sergey Sergyenko', 'Ryan Williamson', 'Lee Kirchhoff']
|
13
|
+
s.authors = ['Tony Spataro', 'Sergey Sergyenko', 'Ryan Williamson', 'Lee Kirchhoff', 'Sergey Enin']
|
14
14
|
s.email = 'support@rightscale.com'
|
15
15
|
s.homepage= 'https://github.com/rightscale/right_support'
|
16
16
|
|
metadata
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tony Spataro
|
14
14
|
- Sergey Sergyenko
|
15
15
|
- Ryan Williamson
|
16
16
|
- Lee Kirchhoff
|
17
|
+
- Sergey Enin
|
17
18
|
autorequire:
|
18
19
|
bindir: bin
|
19
20
|
cert_chain: []
|
20
21
|
|
21
|
-
date: 2012-
|
22
|
+
date: 2012-03-23 00:00:00 -07:00
|
22
23
|
default_executable:
|
23
24
|
dependencies: []
|
24
25
|
|
@@ -34,12 +35,10 @@ files:
|
|
34
35
|
- LICENSE
|
35
36
|
- README.rdoc
|
36
37
|
- lib/right_support.rb
|
37
|
-
- lib/right_support/config.rb
|
38
|
-
- lib/right_support/config/feature_set.rb
|
39
|
-
- lib/right_support/config/recursive_true_class.rb
|
40
|
-
- lib/right_support/config/yaml_config.rb
|
41
38
|
- lib/right_support/crypto.rb
|
42
39
|
- lib/right_support/crypto/signed_hash.rb
|
40
|
+
- lib/right_support/data.rb
|
41
|
+
- lib/right_support/data/uuid.rb
|
43
42
|
- lib/right_support/db.rb
|
44
43
|
- lib/right_support/db/cassandra_model.rb
|
45
44
|
- lib/right_support/log.rb
|
@@ -49,22 +48,22 @@ files:
|
|
49
48
|
- lib/right_support/log/multiplexer.rb
|
50
49
|
- lib/right_support/log/null_logger.rb
|
51
50
|
- lib/right_support/log/system_logger.rb
|
52
|
-
- lib/right_support/log/tag_logger.rb
|
53
51
|
- lib/right_support/net.rb
|
54
52
|
- lib/right_support/net/address_helper.rb
|
55
|
-
- lib/right_support/net/balancing.rb
|
56
|
-
- lib/right_support/net/balancing/health_check.rb
|
57
|
-
- lib/right_support/net/balancing/round_robin.rb
|
58
|
-
- lib/right_support/net/balancing/sticky_policy.rb
|
59
53
|
- lib/right_support/net/dns.rb
|
60
54
|
- lib/right_support/net/http_client.rb
|
55
|
+
- lib/right_support/net/lb.rb
|
56
|
+
- lib/right_support/net/lb/health_check.rb
|
57
|
+
- lib/right_support/net/lb/round_robin.rb
|
58
|
+
- lib/right_support/net/lb/sticky.rb
|
61
59
|
- lib/right_support/net/request_balancer.rb
|
62
60
|
- lib/right_support/net/ssl.rb
|
63
61
|
- lib/right_support/net/ssl/open_ssl_patch.rb
|
64
62
|
- lib/right_support/net/string_encoder.rb
|
65
63
|
- lib/right_support/rack.rb
|
66
|
-
- lib/right_support/rack/
|
64
|
+
- lib/right_support/rack/log_setter.rb
|
67
65
|
- lib/right_support/rack/request_logger.rb
|
66
|
+
- lib/right_support/rack/request_tracker.rb
|
68
67
|
- lib/right_support/ruby.rb
|
69
68
|
- lib/right_support/ruby/easy_singleton.rb
|
70
69
|
- lib/right_support/ruby/object_extensions.rb
|
@@ -1,95 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2012 RightScale Inc
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
|
23
|
-
module RightSupport::Config
|
24
|
-
|
25
|
-
# Returns new instance of FeatureSet class,
|
26
|
-
# with loaded from config_source configuration
|
27
|
-
#
|
28
|
-
# === Parameters
|
29
|
-
# config_source(IO|String):: File` path, IO or raw yaml.
|
30
|
-
#
|
31
|
-
# === Return
|
32
|
-
# (FeatureSet):: new instance of FeatureSet class
|
33
|
-
def self.features(config_source)
|
34
|
-
return FeatureSet.new(config_source)
|
35
|
-
end
|
36
|
-
|
37
|
-
class FeatureSet
|
38
|
-
|
39
|
-
attr_accessor :configuration_source
|
40
|
-
attr_accessor :configuration
|
41
|
-
|
42
|
-
# Create features configuration object
|
43
|
-
#
|
44
|
-
# === Parameters
|
45
|
-
# cfg_source(IO|String):: File path, IO or raw yaml.
|
46
|
-
def initialize(cfg_source)
|
47
|
-
@configuration = load(cfg_source)
|
48
|
-
end
|
49
|
-
|
50
|
-
# Returns configuration value
|
51
|
-
#
|
52
|
-
# === Parameters
|
53
|
-
# feature_group(String):: Feature group name
|
54
|
-
# feature(String|nil):: Feature name
|
55
|
-
#
|
56
|
-
# === Return
|
57
|
-
# (String|Boolean):: Configuration value
|
58
|
-
def [](feature_group, feature=nil)
|
59
|
-
return_value = true
|
60
|
-
if @configuration[feature_group]
|
61
|
-
if feature == nil
|
62
|
-
return_value = @configuration[feature_group]
|
63
|
-
else
|
64
|
-
return_value = @configuration[feature_group][feature]
|
65
|
-
end
|
66
|
-
else
|
67
|
-
return_value = RecursiveTrueClass.new
|
68
|
-
end
|
69
|
-
return_value = true if return_value == nil
|
70
|
-
return_value
|
71
|
-
end
|
72
|
-
|
73
|
-
# Load configuration source
|
74
|
-
#
|
75
|
-
# === Parameters
|
76
|
-
# something(IO|String|Hash):: File path, IO, raw YAML string, or a pre-loaded Hash
|
77
|
-
#
|
78
|
-
# === Return
|
79
|
-
# (Hash|nil):: Loaded yaml file
|
80
|
-
#
|
81
|
-
# === Raise
|
82
|
-
# (ArgumentError):: If configuration source can`t be loaded
|
83
|
-
def load(something)
|
84
|
-
return_value = nil
|
85
|
-
@configuration_source = something
|
86
|
-
raise ArgumentError, "Can't coerce #{something} into YAML/Hash" unless (return_value = YAMLConfig.read(something))
|
87
|
-
return_value
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
# Temporary alias for FeatureSet class, to avoid disrupting downstream development
|
93
|
-
Feature = FeatureSet
|
94
|
-
|
95
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2012 RightScale Inc
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
require 'yaml'
|
23
|
-
|
24
|
-
module RightSupport::Config
|
25
|
-
|
26
|
-
# Helper that encapsulates logic for loading YAML configuration hashes from various sources
|
27
|
-
# which can include strings, IO objects, or already-loaded YAML in the form of a Hash.
|
28
|
-
module YAMLConfig
|
29
|
-
|
30
|
-
class << self
|
31
|
-
|
32
|
-
# Load yaml source
|
33
|
-
#
|
34
|
-
# === Parameters
|
35
|
-
# something(IO|String|Hash):: File path, IO, raw YAML string, or a pre-loaded Hash
|
36
|
-
#
|
37
|
-
# === Returns
|
38
|
-
# (Boolean|Hash):: Loaded yaml file or false if a RuntimeError occurred while loading
|
39
|
-
def read(something)
|
40
|
-
return_value = false
|
41
|
-
|
42
|
-
begin
|
43
|
-
if something.kind_of?(Hash)
|
44
|
-
return_value = something
|
45
|
-
elsif File.exists?(something)
|
46
|
-
return_value = YAML.load_file(something)
|
47
|
-
else
|
48
|
-
return_value = YAML.load(something)
|
49
|
-
end
|
50
|
-
raise unless return_value.kind_of?(Hash)
|
51
|
-
rescue
|
52
|
-
return_value = false
|
53
|
-
end
|
54
|
-
|
55
|
-
return_value
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2011 RightScale Inc
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'logger'
|
24
|
-
|
25
|
-
module RightSupport::Log
|
26
|
-
# A logger that prepends a tag to every message that is emitted. Can be used to
|
27
|
-
# correlate logs with a Web session ID, transaction ID or other context.
|
28
|
-
#
|
29
|
-
# The user of this logger is responsible for calling #tag= to set the tag as
|
30
|
-
# appropriate, e.g. in a Web request around-filter.
|
31
|
-
#
|
32
|
-
# This logger uses thread-local storage (TLS) to provide tagging on a per-thread
|
33
|
-
# basis; however, it does not account for EventMachine, neverblock, the use of
|
34
|
-
# Ruby fibers, or any other phenomenon that can "hijack" a thread's call stack.
|
35
|
-
#
|
36
|
-
class TagLogger < FilterLogger
|
37
|
-
# Prepend the current tag to the log message; return the same severity and
|
38
|
-
# the modified message.
|
39
|
-
#
|
40
|
-
# === Parameters
|
41
|
-
# severity(Integer):: one of the severity constants defined by Logger
|
42
|
-
# messgae(String):: the log message
|
43
|
-
#
|
44
|
-
# === Return
|
45
|
-
# Returns a pair consisting of the filtered [severity, message].
|
46
|
-
#
|
47
|
-
def filter(severity, message)
|
48
|
-
@tls_id ||= "tag_logger_#{self.object_id}"
|
49
|
-
tag = Thread.current[@tls_id] || ''
|
50
|
-
if tag
|
51
|
-
return [severity, tag + message]
|
52
|
-
else
|
53
|
-
return [severity, message]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
attr_reader :tag
|
58
|
-
|
59
|
-
# Set the tag for this logger.
|
60
|
-
#
|
61
|
-
# === Parameters
|
62
|
-
# tag(String|nil):: the new tag, or nil to remove the tag
|
63
|
-
#
|
64
|
-
# === Return
|
65
|
-
# String:: returns the new tag
|
66
|
-
def tag=(tag)
|
67
|
-
@tag = tag
|
68
|
-
@tls_id ||= "tag_logger_#{self.object_id}"
|
69
|
-
Thread.current[@tls_id] = @tag
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|