legionio 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- metadata +4 -94
- data/.circleci/config.yml +0 -119
- data/.gitignore +0 -14
- data/.rspec +0 -2
- data/.rubocop.yml +0 -89
- data/CHANGELOG.md +0 -16
- data/Gemfile +0 -3
- data/LICENSE.txt +0 -21
- data/README.md +0 -49
- data/Rakefile +0 -38
- data/bin/console +0 -16
- data/bin/legion +0 -49
- data/bin/setup +0 -8
- data/bin/test +0 -32
- data/bitbucket-pipelines.yml +0 -55
- data/docs/Makefile +0 -20
- data/docs/_build/doctrees/environment.pickle +0 -0
- data/docs/_build/doctrees/index.doctree +0 -0
- data/docs/_build/doctrees/overview.doctree +0 -0
- data/docs/_build/html/.buildinfo +0 -4
- data/docs/_build/html/_sources/index.rst.txt +0 -28
- data/docs/_build/html/_sources/overview.rst.txt +0 -0
- data/docs/_build/html/_static/alabaster.css +0 -701
- data/docs/_build/html/_static/basic.css +0 -855
- data/docs/_build/html/_static/custom.css +0 -1
- data/docs/_build/html/_static/doctools.js +0 -315
- data/docs/_build/html/_static/documentation_options.js +0 -12
- data/docs/_build/html/_static/file.png +0 -0
- data/docs/_build/html/_static/jquery-3.5.1.js +0 -10872
- data/docs/_build/html/_static/jquery.js +0 -2
- data/docs/_build/html/_static/language_data.js +0 -297
- data/docs/_build/html/_static/minus.png +0 -0
- data/docs/_build/html/_static/plus.png +0 -0
- data/docs/_build/html/_static/pygments.css +0 -82
- data/docs/_build/html/_static/searchtools.js +0 -514
- data/docs/_build/html/_static/underscore-1.3.1.js +0 -999
- data/docs/_build/html/_static/underscore.js +0 -31
- data/docs/_build/html/genindex.html +0 -101
- data/docs/_build/html/index.html +0 -117
- data/docs/_build/html/objects.inv +0 -6
- data/docs/_build/html/overview.html +0 -98
- data/docs/_build/html/search.html +0 -110
- data/docs/_build/html/searchindex.js +0 -1
- data/docs/conf.py +0 -54
- data/docs/index.rst +0 -28
- data/docs/make.bat +0 -35
- data/exe/legion +0 -52
- data/legion.gemspec +0 -59
- data/lib/legion.rb +0 -21
- data/lib/legion/exceptions/handled_task.rb +0 -6
- data/lib/legion/exceptions/invalidjson.rb +0 -5
- data/lib/legion/exceptions/missingargument.rb +0 -6
- data/lib/legion/exceptions/wrongtype.rb +0 -10
- data/lib/legion/exceptions/wrongtypes/array.rb +0 -8
- data/lib/legion/exceptions/wrongtypes/hash.rb +0 -8
- data/lib/legion/exceptions/wrongtypes/integer.rb +0 -8
- data/lib/legion/exceptions/wrongtypes/string.rb +0 -8
- data/lib/legion/extensions.rb +0 -185
- data/lib/legion/extensions/actors/base.rb +0 -49
- data/lib/legion/extensions/actors/every.rb +0 -48
- data/lib/legion/extensions/actors/loop.rb +0 -32
- data/lib/legion/extensions/actors/nothing.rb +0 -15
- data/lib/legion/extensions/actors/once.rb +0 -40
- data/lib/legion/extensions/actors/poll.rb +0 -88
- data/lib/legion/extensions/actors/subscription.rb +0 -138
- data/lib/legion/extensions/builders/actors.rb +0 -61
- data/lib/legion/extensions/builders/base.rb +0 -36
- data/lib/legion/extensions/builders/helpers.rb +0 -24
- data/lib/legion/extensions/builders/runners.rb +0 -58
- data/lib/legion/extensions/core.rb +0 -126
- data/lib/legion/extensions/data.rb +0 -58
- data/lib/legion/extensions/data/migrator.rb +0 -28
- data/lib/legion/extensions/data/model.rb +0 -8
- data/lib/legion/extensions/helpers/base.rb +0 -82
- data/lib/legion/extensions/helpers/cache.rb +0 -23
- data/lib/legion/extensions/helpers/core.rb +0 -41
- data/lib/legion/extensions/helpers/data.rb +0 -23
- data/lib/legion/extensions/helpers/lex.rb +0 -48
- data/lib/legion/extensions/helpers/logger.rb +0 -47
- data/lib/legion/extensions/helpers/task.rb +0 -60
- data/lib/legion/extensions/helpers/transport.rb +0 -44
- data/lib/legion/extensions/transport.rb +0 -159
- data/lib/legion/process.rb +0 -124
- data/lib/legion/runner.rb +0 -55
- data/lib/legion/runner/log.rb +0 -10
- data/lib/legion/runner/status.rb +0 -69
- data/lib/legion/service.rb +0 -99
- data/lib/legion/supervision.rb +0 -15
- data/lib/legion/version.rb +0 -3
@@ -1 +0,0 @@
|
|
1
|
-
Search.setIndex({docnames:["index","overview"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,sphinx:56},filenames:["index.rst","overview.rst"],objects:{},objnames:{},objtypes:{},terms:{"class":0,"function":0,These:0,acknowledg:0,action:0,add:0,ani:0,call:0,can:0,chain:0,cluster:0,complex:0,connect:0,contain:0,content:[],creat:0,delet:0,design:0,exampl:0,extens:0,foobar:[],get:0,incid:0,index:[],input:0,instal:0,legion:0,lex:0,list:0,make:0,merg:0,modul:[],more:0,out:0,output:0,page:[],pagerduti:0,platform:0,project:0,relationship:0,resolv:0,runner:0,search:[],second:[],servic:0,them:0,thi:[],thing:0,think:0,trigger:0,updat:0,user:0,whatev:0,which:0,within:0,without:0,work:0,workflow:0,yaml:0,you:0,your:0},titles:["LegionIO Overview","<no title>"],titleterms:{about:0,document:[],indic:[],legionio:0,overview:0,tabl:[],test3:[],test:[],welcom:[]}})
|
data/docs/conf.py
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# Configuration file for the Sphinx documentation builder.
|
2
|
-
#
|
3
|
-
# This file only contains a selection of the most common options. For a full
|
4
|
-
# list see the documentation:
|
5
|
-
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
6
|
-
|
7
|
-
# -- Path setup --------------------------------------------------------------
|
8
|
-
|
9
|
-
# If extensions (or modules to document with autodoc) are in another directory,
|
10
|
-
# add these directories to sys.path here. If the directory is relative to the
|
11
|
-
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
12
|
-
#
|
13
|
-
# import os
|
14
|
-
# import sys
|
15
|
-
# sys.path.insert(0, os.path.abspath('.'))
|
16
|
-
|
17
|
-
|
18
|
-
# -- Project information -----------------------------------------------------
|
19
|
-
|
20
|
-
project = 'LegionIO'
|
21
|
-
copyright = '2020, Esity'
|
22
|
-
author = 'Esity'
|
23
|
-
|
24
|
-
# The full version, including alpha/beta/rc tags
|
25
|
-
release = '0.3.1'
|
26
|
-
|
27
|
-
|
28
|
-
# -- General configuration ---------------------------------------------------
|
29
|
-
|
30
|
-
# Add any Sphinx extension module names here, as strings. They can be
|
31
|
-
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
32
|
-
# ones.
|
33
|
-
extensions = ['recommonmark']
|
34
|
-
|
35
|
-
# Add any paths that contain templates here, relative to this directory.
|
36
|
-
templates_path = ['_templates']
|
37
|
-
|
38
|
-
# List of patterns, relative to source directory, that match files and
|
39
|
-
# directories to ignore when looking for source files.
|
40
|
-
# This pattern also affects html_static_path and html_extra_path.
|
41
|
-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
42
|
-
|
43
|
-
|
44
|
-
# -- Options for HTML output -------------------------------------------------
|
45
|
-
|
46
|
-
# The theme to use for HTML and HTML Help pages. See the documentation for
|
47
|
-
# a list of builtin themes.
|
48
|
-
#
|
49
|
-
html_theme = 'alabaster'
|
50
|
-
|
51
|
-
# Add any paths that contain custom static files (such as style sheets) here,
|
52
|
-
# relative to this directory. They are copied after the builtin static files,
|
53
|
-
# so a file named "default.css" will overwrite the builtin "default.css".
|
54
|
-
html_static_path = ['_static']
|
data/docs/index.rst
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
.. LegionIO documentation master file, created by
|
2
|
-
sphinx-quickstart on Thu Oct 15 08:16:27 2020.
|
3
|
-
You can adapt this file completely to your liking, but it should at least
|
4
|
-
contain the root `toctree` directive.
|
5
|
-
|
6
|
-
LegionIO Overview
|
7
|
-
==============================
|
8
|
-
|
9
|
-
About
|
10
|
-
------------
|
11
|
-
LegionIO is a platform designed for connecting things. You install a LEX(Legion Extension)
|
12
|
-
which adds functionality to your Legion service?project?cluster? Whatever it's called.
|
13
|
-
|
14
|
-
A LEX contains 1 or more runners. Think of them as classes
|
15
|
-
A runner contains 1 or more functions. These are the things you can call and make relationships out of
|
16
|
-
Example
|
17
|
-
|
18
|
-
* Lex: pagerduty
|
19
|
-
|
20
|
-
* Runners: incident, user, service
|
21
|
-
|
22
|
-
* Functions within the incident runner: trigger, acknowledge, resolve, merge
|
23
|
-
|
24
|
-
* Functions within the services runner: create, delete, update, list, get
|
25
|
-
|
26
|
-
Any function can be a trigger or an action(the input or output in the relationship).
|
27
|
-
|
28
|
-
Legion works by creating chains of relationships to make make a complex workflow without complex yaml
|
data/docs/make.bat
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
@ECHO OFF
|
2
|
-
|
3
|
-
pushd %~dp0
|
4
|
-
|
5
|
-
REM Command file for Sphinx documentation
|
6
|
-
|
7
|
-
if "%SPHINXBUILD%" == "" (
|
8
|
-
set SPHINXBUILD=sphinx-build
|
9
|
-
)
|
10
|
-
set SOURCEDIR=.
|
11
|
-
set BUILDDIR=_build
|
12
|
-
|
13
|
-
if "%1" == "" goto help
|
14
|
-
|
15
|
-
%SPHINXBUILD% >NUL 2>NUL
|
16
|
-
if errorlevel 9009 (
|
17
|
-
echo.
|
18
|
-
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
19
|
-
echo.installed, then set the SPHINXBUILD environment variable to point
|
20
|
-
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
21
|
-
echo.may add the Sphinx directory to PATH.
|
22
|
-
echo.
|
23
|
-
echo.If you don't have Sphinx installed, grab it from
|
24
|
-
echo.http://sphinx-doc.org/
|
25
|
-
exit /b 1
|
26
|
-
)
|
27
|
-
|
28
|
-
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
29
|
-
goto end
|
30
|
-
|
31
|
-
:help
|
32
|
-
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
33
|
-
|
34
|
-
:end
|
35
|
-
popd
|
data/exe/legion
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'optparse'
|
5
|
-
|
6
|
-
options = { action: :run }
|
7
|
-
|
8
|
-
daemonize_help = 'run daemonized in the background (default: false)'
|
9
|
-
pidfile_help = 'the pid filename'
|
10
|
-
logfile_help = 'the log filename'
|
11
|
-
include_help = 'an additional $LOAD_PATH (may be used more than once)'
|
12
|
-
debug_help = 'set $DEBUG to true'
|
13
|
-
warn_help = 'enable warnings'
|
14
|
-
time_help = 'only run legion for X seconds'
|
15
|
-
|
16
|
-
op = OptionParser.new
|
17
|
-
op.banner = 'An example of how to daemonize a long running Ruby process.'
|
18
|
-
op.separator ''
|
19
|
-
op.separator 'Usage: server [options]'
|
20
|
-
op.separator ''
|
21
|
-
|
22
|
-
op.separator ''
|
23
|
-
op.separator 'Process options:'
|
24
|
-
op.on('-d', '--daemonize', daemonize_help) { options[:daemonize] = true }
|
25
|
-
op.on('-p', '--pid PIDFILE', pidfile_help) { |value| options[:pidfile] = value }
|
26
|
-
op.on('-l', '--log LOGFILE', logfile_help) { |value| options[:logfile] = value }
|
27
|
-
op.on('-t', '--time 10', time_help) { |value| options[:time_limit] = value }
|
28
|
-
|
29
|
-
op.separator ''
|
30
|
-
op.separator 'Ruby options:'
|
31
|
-
op.on('-I', '--include PATH', include_help) do |value|
|
32
|
-
$LOAD_PATH.unshift(*value.split(':').map do |v|
|
33
|
-
File.expand_path(v)
|
34
|
-
end)
|
35
|
-
end
|
36
|
-
op.on('--debug', debug_help) { $DEBUG = true }
|
37
|
-
op.on('--warn', warn_help) { $-w = true }
|
38
|
-
|
39
|
-
op.separator ''
|
40
|
-
op.separator 'Common options:'
|
41
|
-
op.on('-h', '--help') { options[:action] = :help }
|
42
|
-
op.on('-v', '--version') { options[:action] = :version }
|
43
|
-
|
44
|
-
op.separator ''
|
45
|
-
op.parse!(ARGV)
|
46
|
-
|
47
|
-
unless options[:action] == :help
|
48
|
-
require 'legion'
|
49
|
-
Legion.start
|
50
|
-
require 'legion/process'
|
51
|
-
Legion::Process.new(options).run!
|
52
|
-
end
|
data/legion.gemspec
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path('lib', __dir__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require 'legion/version'
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = (RUBY_ENGINE == 'jruby' ? 'legionio-java' : 'legionio')
|
9
|
-
spec.version = Legion::VERSION
|
10
|
-
spec.authors = ['Esity']
|
11
|
-
spec.email = ['matthewdiverson@gmail.com']
|
12
|
-
|
13
|
-
spec.summary = 'Legion Core Software to string it all together'
|
14
|
-
spec.description = 'Legion Core runs Legion Framwork'
|
15
|
-
spec.homepage = 'https://bitbucket.org/legion-io/legion/'
|
16
|
-
spec.license = 'MIT'
|
17
|
-
spec.required_ruby_version = '>= 2.5.0'
|
18
|
-
|
19
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
-
f.match(%r{^(test|spec|features)/})
|
21
|
-
end
|
22
|
-
spec.bindir = 'exe'
|
23
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
-
spec.require_paths = ['lib']
|
25
|
-
|
26
|
-
if RUBY_ENGINE == 'jruby'
|
27
|
-
spec.add_dependency 'jrjackson'
|
28
|
-
spec.add_dependency 'legion-data-java'
|
29
|
-
spec.add_dependency 'legion-transport-java'
|
30
|
-
spec.add_dependency 'march_hare'
|
31
|
-
else
|
32
|
-
spec.add_dependency 'concurrent-ruby-ext'
|
33
|
-
spec.add_dependency 'legion-data'
|
34
|
-
spec.add_dependency 'legion-transport'
|
35
|
-
spec.add_dependency 'oj'
|
36
|
-
end
|
37
|
-
|
38
|
-
spec.add_dependency 'concurrent-ruby'
|
39
|
-
spec.add_dependency 'daemons'
|
40
|
-
spec.add_dependency 'hashdiff'
|
41
|
-
|
42
|
-
spec.add_dependency 'bunny'
|
43
|
-
spec.add_dependency 'legion-cache'
|
44
|
-
spec.add_dependency 'legion-crypt'
|
45
|
-
spec.add_dependency 'legion-exceptions'
|
46
|
-
spec.add_dependency 'legion-json'
|
47
|
-
spec.add_dependency 'legion-logging'
|
48
|
-
spec.add_dependency 'legion-settings'
|
49
|
-
|
50
|
-
spec.add_dependency 'lex-node'
|
51
|
-
|
52
|
-
spec.add_development_dependency 'bundler'
|
53
|
-
spec.add_development_dependency 'codecov'
|
54
|
-
spec.add_development_dependency 'rake'
|
55
|
-
spec.add_development_dependency 'rspec'
|
56
|
-
spec.add_development_dependency 'rspec_junit_formatter'
|
57
|
-
spec.add_development_dependency 'rubocop'
|
58
|
-
spec.add_development_dependency 'simplecov'
|
59
|
-
end
|
data/lib/legion.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
Process.setproctitle('Legion')
|
2
|
-
require 'concurrent'
|
3
|
-
require 'securerandom'
|
4
|
-
require 'legion/exceptions'
|
5
|
-
require 'legion/version'
|
6
|
-
require 'legion/process'
|
7
|
-
require 'legion/service'
|
8
|
-
require 'legion/extensions'
|
9
|
-
|
10
|
-
module Legion
|
11
|
-
attr_reader :service
|
12
|
-
|
13
|
-
def self.start
|
14
|
-
@service = Legion::Service.new
|
15
|
-
Legion::Logging.info("Started Legion v#{Legion::VERSION}")
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.shutdown
|
19
|
-
@service.shutdown
|
20
|
-
end
|
21
|
-
end
|
data/lib/legion/extensions.rb
DELETED
@@ -1,185 +0,0 @@
|
|
1
|
-
require 'legion/extensions/core'
|
2
|
-
require 'legion/runner'
|
3
|
-
|
4
|
-
module Legion
|
5
|
-
module Extensions
|
6
|
-
class << self
|
7
|
-
def setup
|
8
|
-
hook_extensions
|
9
|
-
end
|
10
|
-
|
11
|
-
def hook_extensions
|
12
|
-
@timer_tasks = []
|
13
|
-
@loop_tasks = []
|
14
|
-
@once_tasks = []
|
15
|
-
@poll_tasks = []
|
16
|
-
@subscription_tasks = []
|
17
|
-
@actors = []
|
18
|
-
|
19
|
-
find_extensions
|
20
|
-
load_extensions
|
21
|
-
end
|
22
|
-
|
23
|
-
def shutdown
|
24
|
-
return nil if @loaded_extensions.nil?
|
25
|
-
|
26
|
-
@subscription_tasks.each do |task|
|
27
|
-
task[:threadpool].shutdown
|
28
|
-
task[:threadpool].kill unless task[:threadpool].wait_for_termination(5)
|
29
|
-
end
|
30
|
-
|
31
|
-
@loop_tasks.each { |task| task[:running_class].cancel if task[:running_class].respond_to?(:cancel) }
|
32
|
-
@once_tasks.each { |task| task[:running_class].cancel if task[:running_class].respond_to?(:cancel) }
|
33
|
-
@timer_tasks.each { |task| task[:running_class].cancel if task[:running_class].respond_to?(:cancel) }
|
34
|
-
@poll_tasks.each { |task| task[:running_class].cancel if task[:running_class].respond_to?(:cancel) }
|
35
|
-
|
36
|
-
Legion::Logging.info 'Successfully shut down all actors'
|
37
|
-
end
|
38
|
-
|
39
|
-
def load_extensions
|
40
|
-
@extensions ||= {}
|
41
|
-
@loaded_extensions ||= []
|
42
|
-
@extensions.each do |extension, values|
|
43
|
-
if values.key(:enabled) && !values[:enabled]
|
44
|
-
Legion::Logging.info "Skipping #{extension} because it's disabled"
|
45
|
-
next
|
46
|
-
end
|
47
|
-
|
48
|
-
if Legion::Settings[:extensions].key?(extension.to_sym) && Legion::Settings[:extensions][extension.to_sym].key?(:enabled) && !Legion::Settings[:extensions][extension.to_sym][:enabled] # rubocop:disable Layout/LineLength
|
49
|
-
next
|
50
|
-
end
|
51
|
-
|
52
|
-
unless load_extension(extension, values)
|
53
|
-
Legion::Logging.warn("#{extension} failed to load")
|
54
|
-
next
|
55
|
-
end
|
56
|
-
@loaded_extensions.push(extension)
|
57
|
-
end
|
58
|
-
Legion::Logging.info "#{@extensions.count} extensions loaded with subscription:#{@subscription_tasks.count},every:#{@timer_tasks.count},poll:#{@poll_tasks.count},once:#{@once_tasks.count},loop:#{@loop_tasks.count}"
|
59
|
-
end
|
60
|
-
|
61
|
-
def load_extension(extension, values)
|
62
|
-
return unless gem_load(values[:gem_name], extension)
|
63
|
-
|
64
|
-
extension = Kernel.const_get(values[:extension_class])
|
65
|
-
has_logger = extension.respond_to?(:log)
|
66
|
-
extension.autobuild
|
67
|
-
|
68
|
-
require 'legion/transport/messages/lex_register'
|
69
|
-
Legion::Transport::Messages::LexRegister.new(function: 'save', opts: extension.runners).publish
|
70
|
-
|
71
|
-
if extension.respond_to?(:meta_actors) && extension.meta_actors.is_a?(Array)
|
72
|
-
extension.meta_actors.each do |_key, actor|
|
73
|
-
extension.log.debug("hooking meta actor: #{actor}") if has_logger
|
74
|
-
hook_actor(**actor)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
extension.actors.each do |_key, actor|
|
79
|
-
extension.log.debug("hooking literal actor: #{actor}") if has_logger
|
80
|
-
hook_actor(**actor)
|
81
|
-
end
|
82
|
-
extension.log.info "Loaded v#{extension::VERSION}"
|
83
|
-
rescue StandardError => e
|
84
|
-
Legion::Logging.error e.message
|
85
|
-
Legion::Logging.error e.backtrace
|
86
|
-
false
|
87
|
-
end
|
88
|
-
|
89
|
-
def hook_actor(extension:, extension_name:, actor_class:, size: 1, **opts)
|
90
|
-
size = if Legion::Settings[:extensions].key?(extension_name.to_sym) && Legion::Settings[:extensions][extension_name.to_sym].key?(:workers)
|
91
|
-
Legion::Settings[:extensions][extension_name.to_sym][:workers]
|
92
|
-
elsif size.is_a? Integer
|
93
|
-
size
|
94
|
-
else
|
95
|
-
1
|
96
|
-
end
|
97
|
-
|
98
|
-
extension_hash = {
|
99
|
-
extension: extension,
|
100
|
-
extension_name: extension_name,
|
101
|
-
actor_class: actor_class,
|
102
|
-
size: size,
|
103
|
-
fallback_policy: :abort,
|
104
|
-
**opts
|
105
|
-
}
|
106
|
-
extension_hash[:running_class] = if actor_class.ancestors.include? Legion::Extensions::Actors::Subscription
|
107
|
-
actor_class
|
108
|
-
else
|
109
|
-
actor_class.new
|
110
|
-
end
|
111
|
-
|
112
|
-
if actor_class.ancestors.include? Legion::Extensions::Actors::Every
|
113
|
-
@timer_tasks.push(extension_hash)
|
114
|
-
elsif actor_class.ancestors.include? Legion::Extensions::Actors::Once
|
115
|
-
@once_tasks.push(extension_hash)
|
116
|
-
elsif actor_class.ancestors.include? Legion::Extensions::Actors::Loop
|
117
|
-
@loop_tasks.push(extension_hash)
|
118
|
-
elsif actor_class.ancestors.include? Legion::Extensions::Actors::Poll
|
119
|
-
@poll_tasks.push(extension_hash)
|
120
|
-
elsif actor_class.ancestors.include? Legion::Extensions::Actors::Subscription
|
121
|
-
extension_hash[:threadpool] = Concurrent::FixedThreadPool.new(size)
|
122
|
-
size.times do
|
123
|
-
extension_hash[:threadpool].post do
|
124
|
-
klass = actor_class.new
|
125
|
-
if klass.respond_to?(:async)
|
126
|
-
klass.async.subscribe
|
127
|
-
else
|
128
|
-
klass.subscribe
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
@subscription_tasks.push(extension_hash)
|
133
|
-
else
|
134
|
-
Legion::Logging.fatal 'did not match any actor classes'
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
def gem_load(gem_name, name)
|
139
|
-
require "#{Gem::Specification.find_by_name(gem_name).gem_dir}/lib/legion/extensions/#{name}"
|
140
|
-
true
|
141
|
-
rescue LoadError => e
|
142
|
-
Legion::Logging.error e.message
|
143
|
-
Legion::Logging.error e.backtrace
|
144
|
-
Legion::Logging.error "gem_path: #{gem_path}" unless gem_path.nil?
|
145
|
-
false
|
146
|
-
end
|
147
|
-
|
148
|
-
def find_extensions
|
149
|
-
@extensions ||= {}
|
150
|
-
Gem::Specification.all_names.each do |gem|
|
151
|
-
next unless gem[0..3] == 'lex-'
|
152
|
-
|
153
|
-
lex = gem.split('-')
|
154
|
-
@extensions[lex[1]] = { full_gem_name: gem,
|
155
|
-
gem_name: "lex-#{lex[1]}",
|
156
|
-
extension_name: lex[1],
|
157
|
-
version: lex[2],
|
158
|
-
extension_class: "Legion::Extensions::#{lex[1].split('_').collect(&:capitalize).join}" }
|
159
|
-
end
|
160
|
-
|
161
|
-
Legion::Settings[:extensions].each do |extension, values|
|
162
|
-
next if @extensions.key? extension.to_s
|
163
|
-
next if values[:enabled] == false
|
164
|
-
next if values[:auto_install] == false
|
165
|
-
|
166
|
-
Legion::Logging.warn "#{extension} is missing, attempting to install automatically.."
|
167
|
-
install = Gem.install("lex-#{extension}")
|
168
|
-
Legion::Logging.debug(install)
|
169
|
-
lex = Gem::Specification.find_by_name("lex-#{extension}")
|
170
|
-
|
171
|
-
@extensions[extension.to_s] = {
|
172
|
-
full_gem_name: "lex-#{extension}-#{lex.version}",
|
173
|
-
gem_name: "lex-#{extension}",
|
174
|
-
extension_name: extension.to_s,
|
175
|
-
version: lex.version,
|
176
|
-
extension_class: "Legion::Extensions::#{extension.to_s.split('_').collect(&:capitalize).join}"
|
177
|
-
}
|
178
|
-
|
179
|
-
rescue StandardError, Gem::MissingSpecError => e
|
180
|
-
Legion::Logging.error "Failed to auto install #{extension}, e: #{e.message}"
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|