legion-data 0.1.1 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +98 -72
- data/.gitignore +0 -1
- data/.rubocop.yml +5 -7
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +85 -0
- data/legion-data.gemspec +3 -6
- data/lib/legion/data.rb +51 -33
- data/lib/legion/data/connection.rb +55 -19
- data/lib/legion/data/migration.rb +7 -20
- data/lib/legion/data/migrations/001_add_schema_columns.rb +1 -1
- data/lib/legion/data/migrations/002_add_users.rb +17 -0
- data/lib/legion/data/migrations/003_add_groups.rb +16 -0
- data/lib/legion/data/migrations/004_add_chains.rb +25 -0
- data/lib/legion/data/migrations/005_add_envs.rb +24 -0
- data/lib/legion/data/migrations/006_add_dcs.rb +24 -0
- data/lib/legion/data/migrations/007_add_nodes.rb +26 -0
- data/lib/legion/data/migrations/008_add_settings.rb +18 -0
- data/lib/legion/data/migrations/009_add_extensions.rb +25 -0
- data/lib/legion/data/migrations/010_add_runners.rb +21 -0
- data/lib/legion/data/migrations/011_add_functions.rb +29 -0
- data/lib/legion/data/migrations/012_add_tasks.rb +28 -0
- data/lib/legion/data/migrations/013_add_task_logs.rb +23 -0
- data/lib/legion/data/migrations/014_add_relationships.rb +27 -0
- data/lib/legion/data/migrations/015_add_default_extensions.rb +24 -0
- data/lib/legion/data/migrations/016_change_task_args.rb +7 -0
- data/lib/legion/data/migrations/017_add_payload_task.rb +7 -0
- data/lib/legion/data/migrations/018_add_migration_column.rb +7 -0
- data/lib/legion/data/migrations/019_add_debug_to_relationships.rb +7 -0
- data/lib/legion/data/migrations/020_add_delay_debug_to_tasks.rb +8 -0
- data/lib/legion/data/model.rb +26 -25
- data/lib/legion/data/models/chain.rb +0 -1
- data/lib/legion/data/models/datacenter.rb +0 -1
- data/lib/legion/data/models/environment.rb +0 -1
- data/lib/legion/data/models/extension.rb +11 -0
- data/lib/legion/data/models/function.rb +5 -4
- data/lib/legion/data/models/group.rb +10 -0
- data/lib/legion/data/models/node.rb +1 -1
- data/lib/legion/data/models/relationship.rb +1 -1
- data/lib/legion/data/models/runner.rb +15 -0
- data/lib/legion/data/models/setting.rb +10 -0
- data/lib/legion/data/models/task.rb +0 -1
- data/lib/legion/data/models/task_log.rb +0 -1
- data/lib/legion/data/models/user.rb +10 -0
- data/lib/legion/data/settings.rb +68 -0
- data/lib/legion/data/version.rb +1 -1
- data/sonar-project.properties +12 -0
- metadata +38 -89
- data/lib/legion/data/connections/base.rb +0 -45
- data/lib/legion/data/connections/jdbc.rb +0 -21
- data/lib/legion/data/connections/mysql.rb +0 -26
- data/lib/legion/data/connections/mysql2.rb +0 -26
- data/lib/legion/data/connections/mysql_base.rb +0 -19
- data/lib/legion/data/migrations/002_add_chains_table.rb +0 -21
- data/lib/legion/data/migrations/003_add_datacenters_table.rb +0 -21
- data/lib/legion/data/migrations/004_add_envs_table.rb +0 -21
- data/lib/legion/data/migrations/005_add_functions_table.rb +0 -25
- data/lib/legion/data/migrations/006_add_namespaces_table.rb +0 -24
- data/lib/legion/data/migrations/007_add_nodes_table.rb +0 -22
- data/lib/legion/data/migrations/008_add_relationships_table.rb +0 -28
- data/lib/legion/data/migrations/009_add_task_logs_table.rb +0 -17
- data/lib/legion/data/migrations/010_add_tasks_table.rb +0 -20
- data/lib/legion/data/migrations/011_add_users_and_groups.rb +0 -28
- data/lib/legion/data/migrations/012_foreign_keys_users_and_groups.rb +0 -42
- data/lib/legion/data/migrations/013_function_foreign_keys.rb +0 -10
- data/lib/legion/data/migrations/014_nodes_foreign_keys.rb +0 -12
- data/lib/legion/data/migrations/015_relationships_foreign_keys.rb +0 -14
- data/lib/legion/data/migrations/016_tasks_foreign_keys.rb +0 -22
- data/lib/legion/data/migrations/017_add_relationship_to_tasks.rb +0 -14
- data/lib/legion/data/models/namespace.rb +0 -12
@@ -0,0 +1,24 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
lex = from(:extensions).insert(namespace: 'Legion::Extensions::Lex', name: 'lex', exchange: 'lex', uri: 'lex')
|
4
|
+
[
|
5
|
+
{ extension_id: lex, namespace: 'Legion::Extensions::Lex::Runners::Register', name: 'register', queue: 'register', uri: 'register' },
|
6
|
+
{ extension_id: lex, namespace: 'Legion::Extensions::Lex::Runners::Function', name: 'function', queue: 'function', uri: 'function' },
|
7
|
+
{ extension_id: lex, namespace: 'Legion::Extensions::Lex::Runners::Runner', name: 'runner', queue: 'runner', uri: 'runner' },
|
8
|
+
{ extension_id: lex, namespace: 'Legion::Extensions::Lex::Runners::Extension', name: 'extension', queue: 'extension', uri: 'extension' }
|
9
|
+
].each do |row|
|
10
|
+
from(:runners).insert row
|
11
|
+
end
|
12
|
+
|
13
|
+
lex = from(:extensions).insert(namespace: 'Legion::Extensions::Node', name: 'node', exchange: 'node', uri: 'node')
|
14
|
+
[
|
15
|
+
{ extension_id: lex, namespace: 'Legion::Extensions::Node::Runners::Crypt', name: 'crypt', queue: 'crypt', uri: 'crypt' }
|
16
|
+
].each do |row|
|
17
|
+
from(:runners).insert row
|
18
|
+
end
|
19
|
+
end
|
20
|
+
down do
|
21
|
+
from(:extensions).where(namespace: 'Legion::Extensions::Lex').delete
|
22
|
+
from(:extensions).where(namespace: 'Legion::Extensions::Node').delete
|
23
|
+
end
|
24
|
+
end
|
data/lib/legion/data/model.rb
CHANGED
@@ -1,34 +1,35 @@
|
|
1
1
|
module Legion
|
2
2
|
module Data
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
options.merge!(default_options) { |_key, v1, _v2| v1 }
|
7
|
-
@loaded_models = []
|
8
|
-
require_sequel_models if options[:auto_load]
|
9
|
-
end
|
3
|
+
module Models
|
4
|
+
class << self
|
5
|
+
attr_reader :loaded_models
|
10
6
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
7
|
+
def models
|
8
|
+
%w[user group extension chain relationship function task runner task_log datacenter environment node setting]
|
9
|
+
end
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
def load
|
12
|
+
Legion::Logging.info 'Loading Legion::Data::Models'
|
13
|
+
@loaded_models ||= []
|
14
|
+
require_sequel_models(models)
|
15
|
+
Legion::Settings[:data][:models][:loaded] = true
|
16
|
+
end
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
def require_sequel_models(files = models)
|
19
|
+
Dir["#{File.dirname(__FILE__)}models/*.rb"].each { |file| puts file }
|
20
|
+
files.each { |file| load_sequel_model(file) }
|
21
|
+
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
def load_sequel_model(model)
|
24
|
+
Legion::Logging.debug("Trying to load #{model}.rb")
|
25
|
+
require_relative "models/#{model}"
|
26
|
+
@loaded_models << model
|
27
|
+
Legion::Logging.debug("Successfully loaded #{model}")
|
28
|
+
model
|
29
|
+
rescue LoadError => e
|
30
|
+
Legion::Logging.fatal("Failed to load #{model}")
|
31
|
+
raise e unless Legion::Settings[:data][:models][:continue_on_fail]
|
32
|
+
end
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'relationship'
|
4
|
+
|
3
5
|
module Legion
|
4
6
|
module Data
|
5
7
|
module Model
|
6
|
-
# Used for accessing legion.functions
|
7
8
|
class Function < Sequel::Model
|
8
|
-
many_to_one :
|
9
|
-
one_to_many :
|
10
|
-
one_to_many :
|
9
|
+
many_to_one :runner
|
10
|
+
one_to_many :trigger_relationships, class: 'Legion::Data::Model::Relationship', key: :trigger_id
|
11
|
+
one_to_many :action_relationships, class: 'Legion::Data::Model::Relationship', key: :action_id
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'function'
|
4
|
+
module Legion
|
5
|
+
module Data
|
6
|
+
module Model
|
7
|
+
class Runner < Sequel::Model
|
8
|
+
many_to_one :chain
|
9
|
+
one_to_many :task
|
10
|
+
one_to_many :functions
|
11
|
+
many_to_one :extension
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Legion
|
2
|
+
module Data
|
3
|
+
module Settings
|
4
|
+
def self.default
|
5
|
+
{
|
6
|
+
connected: false,
|
7
|
+
cache: cache,
|
8
|
+
connection: connection,
|
9
|
+
creds: creds,
|
10
|
+
migrations: migrations,
|
11
|
+
models: models,
|
12
|
+
connect_on_start: true
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.models
|
17
|
+
{
|
18
|
+
continue_on_load_fail: false,
|
19
|
+
autoload: true
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.migrations
|
24
|
+
{
|
25
|
+
continue_on_fail: false,
|
26
|
+
auto_migrate: true,
|
27
|
+
ran: false,
|
28
|
+
version: nil
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.connection
|
33
|
+
{
|
34
|
+
log: false,
|
35
|
+
log_connection_info: false,
|
36
|
+
log_warn_duration: 1,
|
37
|
+
sql_log_level: 'debug',
|
38
|
+
max_connections: 10,
|
39
|
+
preconnect: false
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.creds
|
44
|
+
{
|
45
|
+
username: 'legion',
|
46
|
+
password: 'legion',
|
47
|
+
database: 'legion',
|
48
|
+
host: '127.0.0.1',
|
49
|
+
port: 3306
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.cache
|
54
|
+
{
|
55
|
+
connected: false,
|
56
|
+
auto_enable: Legion::Settings[:cache][:connected],
|
57
|
+
ttl: 60
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
begin
|
65
|
+
Legion::Settings.merge_settings('data', Legion::Data::Settings.default) if Legion.const_defined?('Settings')
|
66
|
+
rescue StandardError => e
|
67
|
+
Legion::Logging.fatal(e.message) if Legion::Logging.method_defined?(:fatal)
|
68
|
+
end
|
data/lib/legion/data/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
sonar.projectKey=legion-io_legion-data
|
2
|
+
sonar.organization=legion-io
|
3
|
+
sonar.projectName=Legion::Data
|
4
|
+
sonar.sources=.
|
5
|
+
sonar.exclusions=vendor/**
|
6
|
+
sonar.coverage.exclusions=spec/**
|
7
|
+
sonar.ruby.coverage.reportPath=coverage/.resultset.json
|
8
|
+
sonar.ruby.file.suffixes=rb,ruby
|
9
|
+
sonar.ruby.coverage.framework=RSpec
|
10
|
+
sonar.ruby.rubocopConfig=.rubocop.yml
|
11
|
+
sonar.ruby.rubocop.reportPath=rubocop-result.json
|
12
|
+
sonar.ruby.rubocop.filePath=.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legion-data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esity
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,41 +95,13 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rubocop-performance
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop-rspec
|
98
|
+
name: legion-logging
|
127
99
|
requirement: !ruby/object:Gem::Requirement
|
128
100
|
requirements:
|
129
101
|
- - ">="
|
130
102
|
- !ruby/object:Gem::Version
|
131
103
|
version: '0'
|
132
|
-
type: :
|
104
|
+
type: :runtime
|
133
105
|
prerelease: false
|
134
106
|
version_requirements: !ruby/object:Gem::Requirement
|
135
107
|
requirements:
|
@@ -137,47 +109,19 @@ dependencies:
|
|
137
109
|
- !ruby/object:Gem::Version
|
138
110
|
version: '0'
|
139
111
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
112
|
+
name: legion-settings
|
141
113
|
requirement: !ruby/object:Gem::Requirement
|
142
114
|
requirements:
|
143
115
|
- - ">="
|
144
116
|
- !ruby/object:Gem::Version
|
145
117
|
version: '0'
|
146
|
-
type: :
|
118
|
+
type: :runtime
|
147
119
|
prerelease: false
|
148
120
|
version_requirements: !ruby/object:Gem::Requirement
|
149
121
|
requirements:
|
150
122
|
- - ">="
|
151
123
|
- !ruby/object:Gem::Version
|
152
124
|
version: '0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: legion-logging
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0.1'
|
160
|
-
type: :runtime
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0.1'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: legion-settings
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - "~>"
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0.1'
|
174
|
-
type: :runtime
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - "~>"
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '0.1'
|
181
125
|
- !ruby/object:Gem::Dependency
|
182
126
|
name: mysql2
|
183
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,6 +163,7 @@ files:
|
|
219
163
|
- ".rubocop.yml"
|
220
164
|
- CHANGELOG.md
|
221
165
|
- Gemfile
|
166
|
+
- Gemfile.lock
|
222
167
|
- README.md
|
223
168
|
- Rakefile
|
224
169
|
- bin/console
|
@@ -227,40 +172,44 @@ files:
|
|
227
172
|
- legion-data.gemspec
|
228
173
|
- lib/legion/data.rb
|
229
174
|
- lib/legion/data/connection.rb
|
230
|
-
- lib/legion/data/connections/base.rb
|
231
|
-
- lib/legion/data/connections/jdbc.rb
|
232
|
-
- lib/legion/data/connections/mysql.rb
|
233
|
-
- lib/legion/data/connections/mysql2.rb
|
234
|
-
- lib/legion/data/connections/mysql_base.rb
|
235
175
|
- lib/legion/data/migration.rb
|
236
176
|
- lib/legion/data/migrations/001_add_schema_columns.rb
|
237
|
-
- lib/legion/data/migrations/
|
238
|
-
- lib/legion/data/migrations/
|
239
|
-
- lib/legion/data/migrations/
|
240
|
-
- lib/legion/data/migrations/
|
241
|
-
- lib/legion/data/migrations/
|
242
|
-
- lib/legion/data/migrations/
|
243
|
-
- lib/legion/data/migrations/
|
244
|
-
- lib/legion/data/migrations/
|
245
|
-
- lib/legion/data/migrations/
|
246
|
-
- lib/legion/data/migrations/
|
247
|
-
- lib/legion/data/migrations/
|
248
|
-
- lib/legion/data/migrations/
|
249
|
-
- lib/legion/data/migrations/
|
250
|
-
- lib/legion/data/migrations/
|
251
|
-
- lib/legion/data/migrations/
|
252
|
-
- lib/legion/data/migrations/
|
177
|
+
- lib/legion/data/migrations/002_add_users.rb
|
178
|
+
- lib/legion/data/migrations/003_add_groups.rb
|
179
|
+
- lib/legion/data/migrations/004_add_chains.rb
|
180
|
+
- lib/legion/data/migrations/005_add_envs.rb
|
181
|
+
- lib/legion/data/migrations/006_add_dcs.rb
|
182
|
+
- lib/legion/data/migrations/007_add_nodes.rb
|
183
|
+
- lib/legion/data/migrations/008_add_settings.rb
|
184
|
+
- lib/legion/data/migrations/009_add_extensions.rb
|
185
|
+
- lib/legion/data/migrations/010_add_runners.rb
|
186
|
+
- lib/legion/data/migrations/011_add_functions.rb
|
187
|
+
- lib/legion/data/migrations/012_add_tasks.rb
|
188
|
+
- lib/legion/data/migrations/013_add_task_logs.rb
|
189
|
+
- lib/legion/data/migrations/014_add_relationships.rb
|
190
|
+
- lib/legion/data/migrations/015_add_default_extensions.rb
|
191
|
+
- lib/legion/data/migrations/016_change_task_args.rb
|
192
|
+
- lib/legion/data/migrations/017_add_payload_task.rb
|
193
|
+
- lib/legion/data/migrations/018_add_migration_column.rb
|
194
|
+
- lib/legion/data/migrations/019_add_debug_to_relationships.rb
|
195
|
+
- lib/legion/data/migrations/020_add_delay_debug_to_tasks.rb
|
253
196
|
- lib/legion/data/model.rb
|
254
197
|
- lib/legion/data/models/chain.rb
|
255
198
|
- lib/legion/data/models/datacenter.rb
|
256
199
|
- lib/legion/data/models/environment.rb
|
200
|
+
- lib/legion/data/models/extension.rb
|
257
201
|
- lib/legion/data/models/function.rb
|
258
|
-
- lib/legion/data/models/
|
202
|
+
- lib/legion/data/models/group.rb
|
259
203
|
- lib/legion/data/models/node.rb
|
260
204
|
- lib/legion/data/models/relationship.rb
|
205
|
+
- lib/legion/data/models/runner.rb
|
206
|
+
- lib/legion/data/models/setting.rb
|
261
207
|
- lib/legion/data/models/task.rb
|
262
208
|
- lib/legion/data/models/task_log.rb
|
209
|
+
- lib/legion/data/models/user.rb
|
210
|
+
- lib/legion/data/settings.rb
|
263
211
|
- lib/legion/data/version.rb
|
212
|
+
- sonar-project.properties
|
264
213
|
homepage: https://bitbucket.org/legion-io/legion-data
|
265
214
|
licenses: []
|
266
215
|
metadata:
|
@@ -270,7 +219,7 @@ metadata:
|
|
270
219
|
homepage_uri: https://bitbucket.org/legion-io/legion-data
|
271
220
|
source_code_uri: https://bitbucket.org/legion-io/legion-data
|
272
221
|
wiki_uri: https://bitbucket.org/legion-io/legion-data/wiki/Home
|
273
|
-
post_install_message:
|
222
|
+
post_install_message:
|
274
223
|
rdoc_options: []
|
275
224
|
require_paths:
|
276
225
|
- lib
|
@@ -278,15 +227,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
278
227
|
requirements:
|
279
228
|
- - ">="
|
280
229
|
- !ruby/object:Gem::Version
|
281
|
-
version:
|
230
|
+
version: 2.5.0
|
282
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
283
232
|
requirements:
|
284
233
|
- - ">="
|
285
234
|
- !ruby/object:Gem::Version
|
286
235
|
version: '0'
|
287
236
|
requirements: []
|
288
|
-
rubygems_version: 3.
|
289
|
-
signing_key:
|
237
|
+
rubygems_version: 3.1.2
|
238
|
+
signing_key:
|
290
239
|
specification_version: 4
|
291
240
|
summary: Used by Legion to connect to the database
|
292
241
|
test_files: []
|