emissary 1.3.18 → 1.3.19
Sign up to get free protection for your applications and to get access to all the features.
- metadata +6 -40
- data/LICENSE +0 -203
- data/VERSION.yml +0 -4
- data/etc/config.ini +0 -38
- data/etc/emissary/config.ini +0 -13
- data/etc/init.d/emissary +0 -51
- data/lib/emissary.rb +0 -226
- data/lib/emissary/agent.rb +0 -61
- data/lib/emissary/agent/emissary.rb +0 -163
- data/lib/emissary/agent/error.rb +0 -26
- data/lib/emissary/agent/file.rb +0 -26
- data/lib/emissary/agent/gem.rb +0 -42
- data/lib/emissary/agent/mysql.rb +0 -230
- data/lib/emissary/agent/ping.rb +0 -37
- data/lib/emissary/agent/proxy.rb +0 -26
- data/lib/emissary/agent/rabbitmq.rb +0 -233
- data/lib/emissary/agent/sshkeys.rb +0 -152
- data/lib/emissary/agent/stats.rb +0 -96
- data/lib/emissary/agent/test.rb +0 -40
- data/lib/emissary/config.rb +0 -231
- data/lib/emissary/core_ext/blank.rb +0 -60
- data/lib/emissary/core_ext/misc_object.rb +0 -21
- data/lib/emissary/core_ext/symbolize.rb +0 -33
- data/lib/emissary/daemon.rb +0 -404
- data/lib/emissary/errors.rb +0 -106
- data/lib/emissary/gem_helper.rb +0 -183
- data/lib/emissary/identity.rb +0 -183
- data/lib/emissary/identity/ec2.rb +0 -64
- data/lib/emissary/identity/unix.rb +0 -67
- data/lib/emissary/logger.rb +0 -130
- data/lib/emissary/message.rb +0 -217
- data/lib/emissary/operator.rb +0 -275
- data/lib/emissary/operator/amqp.rb +0 -205
- data/lib/emissary/server.rb +0 -98
- data/lib/emissary/servolux.rb +0 -75
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emissary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 61
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 1.3.
|
9
|
+
- 19
|
10
|
+
version: 1.3.19
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Carl P. Corliss
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2013-01-08 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: daemons
|
@@ -189,45 +189,11 @@ extensions: []
|
|
189
189
|
extra_rdoc_files:
|
190
190
|
- README.txt
|
191
191
|
files:
|
192
|
-
-
|
193
|
-
- lib/emissary/servolux.rb
|
194
|
-
- lib/emissary/server.rb
|
195
|
-
- lib/emissary/operator.rb
|
196
|
-
- lib/emissary/operator/amqp.rb
|
197
|
-
- lib/emissary/message.rb
|
198
|
-
- lib/emissary/logger.rb
|
199
|
-
- lib/emissary/identity.rb
|
200
|
-
- lib/emissary/identity/unix.rb
|
201
|
-
- lib/emissary/identity/ec2.rb
|
202
|
-
- lib/emissary/gem_helper.rb
|
203
|
-
- lib/emissary/errors.rb
|
204
|
-
- lib/emissary/daemon.rb
|
205
|
-
- lib/emissary/core_ext/symbolize.rb
|
206
|
-
- lib/emissary/core_ext/misc_object.rb
|
207
|
-
- lib/emissary/core_ext/blank.rb
|
208
|
-
- lib/emissary/config.rb
|
209
|
-
- lib/emissary/agent.rb
|
210
|
-
- lib/emissary/agent/test.rb
|
211
|
-
- lib/emissary/agent/stats.rb
|
212
|
-
- lib/emissary/agent/sshkeys.rb
|
213
|
-
- lib/emissary/agent/rabbitmq.rb
|
214
|
-
- lib/emissary/agent/proxy.rb
|
215
|
-
- lib/emissary/agent/ping.rb
|
216
|
-
- lib/emissary/agent/mysql.rb
|
217
|
-
- lib/emissary/agent/gem.rb
|
218
|
-
- lib/emissary/agent/file.rb
|
219
|
-
- lib/emissary/agent/error.rb
|
220
|
-
- lib/emissary/agent/emissary.rb
|
221
|
-
- etc/init.d/emissary
|
222
|
-
- etc/emissary/config.ini
|
223
|
-
- etc/config.ini
|
192
|
+
- README.txt
|
224
193
|
- bin/emissary-setup
|
225
194
|
- bin/emissary-send-message
|
226
195
|
- bin/emissary
|
227
196
|
- bin/amqp-listen
|
228
|
-
- VERSION.yml
|
229
|
-
- LICENSE
|
230
|
-
- README.txt
|
231
197
|
homepage: http://nimbul.github.com/nimbul/
|
232
198
|
licenses: []
|
233
199
|
|
@@ -257,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
223
|
requirements: []
|
258
224
|
|
259
225
|
rubyforge_project:
|
260
|
-
rubygems_version: 1.8.
|
226
|
+
rubygems_version: 1.8.24
|
261
227
|
signing_key:
|
262
228
|
specification_version: 3
|
263
229
|
summary: EventMachine/AMQP based event handling client
|
data/LICENSE
DELETED
@@ -1,203 +0,0 @@
|
|
1
|
-
|
2
|
-
Apache License
|
3
|
-
Version 2.0, January 2004
|
4
|
-
http://www.apache.org/licenses/
|
5
|
-
|
6
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
-
|
8
|
-
1. Definitions.
|
9
|
-
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
-
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
-
the copyright owner that is granting the License.
|
15
|
-
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
-
other entities that control, are controlled by, or are under common
|
18
|
-
control with that entity. For the purposes of this definition,
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
20
|
-
direction or management of such entity, whether by contract or
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
-
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
-
exercising permissions granted by this License.
|
26
|
-
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
28
|
-
including but not limited to software source code, documentation
|
29
|
-
source, and configuration files.
|
30
|
-
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
32
|
-
transformation or translation of a Source form, including but
|
33
|
-
not limited to compiled object code, generated documentation,
|
34
|
-
and conversions to other media types.
|
35
|
-
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
37
|
-
Object form, made available under the License, as indicated by a
|
38
|
-
copyright notice that is included in or attached to the work
|
39
|
-
(an example is provided in the Appendix below).
|
40
|
-
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
-
the Work and Derivative Works thereof.
|
48
|
-
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
50
|
-
the original version of the Work and any modifications or additions
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
-
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
65
|
-
subsequently incorporated within the Work.
|
66
|
-
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
73
|
-
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
-
where such license applies only to those patent claims licensable
|
80
|
-
by such Contributor that are necessarily infringed by their
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
83
|
-
institute patent litigation against any entity (including a
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
86
|
-
or contributory patent infringement, then any patent licenses
|
87
|
-
granted to You under this License for that Work shall terminate
|
88
|
-
as of the date such litigation is filed.
|
89
|
-
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
92
|
-
modifications, and in Source or Object form, provided that You
|
93
|
-
meet the following conditions:
|
94
|
-
|
95
|
-
(a) You must give any other recipients of the Work or
|
96
|
-
Derivative Works a copy of this License; and
|
97
|
-
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
99
|
-
stating that You changed the files; and
|
100
|
-
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
103
|
-
attribution notices from the Source form of the Work,
|
104
|
-
excluding those notices that do not pertain to any part of
|
105
|
-
the Derivative Works; and
|
106
|
-
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
109
|
-
include a readable copy of the attribution notices contained
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
112
|
-
of the following places: within a NOTICE text file distributed
|
113
|
-
as part of the Derivative Works; within the Source form or
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
115
|
-
within a display generated by the Derivative Works, if and
|
116
|
-
wherever such third-party notices normally appear. The contents
|
117
|
-
of the NOTICE file are for informational purposes only and
|
118
|
-
do not modify the License. You may add Your own attribution
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
121
|
-
that such additional attribution notices cannot be construed
|
122
|
-
as modifying the License.
|
123
|
-
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
125
|
-
may provide additional or different license terms and conditions
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
129
|
-
the conditions stated in this License.
|
130
|
-
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
134
|
-
this License, without any additional terms or conditions.
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
-
the terms of any separate license agreement you may have executed
|
137
|
-
with Licensor regarding such Contributions.
|
138
|
-
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
141
|
-
except as required for reasonable and customary use in describing the
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
-
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
153
|
-
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
159
|
-
incidental, or consequential damages of any character arising as a
|
160
|
-
result of this License or out of the use or inability to use the
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
163
|
-
other commercial damages or losses), even if such Contributor
|
164
|
-
has been advised of the possibility of such damages.
|
165
|
-
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
-
or other liability obligations and/or rights consistent with this
|
170
|
-
License. However, in accepting such obligations, You may act only
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
175
|
-
of your accepting any such warranty or additional liability.
|
176
|
-
|
177
|
-
END OF TERMS AND CONDITIONS
|
178
|
-
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
180
|
-
|
181
|
-
To apply the Apache License to your work, attach the following
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
-
replaced with your own identifying information. (Don't include
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
185
|
-
comment syntax for the file format. We also recommend that a
|
186
|
-
file or class name and description of purpose be included on the
|
187
|
-
same "printed page" as the copyright notice for easier
|
188
|
-
identification within third-party archives.
|
189
|
-
|
190
|
-
Copyright 2010 The New York Times
|
191
|
-
|
192
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
-
you may not use this file except in compliance with the License.
|
194
|
-
You may obtain a copy of the License at
|
195
|
-
|
196
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
-
|
198
|
-
Unless required by applicable law or agreed to in writing, software
|
199
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
-
See the License for the specific language governing permissions and
|
202
|
-
limitations under the License.
|
203
|
-
|
data/VERSION.yml
DELETED
data/etc/config.ini
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
[general]
|
2
|
-
operators = [ amqp ]
|
3
|
-
pid_dir = /var/run
|
4
|
-
log_level = NOTICE
|
5
|
-
agents = [ all ]
|
6
|
-
[agents]
|
7
|
-
execute = {
|
8
|
-
safe_path = /opt/nyt/emissary/bin
|
9
|
-
}
|
10
|
-
sshkeys = {
|
11
|
-
valid_users = [
|
12
|
-
root, dev, logpoll
|
13
|
-
]
|
14
|
-
}
|
15
|
-
[amqp]
|
16
|
-
node = {
|
17
|
-
# URI schema is: <scheme>://<user>:<pass>@<server>:<port>/<vhost>
|
18
|
-
# scheme is either amqp (non-ssl) or amqps (ssl)
|
19
|
-
URI = amqps://nimbul_pa_1:22MH%23a3%7D5%2AGb5%2EfG@mq.ec2.nytimes.com:443/nimbul
|
20
|
-
# Account: NYTD Platform Production [1]
|
21
|
-
# Cluster: Nimbul [2]
|
22
|
-
# Server: Nimbul Production [292]
|
23
|
-
# all routing keys are based on <RouteType>.<Account ID>.<Cluster ID>.<Server Id>.<Instance ID>
|
24
|
-
subscriptions = [
|
25
|
-
request.1:topic
|
26
|
-
request.1.2:topic
|
27
|
-
request.1.2.292:topic
|
28
|
-
request.1.2.292.__ID_INSTANCE_ID__:topic
|
29
|
-
]
|
30
|
-
startup = startup.1.2.292.__ID_INSTANCE_ID__:topic
|
31
|
-
shutdown = shutdown.1.2.292.__ID_INSTANCE_ID__:topic
|
32
|
-
stats = {
|
33
|
-
interval = 300
|
34
|
-
queue_base = info.stat.1.2.292.__ID_INSTANCE_ID__:topic
|
35
|
-
}
|
36
|
-
# no stats for the time being
|
37
|
-
disable = [ stats ]
|
38
|
-
}
|
data/etc/emissary/config.ini
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
[general]
|
2
|
-
|
3
|
-
# what operator types are monitoring for message events (comma seperated list)
|
4
|
-
operators = [ amqp ]
|
5
|
-
|
6
|
-
# pid_dir: Where to store the Process ID file which contains the id of the process
|
7
|
-
# and is used for stoping and reloading the service
|
8
|
-
pid_dir = /var/run
|
9
|
-
|
10
|
-
# log_level: the level of information to log. see 'man 3 syslog' for list of log levels
|
11
|
-
log_level = NOTICE
|
12
|
-
|
13
|
-
agents = [ all ]
|
data/etc/init.d/emissary
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
# $Id: emissary 496 2009-03-14 02:26:46Z ccorliss $
|
3
|
-
# emissary This shell script takes care of starting and stopping emissary.
|
4
|
-
#
|
5
|
-
# chkconfig: 2345 99 10
|
6
|
-
# description: emissary provides support for handling of network events.
|
7
|
-
|
8
|
-
CONFIG_FILE=/etc/emissary/config.ini
|
9
|
-
## Do this to ensure that RVM is used (invoke a subshell) if it exists on the system. No harm otherwise
|
10
|
-
EMISSARY_EXECUTABLE=$(/bin/sh -l -c "ruby -rrubygems -e 'puts Gem.bindir'")/emissary
|
11
|
-
|
12
|
-
[ -f "${CONFIG_FILE}" ] || exit 0
|
13
|
-
|
14
|
-
. /etc/rc.d/init.d/functions
|
15
|
-
|
16
|
-
if [ -f /etc/sysconfig/emissary ]; then
|
17
|
-
. /etc/sysconfig/emissary
|
18
|
-
fi
|
19
|
-
|
20
|
-
# See how we were called.
|
21
|
-
case "$1" in
|
22
|
-
start)
|
23
|
-
# Start daemon.
|
24
|
-
echo -n "Starting emissary: "
|
25
|
-
daemon ${EMISSARY_EXECUTABLE} -d --config-file ${CONFIG_FILE} start
|
26
|
-
touch /var/lock/subsys/emissary
|
27
|
-
echo
|
28
|
-
;;
|
29
|
-
stop)
|
30
|
-
# Stop daemon.
|
31
|
-
echo -n "Shutting down emissary: "
|
32
|
-
daemon ${EMISSARY_EXECUTABLE} --config-file ${CONFIG_FILE} stop
|
33
|
-
echo
|
34
|
-
rm -f /var/lock/subsys/emissary
|
35
|
-
;;
|
36
|
-
restart)
|
37
|
-
daemon ${EMISSARY_EXECUTABLE} --config-file ${CONFIG_FILE} restart
|
38
|
-
;;
|
39
|
-
status)
|
40
|
-
daemon ${EMISSARY_EXECUTABLE} --config-file ${CONFIG_FILE} status
|
41
|
-
;;
|
42
|
-
reconfig)
|
43
|
-
daemon ${EMISSARY_EXECUTABLE} --config-file ${CONFIG_FILE} reconfig
|
44
|
-
;;
|
45
|
-
*)
|
46
|
-
echo "Usage: emissary {start|stop|restart|status|reconfig}"
|
47
|
-
exit 1
|
48
|
-
;;
|
49
|
-
esac
|
50
|
-
|
51
|
-
exit 0
|
data/lib/emissary.rb
DELETED
@@ -1,226 +0,0 @@
|
|
1
|
-
# Copyright 2010 The New York Times
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#
|
15
|
-
#
|
16
|
-
require 'rubygems'
|
17
|
-
require 'bundler/setup'
|
18
|
-
|
19
|
-
require 'uuid'
|
20
|
-
require 'digest/md5'
|
21
|
-
require 'yaml'
|
22
|
-
require 'pathname'
|
23
|
-
|
24
|
-
begin
|
25
|
-
require 'thread'
|
26
|
-
require 'fastthread'
|
27
|
-
rescue LoadError
|
28
|
-
end
|
29
|
-
|
30
|
-
module Emissary
|
31
|
-
# :stopdoc:
|
32
|
-
LIBPATH = Pathname.new(__FILE__).dirname.realpath
|
33
|
-
PATH = LIBPATH.dirname
|
34
|
-
VERSION = ::YAML.load(File.read(PATH + 'VERSION.yml')).values.join '.'
|
35
|
-
|
36
|
-
EXTERNALS_BASE = File.join('emissary')
|
37
|
-
EXTERNAL_IDENTITIES = File.join(EXTERNALS_BASE, 'identities').to_s
|
38
|
-
EXTERNAL_AGENTS = File.join(EXTERNALS_BASE, 'agents').to_s
|
39
|
-
EXTERNAL_OPERATORS = File.join(EXTERNALS_BASE, 'operator').to_s
|
40
|
-
|
41
|
-
DEFAULT_EXCHANGE = :direct
|
42
|
-
DAEMON_RECHECK_INTERVAL = 10
|
43
|
-
IP_CHECK_DOMAIN = 'checkip.dyndns.org'
|
44
|
-
IP_CHECK_URL = "http://#{IP_CHECK_DOMAIN}"
|
45
|
-
# :startdoc:
|
46
|
-
|
47
|
-
class << self
|
48
|
-
@@pid = nil
|
49
|
-
def PID
|
50
|
-
@@pid
|
51
|
-
end
|
52
|
-
|
53
|
-
# Returns the version string for the library.
|
54
|
-
#
|
55
|
-
def version
|
56
|
-
VERSION
|
57
|
-
end
|
58
|
-
|
59
|
-
# Returns the library path for the module. If any arguments are given,
|
60
|
-
# they will be joined to the end of the libray path using
|
61
|
-
# <tt>File.join</tt>.
|
62
|
-
#
|
63
|
-
def libpath( *args )
|
64
|
-
args.empty? ? LIBPATH.to_s : File.join(LIBPATH.to_s, args.flatten)
|
65
|
-
end
|
66
|
-
|
67
|
-
# Returns the path for the module. If any arguments are given,
|
68
|
-
# they will be joined to the end of the path using
|
69
|
-
# <tt>File.join</tt>.
|
70
|
-
#
|
71
|
-
def path( *args )
|
72
|
-
args.empty? ? PATH.to_s : File.join(PATH.to_s, args.flatten)
|
73
|
-
end
|
74
|
-
|
75
|
-
def sublib_path( *args )
|
76
|
-
args.empty? ? PATH.to_s : File.join(LIBPATH.to_s, 'emissary', args.flatten)
|
77
|
-
end
|
78
|
-
|
79
|
-
def klass_from_handler(klass = nil, handler = nil, *args)
|
80
|
-
klass = if handler and handler.is_a? Class and not handler.nil?
|
81
|
-
raise ArgumentError, "must provide module or subclass of #{klass.name}" unless klass >= handler
|
82
|
-
handler
|
83
|
-
elsif handler.is_a? Module
|
84
|
-
resource_name = "RESOURCE_#{handler.to_s.upcase.split('::').pop}"
|
85
|
-
begin
|
86
|
-
klass.const_get(resource_name)
|
87
|
-
rescue NameError
|
88
|
-
klass.const_set(resource_name, Class.new(klass) { include handler } )
|
89
|
-
end
|
90
|
-
elsif klass.nil?
|
91
|
-
raise ArgumentError, "klass must be a valid class constant for #{name}#klass_from_handler"
|
92
|
-
elsif handler.nil?
|
93
|
-
raise ArgumentError, "handler must be a valid class or module"
|
94
|
-
else
|
95
|
-
klass
|
96
|
-
end
|
97
|
-
|
98
|
-
arity = klass.instance_method(:initialize).arity
|
99
|
-
expected = arity >= 0 ? arity : -(arity + 1)
|
100
|
-
if (arity >= 0 and args.size != expected) or (arity < 0 and args.size < expected)
|
101
|
-
raise ArgumentError, "wrong number of arguments for #{klass}#initialize (#{args.size} for #{expected})"
|
102
|
-
end
|
103
|
-
|
104
|
-
klass
|
105
|
-
end
|
106
|
-
|
107
|
-
def klass_loaded?(class_name)
|
108
|
-
begin
|
109
|
-
!!klass_const(class_name)
|
110
|
-
rescue NameError
|
111
|
-
false
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def klass_const(class_name, autoload = false)
|
116
|
-
return class_name if class_name.is_a? Class or class_name.is_a? Module
|
117
|
-
|
118
|
-
klass = Object
|
119
|
-
|
120
|
-
class_name.split('::').each do |c|
|
121
|
-
begin
|
122
|
-
klass = klass.const_get(c.to_sym)
|
123
|
-
rescue NameError => e
|
124
|
-
if autoload
|
125
|
-
require_klass( (klass == Object ? c : "#{klass.to_s}::#{c}") )
|
126
|
-
redo
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
klass.to_s == class_name ? klass : nil
|
132
|
-
end
|
133
|
-
|
134
|
-
def load_klass(class_name)
|
135
|
-
load libpath(*class_name.downcase.split(/::/)) + '.rb'
|
136
|
-
end
|
137
|
-
|
138
|
-
def require_klass(class_name)
|
139
|
-
require libpath(*class_name.downcase.split(/::/))
|
140
|
-
end
|
141
|
-
|
142
|
-
def logger
|
143
|
-
Emissary::Logger.instance
|
144
|
-
end
|
145
|
-
|
146
|
-
def generate_uuid
|
147
|
-
UUID.generate
|
148
|
-
end
|
149
|
-
|
150
|
-
def identity
|
151
|
-
@@identity ||= Emissary::Identity.instance
|
152
|
-
end
|
153
|
-
|
154
|
-
# Sets up a line of communication
|
155
|
-
#
|
156
|
-
def call handler, config, *args
|
157
|
-
unless handler.is_a? Class or handler.is_a? Module
|
158
|
-
klass_name = 'Emissary::Operator::' + handler.to_s.upcase
|
159
|
-
begin
|
160
|
-
require_klass klass_name
|
161
|
-
rescue LoadError => e
|
162
|
-
begin
|
163
|
-
require_klass Emissary::EXTERNAL_OPERATORS + '::' + handler.to_s.upcase
|
164
|
-
#rescue LoadError
|
165
|
-
# raise the original exception if we still haven't found the file
|
166
|
-
# raise e
|
167
|
-
end
|
168
|
-
end
|
169
|
-
handler = klass_const klass_name
|
170
|
-
end
|
171
|
-
|
172
|
-
klass = klass_from_handler(Operator, handler, config)
|
173
|
-
|
174
|
-
operator = klass.new(config, *args)
|
175
|
-
operator.validate_config!
|
176
|
-
block_given? and yield operator
|
177
|
-
operator
|
178
|
-
end
|
179
|
-
|
180
|
-
# Dispatches a message to the agent specified by the message
|
181
|
-
#
|
182
|
-
def dispatch message, config, *args
|
183
|
-
unless message.is_a? Emissary::Message
|
184
|
-
raise ArgumentError, "message is not an Emissary::Message"
|
185
|
-
end
|
186
|
-
|
187
|
-
begin
|
188
|
-
agent_type = 'Emissary::Agent::' + message.agent.to_s.capitalize
|
189
|
-
begin
|
190
|
-
require_klass agent_type
|
191
|
-
rescue LoadError => e
|
192
|
-
begin
|
193
|
-
require_klass Emissary::EXTERNAL_AGENTS + '::' + message.agent.to_s.capitalize
|
194
|
-
rescue LoadError
|
195
|
-
# raise the original exception if we still haven't found the file
|
196
|
-
raise e
|
197
|
-
end
|
198
|
-
end
|
199
|
-
rescue Exception => e
|
200
|
-
Emissary.logger.error "Dispatcher Error: #{e.class.name}: #{e.message}\n\t#{e.backtrace.join("\n\t")}"
|
201
|
-
message = message.error(e)
|
202
|
-
agent_type = 'Emissary::Agent::Error'
|
203
|
-
end
|
204
|
-
|
205
|
-
handler = klass_const agent_type, true
|
206
|
-
|
207
|
-
klass = klass_from_handler(Agent, handler, message, config, *args)
|
208
|
-
|
209
|
-
Emissary.logger.debug " [--] Dispatching message to: #{agent_type}"
|
210
|
-
agent = klass.new(message, config, *args)
|
211
|
-
block_given? and yield agent
|
212
|
-
agent
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
# autoload core object extensions
|
217
|
-
Dir[sublib_path('core_ext', '*.rb')].each do |core_extension|
|
218
|
-
require core_extension
|
219
|
-
end
|
220
|
-
end # module Emissary
|
221
|
-
|
222
|
-
$:.unshift Emissary::LIBPATH.to_s
|
223
|
-
|
224
|
-
[ :errors, :logger, :operator, :agent, :identity, :message, :config, :gem_helper ].each do |sublib|
|
225
|
-
require Emissary.sublib_path sublib.to_s
|
226
|
-
end
|