pipeline_toolkit 1.2.24 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +37 -5
- data/lib/pipeline_toolkit/amqp/abstract.rb +5 -7
- data/lib/pipeline_toolkit/amqp/reader.rb +5 -5
- data/lib/pipeline_toolkit/amqp/writer.rb +3 -3
- data/lib/pipeline_toolkit/cli/msg_push_cli.rb +1 -0
- data/lib/pipeline_toolkit/cli/msg_subscribe_cli.rb +1 -0
- data/lib/pipeline_toolkit/default_logger.rb +86 -98
- data/lib/pipeline_toolkit/handlers/message_handler.rb +3 -3
- data/lib/pipeline_toolkit/message_command.rb +7 -8
- data/lib/pipeline_toolkit/message_pusher.rb +6 -3
- data/lib/pipeline_toolkit/message_subscriber.rb +2 -3
- data/lib/pipeline_toolkit/monitoring/monitor_server.rb +0 -1
- metadata +63 -22
data/README.markdown
CHANGED
@@ -30,7 +30,7 @@ Provides:
|
|
30
30
|
|
31
31
|
> (sudo) gem install pipeline_toolkit
|
32
32
|
|
33
|
-
###
|
33
|
+
### Dependencies ###
|
34
34
|
|
35
35
|
It is assumed that you have:
|
36
36
|
|
@@ -135,9 +135,43 @@ To make the steps available to your application's cucumber features simply put t
|
|
135
135
|
|
136
136
|
require 'pipeline_toolkit/cucumber'
|
137
137
|
|
138
|
-
##
|
138
|
+
## Logging ##
|
139
|
+
|
140
|
+
Pipeline toolkit uses the Log4r framework for logging. This lets you use output your logging to syslog, send email, tweet, dispatch a carrier pigeon, etc. See [Log4r](http://log4r.rubyforge.org) for more. To use it simply call any one of "debug", "info", "warn", "error", "fatal" on the DefaultLogger class. For examples:
|
141
|
+
|
142
|
+
DefaultLogginer.debug("Hi there!")
|
143
|
+
|
144
|
+
The logger is initialized automatically and can be configured using one of following three methods:
|
145
|
+
|
146
|
+
1. Using the built-in defaults -- this is what you get if you use nothing else. The defaults are:
|
147
|
+
|
148
|
+
* Output to stderr and the file 'pipeline_development.log' in the execution directory
|
149
|
+
* Log level is DEBUG
|
150
|
+
|
151
|
+
2. Load the logging configuration from a file called "log_config.yml" in your execution directory. See the Log4r [rdoc](http://log4r.rubyforge.org) for more details.
|
152
|
+
|
153
|
+
3. Tweak the defaults (such as where the log\_config.yml is loaded from) by calling DefaultLogger.init_logger before making any logging calls. The following options are available:
|
139
154
|
|
140
|
-
|
155
|
+
# Used to build the file name. Made available in config YML as #{ENV}
|
156
|
+
options[:env] ||= "development"
|
157
|
+
|
158
|
+
# Logger name. Used to build the file name. Made available in config YML as #{NAME}
|
159
|
+
options[:log_name] ||= "pipeline"
|
160
|
+
|
161
|
+
# Log level. Made available in config YML as #{LEVEL}
|
162
|
+
options[:log_level] ||= "DEBUG"
|
163
|
+
|
164
|
+
# Name of logger to use. If you specify multiple loggers in your YML, you can select which one to use here.
|
165
|
+
options[:logger_name] ||= "log"
|
166
|
+
|
167
|
+
# File to read configuration from.
|
168
|
+
options[:log_config_file] ||= "log_config.yml"
|
169
|
+
|
170
|
+
4. One difference with vanilla log4r is that if trace is enabled in the logger you define, the logging methods will automatically add the trace at the end of any string you pass for logging,
|
171
|
+
regardless of what formatter you use. This is to work around the trace always appearing to come from DefaultLogger.method_missing.
|
172
|
+
|
173
|
+
|
174
|
+
## Todo ##
|
141
175
|
|
142
176
|
* Add tmp path as a argument (hardcoded to /tmp at mo)
|
143
177
|
|
@@ -147,5 +181,3 @@ To make the steps available to your application's cucumber features simply put t
|
|
147
181
|
|
148
182
|
* Write tests around queue setup for msg_push and msg_sub
|
149
183
|
|
150
|
-
|
151
|
-
|
@@ -32,8 +32,6 @@ module PipelineToolkit
|
|
32
32
|
def initialize(options = {})
|
33
33
|
super(options)
|
34
34
|
|
35
|
-
DefaultLogger.init_logger(options)
|
36
|
-
|
37
35
|
@options = options
|
38
36
|
end
|
39
37
|
|
@@ -41,7 +39,7 @@ module PipelineToolkit
|
|
41
39
|
# Create a new connection to the AMQP server.
|
42
40
|
#
|
43
41
|
def initialize_connection
|
44
|
-
DefaultLogger.debug("Amqp::Abstract#initialize_connection")
|
42
|
+
DefaultLogger.debug("Amqp::Abstract#initialize_connection")
|
45
43
|
@connection = AMQP.connect(options.select_keys(:host, :port, :user, :pass, :vhost))
|
46
44
|
end
|
47
45
|
|
@@ -59,7 +57,7 @@ module PipelineToolkit
|
|
59
57
|
# and the AMQP server.
|
60
58
|
#
|
61
59
|
def initialize_channel
|
62
|
-
DefaultLogger.debug("Amqp::Abstract#initialize_channel")
|
60
|
+
DefaultLogger.debug("Amqp::Abstract#initialize_channel")
|
63
61
|
@channel = MQ.new(@connection)
|
64
62
|
end
|
65
63
|
|
@@ -68,7 +66,7 @@ module PipelineToolkit
|
|
68
66
|
# to act as an ingress point for all published messages.
|
69
67
|
#
|
70
68
|
def initialize_exchange
|
71
|
-
DefaultLogger.debug("Amqp::Abstract#initialize_exchange")
|
69
|
+
DefaultLogger.debug("Amqp::Abstract#initialize_exchange")
|
72
70
|
# declare a exchange on the channel
|
73
71
|
@exchange = MQ::Exchange.new(@channel, options[:type], options[:exchange], :durable => options[:durable], :passive => options[:passive])
|
74
72
|
rescue MQ::Error => e # rescued here because main thread does not seem to see it
|
@@ -82,7 +80,7 @@ module PipelineToolkit
|
|
82
80
|
# @param name<String> The name to use for the queue
|
83
81
|
#
|
84
82
|
def initialize_queue(name = '')
|
85
|
-
DefaultLogger.debug("Amqp::Abstract#initialize_queue(name = '')")
|
83
|
+
DefaultLogger.debug("Amqp::Abstract#initialize_queue(name = '')")
|
86
84
|
name = options[:queue] if name.nil? || name.empty?
|
87
85
|
@queue = MQ::Queue.new(@channel, name, :durable => options[:durable], :passive => options[:passive])
|
88
86
|
end
|
@@ -95,7 +93,7 @@ module PipelineToolkit
|
|
95
93
|
#
|
96
94
|
def bind_queue(routing_key = '')
|
97
95
|
routing_key = options[:queue].split(":").last if options[:queue] && options[:queue].include?(":")
|
98
|
-
DefaultLogger.debug("Amqp::Abstract#bind_queue(routing_key = '')")
|
96
|
+
DefaultLogger.debug("Amqp::Abstract#bind_queue(routing_key = '')")
|
99
97
|
unless routing_key.nil? || routing_key.empty?
|
100
98
|
@queue.bind(@exchange, :key => routing_key)
|
101
99
|
else
|
@@ -15,7 +15,7 @@ module PipelineToolkit
|
|
15
15
|
# of messages from the server.
|
16
16
|
#
|
17
17
|
def initialize_reader
|
18
|
-
DefaultLogger.debug("Amqp::Reader#initialize_reader")
|
18
|
+
DefaultLogger.debug("Amqp::Reader#initialize_reader")
|
19
19
|
@ack_headers ||= {}
|
20
20
|
initialize_connection
|
21
21
|
initialize_channel
|
@@ -31,10 +31,10 @@ module PipelineToolkit
|
|
31
31
|
# Subscribe the queue to receive messages
|
32
32
|
#
|
33
33
|
def queue_subscribe
|
34
|
-
DefaultLogger.debug("Amqp::Reader#queue_subscribe")
|
34
|
+
DefaultLogger.debug("Amqp::Reader#queue_subscribe")
|
35
35
|
unless AMQP.closing?
|
36
36
|
@queue.subscribe(:ack => options[:ack]) do |header, body|
|
37
|
-
DefaultLogger.debug("Rabbit Message: #{body}")
|
37
|
+
DefaultLogger.debug("Rabbit Message: #{body}")
|
38
38
|
process_queue_message(header, body)
|
39
39
|
end
|
40
40
|
end
|
@@ -47,7 +47,7 @@ module PipelineToolkit
|
|
47
47
|
# @param header<MQ::Header> The message queue header for the message
|
48
48
|
#
|
49
49
|
def store_acknowledgement(message, header)
|
50
|
-
DefaultLogger.debug("Amqp::Reader#store_acknowledgement(message, header)")
|
50
|
+
DefaultLogger.debug("Amqp::Reader#store_acknowledgement(message, header)")
|
51
51
|
message[:ack_id] = header.delivery_tag.to_s
|
52
52
|
@ack_headers[message[:ack_id]] = header
|
53
53
|
end
|
@@ -59,7 +59,7 @@ module PipelineToolkit
|
|
59
59
|
# @param ack_id<String> The acknowledgement identifier
|
60
60
|
#
|
61
61
|
def perform_acknowledgement(ack_id)
|
62
|
-
DefaultLogger.debug("Amqp::Reader#perform_acknowledgement(ack_id)")
|
62
|
+
DefaultLogger.debug("Amqp::Reader#perform_acknowledgement(ack_id)")
|
63
63
|
header = @ack_headers.delete(ack_id)
|
64
64
|
header.ack
|
65
65
|
end
|
@@ -16,7 +16,7 @@ module PipelineToolkit
|
|
16
16
|
# of messages publishing to the server.
|
17
17
|
#
|
18
18
|
def initialize_writer
|
19
|
-
DefaultLogger.debug("Amqp::Writer#initialize_writer")
|
19
|
+
DefaultLogger.debug("Amqp::Writer#initialize_writer")
|
20
20
|
initialize_connection
|
21
21
|
initialize_channel
|
22
22
|
initialize_exchange
|
@@ -26,7 +26,7 @@ module PipelineToolkit
|
|
26
26
|
# Initializes the queues to publish the messages too.
|
27
27
|
#
|
28
28
|
def initialize_queues
|
29
|
-
DefaultLogger.debug("Amqp::Writer#initialize_queues")
|
29
|
+
DefaultLogger.debug("Amqp::Writer#initialize_queues")
|
30
30
|
options[:queues].each do |name, routing_key|
|
31
31
|
initialize_queue(name)
|
32
32
|
bind_queue(routing_key)
|
@@ -39,7 +39,7 @@ module PipelineToolkit
|
|
39
39
|
# @param message<Hash> The message to publish
|
40
40
|
#
|
41
41
|
def publish(message)
|
42
|
-
DefaultLogger.debug("Amqp::Writer#publish(message)")
|
42
|
+
DefaultLogger.debug("Amqp::Writer#publish(message)")
|
43
43
|
if message.has_key?(:routing_key)
|
44
44
|
@exchange.publish(MessageCoder.encode(message), :key => message[:routing_key])
|
45
45
|
else
|
@@ -50,6 +50,7 @@ EOL
|
|
50
50
|
Misc:
|
51
51
|
EOL
|
52
52
|
opt :env, "Environment (development, production)", :default => "development", :short => :e
|
53
|
+
opt :log_conf, "YML file to configure logging", :short => :l, :type => :string, :required => false
|
53
54
|
end
|
54
55
|
|
55
56
|
# Change ['queue1:routing_key', ...] to [['queue1','routing_key'], ...]
|
@@ -58,6 +58,7 @@ EOL
|
|
58
58
|
Misc:
|
59
59
|
EOL
|
60
60
|
opt :pid_path, "Specifies a path to write a file containing the pid to, by default no pid file is created", :type => :string
|
61
|
+
opt :log_conf, "YML file to configure logging", :short => :l, :type => :string, :required => false
|
61
62
|
opt :env, "The environment to run (development, production)", :default => "development", :short => :e
|
62
63
|
end
|
63
64
|
|
@@ -1,48 +1,103 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
require "fileutils"
|
2
|
+
require "log4r"
|
3
|
+
require 'log4r/yamlconfigurator'
|
4
|
+
require 'log4r/outputter/fileoutputter'
|
5
|
+
require 'log4r/outputter/emailoutputter'
|
6
|
+
require 'log4r/outputter/syslogoutputter'
|
7
|
+
include Log4r
|
8
8
|
|
9
|
-
# replace for tidy timestamped logs
|
10
|
-
class Logger
|
11
|
-
remove_method :format_message
|
12
|
-
def format_message(severity, timestamp, progname, msg)
|
13
|
-
"#{timestamp.strftime('%b%d %H:%M:%S')} #{msg}\n"
|
14
|
-
end
|
15
|
-
end
|
16
9
|
|
17
10
|
##
|
18
|
-
#
|
19
|
-
#
|
20
|
-
|
21
|
-
# logs to syslog. You can set the environment by passing the :env option with either
|
22
|
-
# 'development' or 'production' when calling the {.init_logger} method.
|
23
|
-
#
|
11
|
+
# DefaultLogger will log to stderr and a log file in the execution directory by default, as specified in this yml.
|
12
|
+
# You can specify your own file to use by calling init_logger with option[:log_config_file] = someconfig.yml
|
13
|
+
|
24
14
|
class DefaultLogger
|
15
|
+
@@logger = nil
|
16
|
+
@@options = nil
|
17
|
+
|
18
|
+
def self.default_yaml
|
19
|
+
"log4r_config:
|
20
|
+
|
21
|
+
# define all loggers ...
|
22
|
+
loggers:
|
23
|
+
- name : log
|
24
|
+
trace : true
|
25
|
+
outputters:
|
26
|
+
- stderr
|
27
|
+
- logfile
|
28
|
+
|
29
|
+
# define all outputters (incl. formatters)
|
30
|
+
outputters:
|
31
|
+
- type : StderrOutputter
|
32
|
+
name : stderr
|
33
|
+
formatter:
|
34
|
+
date_pattern: '%Y-%m-%d %H:%M:%S'
|
35
|
+
pattern : '%d %l: [#\{NAME\}] %m '
|
36
|
+
type : PatternFormatter
|
37
|
+
|
38
|
+
- type : FileOutputter
|
39
|
+
name : logfile
|
40
|
+
filename : '#\{NAME\}.log'
|
41
|
+
formatter:
|
42
|
+
date_pattern: '%Y-%m-%d %H:%M:%S'
|
43
|
+
pattern : '%d %l: [#\{NAME\}] %m '
|
44
|
+
type : PatternFormatter"
|
45
|
+
end
|
25
46
|
|
26
47
|
##
|
27
|
-
# Initialize a new logger
|
48
|
+
# Initialize a new logger. Optional, as it will be called with default values when log methods are used.
|
49
|
+
# Options fields are as follows:
|
50
|
+
#
|
51
|
+
# options[:log_name] ||= "pipeline"
|
52
|
+
# Logger name. Used to build the file name. Made available in config YML as #{NAME}
|
53
|
+
#
|
54
|
+
# options[:log_level] ||= "DEBUG"
|
55
|
+
# Log level. Made available in config YML as #{LEVEL}
|
28
56
|
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
57
|
+
# options[:logger_name] ||= "log"
|
58
|
+
# Name of logger to use. If you specify multiple loggers in your YML, you can select which one to use here.
|
59
|
+
#
|
60
|
+
# options[:log_config_file] ||= "log_config.yml"
|
61
|
+
# File to read configuration from.
|
32
62
|
#
|
33
63
|
def self.init_logger(options = {})
|
34
|
-
options[:env] ||= "development"
|
35
64
|
options[:log_name] ||= "pipeline"
|
65
|
+
options[:log_level] ||= 'DEBUG'
|
66
|
+
options[:logger_name] ||= "log"
|
67
|
+
options[:log_conf] ||= "log_config.yml"
|
68
|
+
|
69
|
+
|
70
|
+
@@options = options
|
36
71
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
72
|
+
ycfg = YamlConfigurator
|
73
|
+
ycfg['LEVEL'] = options[:log_level]
|
74
|
+
ycfg['NAME'] = options[:log_name]
|
75
|
+
|
76
|
+
if File.exists?(options[:log_conf])
|
77
|
+
#puts "using log_config.yml"
|
78
|
+
h = File.open(options[:log_conf]) { |yf| YAML::load( yf ) }
|
41
79
|
else
|
42
|
-
|
43
|
-
|
80
|
+
#puts "using default yml"
|
81
|
+
h = YAML.load default_yaml
|
44
82
|
end
|
83
|
+
#y h
|
84
|
+
ycfg.decode_yaml h['log4r_config']
|
45
85
|
|
86
|
+
@@logger = Logger[options[:logger_name]]
|
87
|
+
end
|
88
|
+
|
89
|
+
##
|
90
|
+
# Send log calls to the Logger, initializing it first if necessary.
|
91
|
+
#
|
92
|
+
def self.method_missing(name, *args)
|
93
|
+
@@logger || init_logger()
|
94
|
+
|
95
|
+
# add trace message if the logger is tracing. we can't use the default trace (%t) because that'll just show this
|
96
|
+
# method_missing as the caller. Usefulness: rather low.
|
97
|
+
|
98
|
+
args[0] += " (#{caller[0]})" if @@logger.trace && args[0].class == String
|
99
|
+
|
100
|
+
@@logger.send(name, *args)
|
46
101
|
end
|
47
102
|
|
48
103
|
##
|
@@ -60,72 +115,5 @@ class DefaultLogger
|
|
60
115
|
def self.logger
|
61
116
|
@@logger
|
62
117
|
end
|
63
|
-
|
64
|
-
##
|
65
|
-
# Setter for setting the log level to use
|
66
|
-
#
|
67
|
-
# @param new_level<Integer> The new log level to use
|
68
|
-
#
|
69
|
-
def self.level=(new_level)
|
70
|
-
logger.level = new_level
|
71
|
-
end
|
72
|
-
|
73
|
-
##
|
74
|
-
# Getter for the log level
|
75
|
-
#
|
76
|
-
def self.level
|
77
|
-
logger.level
|
78
|
-
end
|
79
|
-
|
80
|
-
##
|
81
|
-
# Publish a debug log message
|
82
|
-
#
|
83
|
-
# @param message<String> The log message to publish
|
84
|
-
#
|
85
|
-
def self.debug(message)
|
86
|
-
logger.debug(message)
|
87
|
-
end
|
88
118
|
|
89
|
-
##
|
90
|
-
# Publish a info log message
|
91
|
-
#
|
92
|
-
# @param message<String> The log message to publish
|
93
|
-
#
|
94
|
-
def self.info(message)
|
95
|
-
logger.info(message)
|
96
|
-
end
|
97
|
-
|
98
|
-
##
|
99
|
-
# Publish a warning log message
|
100
|
-
#
|
101
|
-
# @param message<String> The log message to publish
|
102
|
-
#
|
103
|
-
def self.warn(message)
|
104
|
-
logger.warn(message)
|
105
|
-
end
|
106
|
-
|
107
|
-
##
|
108
|
-
# Publish a error log message
|
109
|
-
#
|
110
|
-
# @param message<String> The log message to publish
|
111
|
-
#
|
112
|
-
def self.error(message)
|
113
|
-
logger.error(message)
|
114
|
-
end
|
115
|
-
|
116
|
-
private
|
117
|
-
|
118
|
-
##
|
119
|
-
# Ensure we have the log directories in the home path
|
120
|
-
#
|
121
|
-
def self.log_directories
|
122
|
-
# Ensure the log directory exist
|
123
|
-
dir = "#{ENV["HOME"]}/pipeline_toolkit/logs"
|
124
|
-
unless File.directory?(dir)
|
125
|
-
# Create log directory
|
126
|
-
FileUtils.makedirs(dir)
|
127
|
-
end
|
128
|
-
dir
|
129
|
-
end
|
130
|
-
|
131
119
|
end
|
@@ -27,7 +27,7 @@ module PipelineToolkit
|
|
27
27
|
# The callback method that EventMachine calls as soon as a new message arrives
|
28
28
|
#
|
29
29
|
def notify_readable
|
30
|
-
DefaultLogger.debug("Handlers::MessageHandler#notify_readable")
|
30
|
+
DefaultLogger.debug("Handlers::MessageHandler#notify_readable")
|
31
31
|
|
32
32
|
# Grab everything from buffer, in case several messages have built up.
|
33
33
|
# NB: Can't use gets or read because they block when reaching EOF.
|
@@ -44,9 +44,9 @@ module PipelineToolkit
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def receive_line(message_coded)
|
47
|
-
DefaultLogger.debug("Raw message: #{message_coded}")
|
47
|
+
DefaultLogger.debug("Raw message: #{message_coded}")
|
48
48
|
message = MessageCoder.decode(message_coded)
|
49
|
-
DefaultLogger.debug("Message: #{message.inspect}")
|
49
|
+
DefaultLogger.debug("Message: #{message.inspect}")
|
50
50
|
@target.process(message)
|
51
51
|
rescue MessagePack::UnpackError => e
|
52
52
|
DefaultLogger.error("Couldn't unpack message: #{message_coded.inspect}")
|
@@ -50,7 +50,6 @@ module PipelineToolkit
|
|
50
50
|
# @param options<Hash> An options hash.
|
51
51
|
#
|
52
52
|
def initialize(options = {})
|
53
|
-
DefaultLogger.init_logger(options)
|
54
53
|
@options = options
|
55
54
|
end
|
56
55
|
|
@@ -59,7 +58,7 @@ module PipelineToolkit
|
|
59
58
|
# and starts watching the STDIN for new messages
|
60
59
|
#
|
61
60
|
def start
|
62
|
-
DefaultLogger.debug("MessageCommand#start")
|
61
|
+
DefaultLogger.debug("MessageCommand#start")
|
63
62
|
|
64
63
|
Signal.trap('INT') { self.stop }
|
65
64
|
Signal.trap('TERM') { self.stop }
|
@@ -103,7 +102,7 @@ module PipelineToolkit
|
|
103
102
|
# @param message<Hash> The decoded message
|
104
103
|
#
|
105
104
|
def process(message)
|
106
|
-
DefaultLogger.debug("MessageCommand#process(message)")
|
105
|
+
DefaultLogger.debug("MessageCommand#process(message)")
|
107
106
|
if message[:msg_type] == "system"
|
108
107
|
process_system(message)
|
109
108
|
else
|
@@ -118,7 +117,7 @@ module PipelineToolkit
|
|
118
117
|
#
|
119
118
|
def acknowledge(message)
|
120
119
|
return if message[:ack_id].nil?
|
121
|
-
DefaultLogger.debug("MessageCommand#acknowledge(message)")
|
120
|
+
DefaultLogger.debug("MessageCommand#acknowledge(message)")
|
122
121
|
ack_message = {:msg_type => "ack", :ack_id => message[:ack_id]}
|
123
122
|
write_to_pipe(ack_message, @ack_pipe)
|
124
123
|
end
|
@@ -129,7 +128,7 @@ module PipelineToolkit
|
|
129
128
|
# @param message<Hash> The message to pass on
|
130
129
|
#
|
131
130
|
def pass_on(message)
|
132
|
-
DefaultLogger.debug("MessageCommand#pass_on(message)")
|
131
|
+
DefaultLogger.debug("MessageCommand#pass_on(message)")
|
133
132
|
write_to_pipe(message)
|
134
133
|
end
|
135
134
|
|
@@ -139,7 +138,7 @@ module PipelineToolkit
|
|
139
138
|
# has started.
|
140
139
|
#
|
141
140
|
def initialize_machine
|
142
|
-
DefaultLogger.debug("MessageCommand#initialize_machine")
|
141
|
+
DefaultLogger.debug("MessageCommand#initialize_machine")
|
143
142
|
# Implemented in class that includes me
|
144
143
|
end
|
145
144
|
|
@@ -152,7 +151,7 @@ module PipelineToolkit
|
|
152
151
|
# message has been dealt with. All messages must be acknowledged by at least one worker in a pipeline.
|
153
152
|
#
|
154
153
|
def process_standard(message)
|
155
|
-
DefaultLogger.debug("MessageCommand#process_standard(message)")
|
154
|
+
DefaultLogger.debug("MessageCommand#process_standard(message)")
|
156
155
|
# Implemented in class that includes me
|
157
156
|
pass_on(message)
|
158
157
|
end
|
@@ -174,7 +173,7 @@ module PipelineToolkit
|
|
174
173
|
# @param message<Hash> The system message
|
175
174
|
#
|
176
175
|
def process_system(message)
|
177
|
-
DefaultLogger.debug("MessageCommand#process_system(message)")
|
176
|
+
DefaultLogger.debug("MessageCommand#process_system(message)")
|
178
177
|
options[:ack] = message[:ack] # inherit setting from upstream
|
179
178
|
@ack_pipe = File.open(message[:sys_pipe], "w") # open ack pipe (needs to already exist)
|
180
179
|
send_description
|
@@ -17,7 +17,10 @@ module PipelineToolkit
|
|
17
17
|
#
|
18
18
|
def initialize(options = {})
|
19
19
|
super(options)
|
20
|
-
|
20
|
+
|
21
|
+
DefaultLogger.init_logger(options) if options[:log_conf]
|
22
|
+
|
23
|
+
DefaultLogger.debug("MessagePusher#initialize(options = {})")
|
21
24
|
|
22
25
|
queues_string = options[:queues].map { |name, type| "#{name} (key:#{type})" }.join(",")
|
23
26
|
DefaultLogger.info "================================================================"
|
@@ -32,7 +35,7 @@ module PipelineToolkit
|
|
32
35
|
# Initialize the AMQP server connection and exchange so we can write messages to the queue.
|
33
36
|
#
|
34
37
|
def initialize_machine
|
35
|
-
DefaultLogger.debug("MessagePusher#initialize_machine")
|
38
|
+
DefaultLogger.debug("MessagePusher#initialize_machine")
|
36
39
|
initialize_writer
|
37
40
|
initialize_queues
|
38
41
|
end
|
@@ -56,7 +59,7 @@ module PipelineToolkit
|
|
56
59
|
# @param message<Hash> The message to write to the exchange.
|
57
60
|
#
|
58
61
|
def process_standard(message)
|
59
|
-
DefaultLogger.debug("MessagePusher#process_standard(message)")
|
62
|
+
DefaultLogger.debug("MessagePusher#process_standard(message)")
|
60
63
|
publish(message.except_keys(:ack_id))
|
61
64
|
acknowledge(message) if options[:ack] && message[:ack_id]
|
62
65
|
end
|
@@ -27,11 +27,10 @@ module PipelineToolkit
|
|
27
27
|
# @param options<Hash> An options hash, see command line interface.
|
28
28
|
#
|
29
29
|
def initialize(options = {})
|
30
|
-
|
31
|
-
DefaultLogger.init_logger(options)
|
32
|
-
|
33
30
|
@options = options
|
34
31
|
options[:ack] = !options[:no_acks]
|
32
|
+
|
33
|
+
DefaultLogger.init_logger(options) if options[:log_conf]
|
35
34
|
|
36
35
|
DefaultLogger.info "================================================================"
|
37
36
|
DefaultLogger.info "Booting #{self.class.name} (#{options[:env]})"
|
@@ -17,7 +17,6 @@ module PipelineToolkit
|
|
17
17
|
# @param message_subscriber<MessageSubscriber> The message subscriber
|
18
18
|
#
|
19
19
|
def initialize(message_subscriber, options = {})
|
20
|
-
DefaultLogger.init_logger(options)
|
21
20
|
@options = options
|
22
21
|
@message_subscriber = message_subscriber
|
23
22
|
@html_template = ERB.new(File.read(File.dirname(__FILE__) + "/monitor.erb"))
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipeline_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 1.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 1.3.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Aisha Fenton
|
@@ -15,16 +16,18 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2010-
|
19
|
+
date: 2010-12-14 00:00:00 +13:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
22
23
|
name: amqp
|
23
24
|
prerelease: false
|
24
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
25
27
|
requirements:
|
26
28
|
- - ~>
|
27
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 9
|
28
31
|
segments:
|
29
32
|
- 0
|
30
33
|
- 6
|
@@ -36,9 +39,11 @@ dependencies:
|
|
36
39
|
name: trollop
|
37
40
|
prerelease: false
|
38
41
|
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
39
43
|
requirements:
|
40
44
|
- - ~>
|
41
45
|
- !ruby/object:Gem::Version
|
46
|
+
hash: 47
|
42
47
|
segments:
|
43
48
|
- 1
|
44
49
|
- 16
|
@@ -49,9 +54,11 @@ dependencies:
|
|
49
54
|
name: eventmachine
|
50
55
|
prerelease: false
|
51
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
52
58
|
requirements:
|
53
59
|
- - ~>
|
54
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 59
|
55
62
|
segments:
|
56
63
|
- 0
|
57
64
|
- 12
|
@@ -63,9 +70,11 @@ dependencies:
|
|
63
70
|
name: eventmachine_httpserver
|
64
71
|
prerelease: false
|
65
72
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
66
74
|
requirements:
|
67
75
|
- - ~>
|
68
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 23
|
69
78
|
segments:
|
70
79
|
- 0
|
71
80
|
- 2
|
@@ -74,74 +83,98 @@ dependencies:
|
|
74
83
|
type: :runtime
|
75
84
|
version_requirements: *id004
|
76
85
|
- !ruby/object:Gem::Dependency
|
77
|
-
name:
|
86
|
+
name: msgpack
|
78
87
|
prerelease: false
|
79
88
|
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
80
90
|
requirements:
|
81
91
|
- - ~>
|
82
92
|
- !ruby/object:Gem::Version
|
93
|
+
hash: 9
|
83
94
|
segments:
|
84
|
-
- 1
|
85
|
-
- 4
|
86
95
|
- 0
|
87
|
-
|
96
|
+
- 4
|
97
|
+
- 3
|
98
|
+
version: 0.4.3
|
88
99
|
type: :runtime
|
89
100
|
version_requirements: *id005
|
90
101
|
- !ruby/object:Gem::Dependency
|
91
|
-
name:
|
102
|
+
name: log4r
|
92
103
|
prerelease: false
|
93
104
|
requirement: &id006 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
94
106
|
requirements:
|
95
107
|
- - ~>
|
96
108
|
- !ruby/object:Gem::Version
|
109
|
+
hash: 1
|
97
110
|
segments:
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
101
|
-
version:
|
111
|
+
- 1
|
112
|
+
- 1
|
113
|
+
- 9
|
114
|
+
version: 1.1.9
|
102
115
|
type: :runtime
|
103
116
|
version_requirements: *id006
|
104
117
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
118
|
+
name: json
|
106
119
|
prerelease: false
|
107
120
|
requirement: &id007 !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
hash: 3
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
version: "0"
|
129
|
+
type: :runtime
|
130
|
+
version_requirements: *id007
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: cucumber
|
133
|
+
prerelease: false
|
134
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
108
136
|
requirements:
|
109
137
|
- - ~>
|
110
138
|
- !ruby/object:Gem::Version
|
139
|
+
hash: 53
|
111
140
|
segments:
|
112
141
|
- 0
|
113
142
|
- 8
|
114
143
|
- 5
|
115
144
|
version: 0.8.5
|
116
145
|
type: :development
|
117
|
-
version_requirements: *
|
146
|
+
version_requirements: *id008
|
118
147
|
- !ruby/object:Gem::Dependency
|
119
148
|
name: bunny
|
120
149
|
prerelease: false
|
121
|
-
requirement: &
|
150
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
122
152
|
requirements:
|
123
153
|
- - ~>
|
124
154
|
- !ruby/object:Gem::Version
|
155
|
+
hash: 7
|
125
156
|
segments:
|
126
157
|
- 0
|
127
158
|
- 6
|
128
159
|
- 0
|
129
160
|
version: 0.6.0
|
130
161
|
type: :development
|
131
|
-
version_requirements: *
|
162
|
+
version_requirements: *id009
|
132
163
|
- !ruby/object:Gem::Dependency
|
133
164
|
name: background_process
|
134
165
|
prerelease: false
|
135
|
-
requirement: &
|
166
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
167
|
+
none: false
|
136
168
|
requirements:
|
137
169
|
- - ~>
|
138
170
|
- !ruby/object:Gem::Version
|
171
|
+
hash: 11
|
139
172
|
segments:
|
140
173
|
- 1
|
141
174
|
- 2
|
142
175
|
version: "1.2"
|
143
176
|
type: :development
|
144
|
-
version_requirements: *
|
177
|
+
version_requirements: *id010
|
145
178
|
description: |-
|
146
179
|
Command line tools for processing messages by constructing a pipeline of workers.
|
147
180
|
AMQP and Unix pipes are used to construct the pipeline. Messages are simple Hashes
|
@@ -188,33 +221,41 @@ files:
|
|
188
221
|
- lib/pipeline_toolkit/util/socket_util.rb
|
189
222
|
- LICENSE.markdown
|
190
223
|
- README.markdown
|
224
|
+
- bin/msg_subscribe
|
225
|
+
- bin/msg_push
|
226
|
+
- bin/msg_sink
|
227
|
+
- bin/msg_generator
|
191
228
|
has_rdoc: true
|
192
229
|
homepage: http://github.com/visfleet/pipeline_toolkit
|
193
230
|
licenses: []
|
194
231
|
|
195
232
|
post_install_message:
|
196
|
-
rdoc_options:
|
197
|
-
|
233
|
+
rdoc_options: []
|
234
|
+
|
198
235
|
require_paths:
|
199
236
|
- lib
|
200
237
|
required_ruby_version: !ruby/object:Gem::Requirement
|
238
|
+
none: false
|
201
239
|
requirements:
|
202
240
|
- - ">="
|
203
241
|
- !ruby/object:Gem::Version
|
242
|
+
hash: 3
|
204
243
|
segments:
|
205
244
|
- 0
|
206
245
|
version: "0"
|
207
246
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
247
|
+
none: false
|
208
248
|
requirements:
|
209
249
|
- - ">="
|
210
250
|
- !ruby/object:Gem::Version
|
251
|
+
hash: 3
|
211
252
|
segments:
|
212
253
|
- 0
|
213
254
|
version: "0"
|
214
255
|
requirements: []
|
215
256
|
|
216
257
|
rubyforge_project:
|
217
|
-
rubygems_version: 1.3.
|
258
|
+
rubygems_version: 1.3.7
|
218
259
|
signing_key:
|
219
260
|
specification_version: 3
|
220
261
|
summary: Toolkit for building processing pipelines using Unix Pipes and AMQP messages
|