saddle 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/saddle/endpoint.rb +18 -7
- data/lib/saddle/method_tree_builder.rb +4 -3
- data/lib/saddle/middleware/logging/statsd.rb +7 -2
- data/lib/saddle/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
M2YwNjAwMDc5ODM3M2JlMDE0NGU5ZWRiYTlhN2FhZmNkYTNjNWE2Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDIzODc3NjJmYmFhNTlmYmM3MTE4MjZjYzEzYTgxNmViZmNlNjQ4NQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjIyN2IyMzJkZjg0NDcyNTY4YTM0NmRjYWVjNzM5MDc5YTRjNGJhZDM1NzAz
|
10
|
+
ZGM2NmY4NzRlNzZlOWMyODE3YWNjNjVkNTEzNGYwNzVjOGQ2MTcwNGM3ODMy
|
11
|
+
OTNiZTc1N2Q1ZThjZDE3NjYyNTM4NGZkOGJhZGQwNDM2YTcyYjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2MwYzg4NTBlODA5YjkwMTVjYjI4MmRiOTdhMDM2ZmI0NDJjNjgzZjA1ZmUw
|
14
|
+
YThmMThmOGRmNGUyMTVkNDZkMmU1ODYxYTAyZmE1NzExMzBkYWM0OTkxNjMy
|
15
|
+
N2Y1MzUyZmRjNDY0ZDFhMjczNjhhNWFkNTc0MzczNDliYjYwOGM=
|
data/lib/saddle/endpoint.rb
CHANGED
@@ -13,7 +13,7 @@ module Saddle
|
|
13
13
|
def initialize(requester, relative_path=nil, parent=nil)
|
14
14
|
@requester = requester
|
15
15
|
@relative_path = relative_path
|
16
|
-
@parent = parent
|
16
|
+
@parent = parent
|
17
17
|
end
|
18
18
|
|
19
19
|
|
@@ -40,6 +40,7 @@ module Saddle
|
|
40
40
|
def request(method, action, params={}, options={})
|
41
41
|
# Augment in interesting options
|
42
42
|
options[:saddle] = {
|
43
|
+
:client_name => self.client_name,
|
43
44
|
:call_chain => path_array,
|
44
45
|
:action => action,
|
45
46
|
}
|
@@ -62,13 +63,27 @@ module Saddle
|
|
62
63
|
def endpoint_chain
|
63
64
|
chain = []
|
64
65
|
node = self
|
65
|
-
|
66
|
+
while node.is_a?(BaseEndpoint)
|
66
67
|
chain << node
|
67
68
|
node = node.parent
|
68
69
|
end
|
69
70
|
chain.reverse
|
70
71
|
end
|
71
72
|
|
73
|
+
# Traverse back until we find the original client
|
74
|
+
def client
|
75
|
+
node = self
|
76
|
+
while node.is_a?(BaseEndpoint)
|
77
|
+
node = node.parent
|
78
|
+
end
|
79
|
+
node
|
80
|
+
end
|
81
|
+
|
82
|
+
# Underscore name of the client
|
83
|
+
def client_name
|
84
|
+
ActiveSupport::Inflector.underscore(self.client.name.split('::')[-2])
|
85
|
+
end
|
86
|
+
|
72
87
|
|
73
88
|
# Create an endpoint instance and foist it upon this node
|
74
89
|
def build_and_attach_node(endpoint_class, method_name)
|
@@ -81,11 +96,7 @@ module Saddle
|
|
81
96
|
# This will create a resource endpoint, based upon the parameters
|
82
97
|
# of this current node endpoint
|
83
98
|
def create_resource_endpoint(endpoint_class, resource_id)
|
84
|
-
endpoint_class.new(
|
85
|
-
@requester,
|
86
|
-
(path_array + [resource_id]).join('/')
|
87
|
-
# no parent so that it can free up memory
|
88
|
-
)
|
99
|
+
endpoint_class.new(@requester, resource_id, self)
|
89
100
|
end
|
90
101
|
end
|
91
102
|
|
@@ -36,15 +36,16 @@ module Saddle
|
|
36
36
|
if File.file?(root_endpoint_file)
|
37
37
|
# Load it and create our base endpoint
|
38
38
|
load(root_endpoint_file)
|
39
|
-
self.implementation_module::RootEndpoint
|
39
|
+
root_node_class = self.implementation_module::RootEndpoint
|
40
40
|
else
|
41
41
|
# 'root_endpoint.rb' doesn't exist, so create a dummy endpoint
|
42
|
-
Saddle::BaseEndpoint
|
42
|
+
root_node_class = Saddle::BaseEndpoint
|
43
43
|
end
|
44
44
|
else
|
45
45
|
# we don't even have an implementation root, so create a dummy endpoint
|
46
|
-
Saddle::BaseEndpoint
|
46
|
+
root_node_class = Saddle::BaseEndpoint
|
47
47
|
end
|
48
|
+
root_node_class.new(requester, nil, self)
|
48
49
|
end
|
49
50
|
|
50
51
|
|
@@ -33,8 +33,13 @@ module Saddle
|
|
33
33
|
statsd_path = nil
|
34
34
|
if env[:request][:statsd_path]
|
35
35
|
statsd_path = env[:request][:statsd_path]
|
36
|
-
elsif env[:request][:saddle]
|
37
|
-
statsd_path = (
|
36
|
+
elsif env[:request][:saddle]
|
37
|
+
statsd_path = (
|
38
|
+
['saddle'] +
|
39
|
+
env[:request][:saddle][:client_name] +
|
40
|
+
env[:request][:saddle][:call_chain] +
|
41
|
+
[env[:request][:saddle][:action]]
|
42
|
+
).join('.')
|
38
43
|
end
|
39
44
|
|
40
45
|
# If we have a path, wrap the ensuing app call in STATSD timing
|
data/lib/saddle/version.rb
CHANGED