prometheus-splash 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,15 @@ module Splash
4
4
  module Grammar
5
5
 
6
6
  include Splash::Config
7
- VERBS=[:ping,:list_commands,:execute_command,:ack_command]
7
+ include Splash::Loggers
8
+
9
+
10
+ VERBS=[:ping,:list_commands,:execute_command,:ack_command, :shutdown]
11
+
12
+
13
+ def shutdown
14
+ self.terminate
15
+ end
8
16
 
9
17
  def ping(payload)
10
18
  return "Pong : #{payload[:hostname]} !"
@@ -22,21 +30,20 @@ module Splash
22
30
 
23
31
  def execute_command(payload)
24
32
  unless get_config.commands.include? payload[:name].to_sym
25
- puts " * Command not found"
33
+ @log.item "Command not found"
26
34
  return { :case => :not_found }
27
35
  end
28
36
  if payload.include? :schedule then
29
37
  sched,value = payload[:schedule].flatten
30
- puts " * Schedule remote call command #{payload[:name]}, scheduling : #{sched.to_s} #{value}"
38
+ @log.schedule "remote call command #{payload[:name]}, scheduling : #{sched.to_s} #{value}"
31
39
  @server.send sched,value do
40
+ @log.trigger "Executing Scheduled command #{payload[:name]} for Scheduling : #{sched.to_s} #{value}"
32
41
  self.execute command: payload[:name]
33
42
  end
34
43
  return { :case => :quiet_exit }
35
44
  else
36
- puts " * Execute direct command"
37
- puts payload[:name]
45
+ @log.info "Execute direct command"
38
46
  res = self.execute command: payload[:name]
39
- puts res.inspect
40
47
  return res
41
48
  end
42
49
  end
@@ -16,7 +16,7 @@ module Splash
16
16
  begin
17
17
  return Kernel.const_get(aclass)::new(options)
18
18
  rescue
19
- return { :case => :configuration_error, :more => "Transport specified for queue #{options[:queue]} inexistant : #{transport}"}
19
+ return { :case => :configuration_error, :more => "Transport specified for queue #{options[:queue]} configuration error : #{transport}"}
20
20
  end
21
21
  end
22
22
 
@@ -32,7 +32,7 @@ module Splash
32
32
  begin
33
33
  return Kernel.const_get(aclass)::new
34
34
  rescue
35
- return { :case => :configuration_error, :more => "Transport specified inexistant : #{transport}"}
35
+ return { :case => :configuration_error, :more => "Transport configuration error : #{transport}"}
36
36
  end
37
37
  end
38
38
 
@@ -11,9 +11,15 @@ module Splash
11
11
 
12
12
  def initialize(options = {})
13
13
  @config = get_config.transports
14
+ @url = "amqp://"
14
15
  host = @config[:rabbitmq][:host]
15
16
  port = @config[:rabbitmq][:port]
16
- @url = "amqp://#{host}:#{port}"
17
+ vhost = @config[:rabbitmq][:vhost]
18
+ if @config[:rabbitmq][:user] and @config[:rabbitmq][:passwd] then
19
+ creds = "#{@config[:rabbitmq][:user]}:#{@config[:rabbitmq][:passwd]}@"
20
+ @url << creds
21
+ end
22
+ @url << "#{host}:#{port}#{vhost}"
17
23
  begin
18
24
  @connection = Bunny.new url: @url
19
25
  @connection.start
@@ -31,12 +37,19 @@ module Splash
31
37
  class Client
32
38
  include Splash::Config
33
39
  include Splash::Transports
40
+ include Splash::Loggers
34
41
 
35
42
  def initialize
36
43
  @config = get_config.transports
44
+ @url = "amqp://"
37
45
  host = @config[:rabbitmq][:host]
38
46
  port = @config[:rabbitmq][:port]
39
- @url = "amqp://#{host}:#{port}"
47
+ vhost = @config[:rabbitmq][:vhost]
48
+ if @config[:rabbitmq][:user] and @config[:rabbitmq][:passwd] then
49
+ creds = "#{@config[:rabbitmq][:user]}:#{@config[:rabbitmq][:passwd]}@"
50
+ @url << creds
51
+ end
52
+ @url << "#{host}:#{port}#{vhost}"
40
53
  begin
41
54
  @connection = Bunny.new url: @url
42
55
  @connection.start
@@ -69,6 +82,7 @@ module Splash
69
82
 
70
83
  lock.synchronize { condition.signal }
71
84
  end
85
+ get_logger.send "Verb : #{order[:verb].to_s} to queue : #{order[:queue]}."
72
86
  get_default_client.publish queue: order[:queue], message: order.to_yaml
73
87
  lock.synchronize { condition.wait(lock) }
74
88
  return res
@@ -25,7 +25,8 @@ Gem::Specification.new do |spec|
25
25
  spec.add_runtime_dependency 'redis','~> 4.1.3'
26
26
  spec.add_runtime_dependency 'bunny','~> 2.15.0'
27
27
  spec.add_runtime_dependency 'tty-markdown','~> 0.6.0'
28
- spec.add_runtime_dependency 'tty-pager','~> 0.12.1'
28
+ spec.add_runtime_dependency 'tty-pager','~> 0.12.1'
29
+ spec.add_runtime_dependency 'colorize','~> 0.8.1'
29
30
  spec.add_development_dependency 'rake', '~> 13.0.1'
30
31
  spec.add_development_dependency 'rspec', '~> 3.9.0'
31
32
  spec.add_development_dependency 'yard', '~> 0.9.24'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prometheus-splash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain GEORGES
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-11 00:00:00.000000000 Z
11
+ date: 2020-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.12.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: colorize
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.8.1
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.8.1
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rake
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -215,6 +229,8 @@ executables:
215
229
  extensions: []
216
230
  extra_rdoc_files: []
217
231
  files:
232
+ - ".github/workflows/ruby.yml"
233
+ - CHANGELOG
218
234
  - Gemfile
219
235
  - LICENSE.txt
220
236
  - README.md
@@ -223,6 +239,7 @@ files:
223
239
  - assets/images/logo_splash.png
224
240
  - assets/images/logo_splash_reduce.png
225
241
  - assets/images/prom_pg_logs.png
242
+ - assets/images/splash_design.png
226
243
  - bin/splash
227
244
  - config/splash.yml
228
245
  - lib/splash/backends.rb
@@ -243,6 +260,10 @@ files:
243
260
  - lib/splash/dependencies.rb
244
261
  - lib/splash/exiter.rb
245
262
  - lib/splash/helpers.rb
263
+ - lib/splash/loggers.rb
264
+ - lib/splash/loggers/cli.rb
265
+ - lib/splash/loggers/daemon.rb
266
+ - lib/splash/loggers/dual.rb
246
267
  - lib/splash/logs.rb
247
268
  - lib/splash/orchestrator.rb
248
269
  - lib/splash/orchestrator/grammar.rb