Revision 20533c4d
Added by Marc Dequènes almost 14 years ago
- ID 20533c4dccb0cbb6da9f4689975523e16763f2ba
bin/test_client | ||
---|---|---|
set_user "guihome"
|
||
set_preferred_locales "fr"
|
||
#ask "Clerk", :dns_info, "/Commands/DNS/INFO"
|
||
ask "Clerk", :dns_info, "/Batch/taiste"
|
||
# ask "Clerk", :dns_info, "/Batch", {
|
||
# :commands => [
|
||
# ["DNS", "INFO"]
|
||
# # ["DNS", "INFO"]
|
||
# ]
|
||
# }
|
||
ask "Clerk", :super_batch, "/Batch", {
|
||
:commands => [
|
||
["DNS", "INFOZZZ"],
|
||
["DNS", "INFO"]
|
||
],
|
||
:references => {},
|
||
:options => {:stop_on_error => false}
|
||
}
|
||
on_error do
|
||
puts "PLOUF"
|
||
pp errors
|
lib/cyborghood-clerk/interface/0_base.rb | ||
---|---|---|
node 'Commands', :dir => '_commands'
|
||
|
||
node 'Batch' do
|
||
# TODO
|
||
on_request do |request|
|
||
task 'batch_commands' do
|
||
# propagate environment
|
||
set_user request.env.user
|
||
set_preferred_locales request.env.preferred_locales
|
||
|
||
# test node
|
||
node 'taiste' do
|
||
on_request do |request|
|
||
task 'batch_commands' do
|
||
# propagate environment
|
||
set_user request.env.user
|
||
set_preferred_locales request.env.preferred_locales
|
||
store.request = request
|
||
|
||
ask :self, :dns_info, "/Commands/DNS/INFO"
|
||
on_error do
|
||
puts "Batch PLOUF"
|
||
request.reply.errors << "Internal error"
|
||
request.send_reply
|
||
end
|
||
on_success do
|
||
request.reply.results = results[:dns_info]
|
||
request.send_reply
|
||
end
|
||
store.remaining_commands = request.args.first[:commands]
|
||
store.batch_result = []
|
||
|
||
on_error do
|
||
request.reply.errors << "Internal error"
|
||
request.send_reply
|
||
end
|
||
|
||
on_success :file => '_batch_run_loop'
|
||
end
|
||
end
|
||
end
|
lib/cyborghood-clerk/tasks/_batch_run_loop.rb | ||
---|---|---|
|
||
if results.include? :command_result
|
||
store.batch_result << results[:command_result]
|
||
end
|
||
|
||
command = store.remaining_commands.shift
|
||
if command.nil?
|
||
store.request.reply.results = store.batch_result
|
||
store.request.send_reply
|
||
else
|
||
command = command.join('/') if command.is_a? Array
|
||
|
||
ask :self, :command_result, "/Commands/" + command
|
||
|
||
on_success :file => '_batch_run_loop'
|
||
end
|
||
|
||
on_error do
|
||
options = store.request.args.first[:options]
|
||
soe = options.include?(:stop_on_error) ? options[:stop_on_error] : true
|
||
|
||
if soe
|
||
store.request.reply.errors << errors
|
||
store.request.send_reply
|
||
else
|
||
store.batch_result << nil
|
||
# TODO: error handling needs rework
|
||
#store.request.reply.errors << errors
|
||
# continue
|
||
on_success :file => '_batch_run_loop'
|
||
end
|
||
end
|
Also available in: Unified diff
[evol] Clerk: implement batch command execution (error handling needs to
be polished)