karma_messages 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +1 -4
- data/Gemfile.lock +2 -0
- data/karma_messages.gemspec +2 -11
- data/lib/karma_messages/base.rb +5 -1
- data/lib/karma_messages/base_karma.rb +3 -0
- data/lib/karma_messages/base_karmap.rb +3 -0
- data/lib/karma_messages/process_command_message.rb +6 -6
- data/lib/karma_messages/process_config_update_message.rb +21 -7
- data/lib/karma_messages/process_register_message.rb +35 -1
- data/lib/karma_messages/process_status_update_message.rb +3 -4
- data/lib/karma_messages/thread_config_update_message.rb +13 -2
- data/lib/karma_messages/version.rb +1 -1
- data/lib/karma_messages.rb +2 -5
- metadata +6 -6
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ab2bc4ab71e723d3d19fb93a3a60e7478e425d8
|
4
|
+
data.tar.gz: c0c3933008d8fc32529f881d7de6f0c9c4f8a18f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edfa09e8f3125baf49e63b72e88d6cf97e27a9e7661467c605024fd1c08e4b716b61702a5aff6cd74d1141a4db6c09230d9c6d8b171806bda951b1d1ec6c6109
|
7
|
+
data.tar.gz: 3cd3d2e13d9f8e1b58081d254466c6a3b703fd307a5714cdd6b7fc0aa6996993fdd26ee37ee416610c8301dc81e8192e11295ce21dcdc88d38fccdd8ca479807
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
4
|
-
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
5
|
-
gem 'byebug', platform: :mri
|
6
|
-
end
|
3
|
+
gem 'byebug'
|
7
4
|
|
8
5
|
# Specify your gem's dependencies in karma_messages.gemspec
|
9
6
|
gemspec
|
data/Gemfile.lock
CHANGED
data/karma_messages.gemspec
CHANGED
@@ -9,19 +9,10 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["extendi"]
|
10
10
|
spec.email = ["info@extendi.it"]
|
11
11
|
|
12
|
-
spec.summary = "
|
13
|
-
spec.description = ""
|
12
|
+
spec.summary = "summary"
|
13
|
+
spec.description = "desription"
|
14
14
|
spec.homepage = "http://extendi.it"
|
15
15
|
|
16
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
-
# if spec.respond_to?(:metadata)
|
19
|
-
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
-
# else
|
21
|
-
# raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
-
# "public gem pushes."
|
23
|
-
# end
|
24
|
-
|
25
16
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
17
|
f.match(%r{^(test|spec|features)/})
|
27
18
|
end
|
data/lib/karma_messages/base.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
module Karma::Messages
|
2
|
+
|
2
3
|
class Base
|
4
|
+
|
3
5
|
attr_accessor :errors, :service
|
4
6
|
|
5
7
|
def initialize(params)
|
8
|
+
Karma::Messages.logger.debug("#{self.class.name} - #{params}")
|
6
9
|
parse(params)
|
10
|
+
Karma::Messages.logger.warn("Message is invalid: - #{errors}") if errors.any?
|
7
11
|
end
|
8
12
|
|
9
13
|
def to_message
|
@@ -13,7 +17,6 @@ module Karma::Messages
|
|
13
17
|
def parse(params)
|
14
18
|
clear_errors
|
15
19
|
@errors << {service: 'Required'} if params[:service].nil?
|
16
|
-
|
17
20
|
@service = params[:service]
|
18
21
|
end
|
19
22
|
|
@@ -30,6 +33,7 @@ module Karma::Messages
|
|
30
33
|
end
|
31
34
|
|
32
35
|
end
|
36
|
+
|
33
37
|
end
|
34
38
|
|
35
39
|
require "karma_messages/base_karma"
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Karma::Messages
|
2
|
+
|
2
3
|
class ProcessCommandMessage < BaseKarmap
|
3
4
|
|
4
|
-
|
5
|
+
attr_reader :command, :pid
|
5
6
|
|
6
|
-
COMMANDS =
|
7
|
+
COMMANDS = {start: 'start', stop: 'stop', restart: 'restart'}.freeze
|
7
8
|
|
8
9
|
def self.services=(val)
|
9
10
|
@@services = val
|
@@ -14,8 +15,6 @@ module Karma::Messages
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def initialize(params)
|
17
|
-
Karma::Messages.logger.debug("ProcessCommandMessage::initialize")
|
18
|
-
Karma::Messages.logger.debug(params)
|
19
18
|
super(params)
|
20
19
|
end
|
21
20
|
|
@@ -24,7 +23,7 @@ module Karma::Messages
|
|
24
23
|
@@services ||= {}
|
25
24
|
@errors << {service: 'Not a valid service'} if !@@services.empty? && !@@services.include?(params[:service])
|
26
25
|
@errors << {command: 'Required'} if params[:command].nil?
|
27
|
-
@errors << {command: 'Not a valid command'} if !params[:command].nil? && !COMMANDS.include?(params[:command])
|
26
|
+
@errors << {command: 'Not a valid command'} if !params[:command].nil? && !COMMANDS.values.include?(params[:command])
|
28
27
|
@errors << {pid: 'Required'} if params[:command] == 'stop' && params[:pid].nil?
|
29
28
|
|
30
29
|
@command = params[:command]
|
@@ -34,9 +33,10 @@ module Karma::Messages
|
|
34
33
|
def to_message
|
35
34
|
ret = super
|
36
35
|
ret.merge!({ type: message_type, command: @command})
|
37
|
-
ret.merge!({ pid: @pid}) if @command
|
36
|
+
ret.merge!({ pid: @pid}) if @command != COMMANDS[:start]
|
38
37
|
ret
|
39
38
|
end
|
40
39
|
|
41
40
|
end
|
41
|
+
|
42
42
|
end
|
@@ -1,18 +1,17 @@
|
|
1
1
|
module Karma::Messages
|
2
|
+
|
2
3
|
class ProcessConfigUpdateMessage < BaseKarmap
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
attr_reader :memory_max, :cpu_quota, :min_running, :max_running, :auto_restart, :auto_start
|
6
|
+
|
6
7
|
def parse(params)
|
7
8
|
super(params)
|
8
9
|
|
9
|
-
@errors << { memory_max: 'Required' } if params[:memory_max].nil?
|
10
|
-
@errors << { cpu_quota: 'Required' } if params[:cpu_quota].nil?
|
11
10
|
@errors << { min_running: 'Required' } if params[:min_running].nil?
|
12
11
|
@errors << { max_running: 'Required' } if params[:max_running].nil?
|
13
12
|
@errors << { auto_restart: 'Required' } if params[:auto_restart].nil?
|
14
13
|
@errors << { auto_start: 'Required' } if params[:auto_start].nil?
|
15
|
-
|
14
|
+
|
16
15
|
@memory_max = params[:memory_max]
|
17
16
|
@cpu_quota = params[:cpu_quota]
|
18
17
|
@min_running = params[:min_running]
|
@@ -24,8 +23,23 @@ module Karma::Messages
|
|
24
23
|
|
25
24
|
def to_message
|
26
25
|
ret = super
|
27
|
-
ret.merge!({
|
26
|
+
ret.merge!({ min_running: @min_running, max_running: @max_running, auto_restart: @auto_restart, auto_start: @auto_start })
|
27
|
+
ret.merge!({ memory_max: @memory_max} ) if !@memory_max.nil?
|
28
|
+
ret.merge!({ cpu_quota: @cpu_quota} ) if !@cpu_quota.nil?
|
28
29
|
ret
|
29
30
|
end
|
31
|
+
|
32
|
+
def to_config
|
33
|
+
{
|
34
|
+
memory_max: memory_max,
|
35
|
+
cpu_quota: cpu_quota,
|
36
|
+
min_running: min_running,
|
37
|
+
max_running: max_running,
|
38
|
+
auto_restart: auto_restart,
|
39
|
+
auto_start: auto_start
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
30
43
|
end
|
44
|
+
|
31
45
|
end
|
@@ -1,5 +1,39 @@
|
|
1
1
|
module Karma::Messages
|
2
|
+
|
2
3
|
class ProcessRegisterMessage < BaseKarma
|
3
|
-
|
4
|
+
|
5
|
+
attr_reader :memory_max, :cpu_quota, :min_running, :max_running, :auto_restart, :auto_start, :log_level, :num_threads, :overwrite
|
6
|
+
|
7
|
+
def parse(params)
|
8
|
+
super(params)
|
9
|
+
@errors << {min_running: 'Required'} if params[:min_running].nil?
|
10
|
+
@errors << {max_running: 'Required'} if params[:max_running].nil?
|
11
|
+
@errors << {auto_restart: 'Required'} if params[:auto_restart].nil?
|
12
|
+
@errors << {auto_start: 'Required'} if params[:auto_start].nil?
|
13
|
+
@errors << {log_level: 'Required'} if params[:log_level].nil?
|
14
|
+
@errors << {num_threads: 'Required'} if params[:num_threads].nil?
|
15
|
+
|
16
|
+
@memory_max = params[:memory_max]
|
17
|
+
@cpu_quota = params[:cpu_quota]
|
18
|
+
@min_running = params[:min_running]
|
19
|
+
@max_running = params[:max_running]
|
20
|
+
@auto_restart = params[:auto_restart]
|
21
|
+
@auto_start = params[:auto_start]
|
22
|
+
@log_level = params[:log_level]
|
23
|
+
@num_threads = params[:num_threads]
|
24
|
+
@overwrite = params[:overwrite] || false
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_message
|
28
|
+
ret = super
|
29
|
+
ret.merge!({ min_running: @min_running, max_running: @max_running,
|
30
|
+
auto_restart: @auto_restart, auto_start: @auto_start,
|
31
|
+
memory_max: @memory_max, cpu_quota: @cpu_quota})
|
32
|
+
ret.merge!({ log_level: @log_level, num_threads: @num_threads })
|
33
|
+
ret.merge!({ overwrite: @overwrite })
|
34
|
+
ret
|
35
|
+
end
|
36
|
+
|
4
37
|
end
|
38
|
+
|
5
39
|
end
|
@@ -1,24 +1,23 @@
|
|
1
1
|
module Karma::Messages
|
2
|
+
|
2
3
|
class ProcessStatusUpdateMessage < BaseKarma
|
3
4
|
|
4
5
|
STATUSES = {running: 'running', stopped: 'stopped', dead: 'dead'}.freeze
|
5
6
|
|
6
|
-
attr_reader :pid, :
|
7
|
+
attr_reader :pid, :status
|
7
8
|
|
8
9
|
def parse(params)
|
9
10
|
super(params)
|
10
11
|
@errors << {pid: 'Required'} if params[:pid].nil?
|
11
|
-
@errors << {instance_name: 'Required'} if params[:instance_name].nil?
|
12
12
|
@errors << {status: 'Not a valid status'} if params[:status].nil? && !STATUSES.values.include?(params[:status])
|
13
13
|
|
14
14
|
@pid = params[:pid]
|
15
|
-
@instance_name = params[:instance_name]
|
16
15
|
@status = params[:status]
|
17
16
|
end
|
18
17
|
|
19
18
|
def to_message
|
20
19
|
ret = super
|
21
|
-
ret.merge!({ pid: @pid,
|
20
|
+
ret.merge!({ pid: @pid, status: @status })
|
22
21
|
end
|
23
22
|
|
24
23
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Karma::Messages
|
2
|
+
|
2
3
|
class ThreadConfigUpdateMessage < BaseKarmap
|
3
|
-
|
4
|
+
|
5
|
+
attr_reader :log_level, :num_threads
|
4
6
|
|
5
7
|
def parse(params)
|
6
8
|
super(params)
|
@@ -15,8 +17,17 @@ module Karma::Messages
|
|
15
17
|
|
16
18
|
def to_message
|
17
19
|
ret = super
|
18
|
-
ret.merge!({
|
20
|
+
ret.merge!({ log_level: @log_level, num_threads: @num_threads })
|
19
21
|
ret
|
20
22
|
end
|
23
|
+
|
24
|
+
def to_config
|
25
|
+
{
|
26
|
+
num_threads: num_threads,
|
27
|
+
log_level: log_level
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
21
31
|
end
|
32
|
+
|
22
33
|
end
|
data/lib/karma_messages.rb
CHANGED
@@ -2,18 +2,15 @@ require 'logger'
|
|
2
2
|
|
3
3
|
module Karma
|
4
4
|
module Messages
|
5
|
-
|
6
5
|
class << self
|
7
6
|
attr_writer :logger
|
8
|
-
|
9
7
|
def logger
|
10
|
-
|
11
|
-
|
8
|
+
@logger ||= Logger.new($stdout, 2, 52428800).tap do |log|
|
9
|
+
log.level = Logger::INFO
|
12
10
|
log.progname = self.name
|
13
11
|
end
|
14
12
|
end
|
15
13
|
end
|
16
|
-
|
17
14
|
end
|
18
15
|
end
|
19
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: karma_messages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- extendi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description:
|
55
|
+
description: desription
|
56
56
|
email:
|
57
57
|
- info@extendi.it
|
58
58
|
executables: []
|
@@ -61,7 +61,6 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- ".editorconfig"
|
63
63
|
- ".gitignore"
|
64
|
-
- ".ruby-version"
|
65
64
|
- Gemfile
|
66
65
|
- Gemfile.lock
|
67
66
|
- README.md
|
@@ -98,8 +97,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
97
|
version: '0'
|
99
98
|
requirements: []
|
100
99
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.4.5
|
102
101
|
signing_key:
|
103
102
|
specification_version: 4
|
104
|
-
summary:
|
103
|
+
summary: summary
|
105
104
|
test_files: []
|
105
|
+
has_rdoc:
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.4.0
|