lex-tasker 0.2.0 → 0.3.0

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +16 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +36 -22
  5. data/CHANGELOG.md +43 -0
  6. data/CLAUDE.md +83 -0
  7. data/Dockerfile +9 -0
  8. data/Gemfile +9 -1
  9. data/README.md +34 -2
  10. data/Rakefile +2 -0
  11. data/docker_deploy.rb +14 -0
  12. data/lex-tasker.gemspec +9 -13
  13. data/lib/legion/extensions/tasker/actors/check_subtask.rb +20 -14
  14. data/lib/legion/extensions/tasker/actors/fetch_delayed.rb +23 -17
  15. data/lib/legion/extensions/tasker/actors/fetch_delayed_push.rb +26 -20
  16. data/lib/legion/extensions/tasker/actors/log.rb +14 -8
  17. data/lib/legion/extensions/tasker/actors/task_manager.rb +20 -14
  18. data/lib/legion/extensions/tasker/actors/updater.rb +20 -14
  19. data/lib/legion/extensions/tasker/client.rb +29 -0
  20. data/lib/legion/extensions/tasker/helpers/task_finder.rb +98 -0
  21. data/lib/legion/extensions/tasker/runners/check_subtask.rb +92 -80
  22. data/lib/legion/extensions/tasker/runners/fetch_delayed.rb +76 -60
  23. data/lib/legion/extensions/tasker/runners/log.rb +47 -41
  24. data/lib/legion/extensions/tasker/runners/task_manager.rb +12 -5
  25. data/lib/legion/extensions/tasker/runners/updater.rb +25 -22
  26. data/lib/legion/extensions/tasker/transport/exchanges/task.rb +10 -4
  27. data/lib/legion/extensions/tasker/transport/messages/fetch_delayed.rb +17 -7
  28. data/lib/legion/extensions/tasker/transport/queues/check_subtask.rb +18 -12
  29. data/lib/legion/extensions/tasker/transport/queues/fetch_delayed.rb +20 -15
  30. data/lib/legion/extensions/tasker/transport/queues/lex_register.rb +15 -9
  31. data/lib/legion/extensions/tasker/transport/queues/subtask.rb +12 -6
  32. data/lib/legion/extensions/tasker/transport/queues/task_log.rb +12 -6
  33. data/lib/legion/extensions/tasker/transport/queues/task_mananger.rb +15 -9
  34. data/lib/legion/extensions/tasker/transport/queues/updater.rb +12 -6
  35. data/lib/legion/extensions/tasker/transport.rb +31 -24
  36. data/lib/legion/extensions/tasker/version.rb +3 -1
  37. data/lib/legion/extensions/tasker.rb +2 -4
  38. metadata +19 -106
  39. data/.circleci/config.yml +0 -39
  40. data/Gemfile.lock +0 -69
  41. data/bin/console +0 -14
  42. data/bin/setup +0 -8
  43. data/bitbucket-pipelines.yml +0 -69
  44. data/lib/legion/extensions/tasker/helpers/base.rb +0 -11
  45. data/lib/legion/extensions/tasker/helpers/fetch_delayed.rb +0 -66
  46. data/lib/legion/extensions/tasker/helpers/find_subtask.rb +0 -49
@@ -1,69 +0,0 @@
1
- image: ruby:2.7
2
-
3
- pipelines:
4
- tags:
5
- "v*":
6
- - step:
7
- name: Rubocop
8
- caches:
9
- - bundler
10
- script:
11
- - gem install rubocop
12
- - gem update rubocop
13
- - rubocop
14
- - step:
15
- name: RSpec
16
- caches:
17
- - bundler
18
- script:
19
- - gem install bundler
20
- - gem update bundler
21
- - bundle update
22
- - bundle exec rspec
23
- - step:
24
- name: Push to RubyGems
25
- deployment: RubyGems
26
- script:
27
- - gem install bundler gem-release rspec
28
- - bundle install
29
- - (umask 077 ; echo $gem_creds | base64 --decode > ~/.gem/credentials)
30
- - gem release
31
- artifacts:
32
- - pkg/**
33
- branches:
34
- master:
35
- - step:
36
- caches:
37
- - bundler
38
- script:
39
- - gem install rubocop
40
- - gem update rubocop
41
- - rubocop
42
- - step:
43
- caches:
44
- - bundler
45
- script:
46
- - gem install bundler
47
- - gem update bundler
48
- - bundle update
49
- - bundle exec rspec
50
- develop:
51
- - step:
52
- caches:
53
- - bundler
54
- script:
55
- - gem install rubocop
56
- - gem update rubocop
57
- - rubocop
58
- - step:
59
- caches:
60
- - bundler
61
- script:
62
- - gem install bundler
63
- - gem update bundler
64
- - bundle update
65
- - bundle exec rspec
66
-
67
- definitions:
68
- caches:
69
- bundler: /usr/local/bundle
@@ -1,11 +0,0 @@
1
- module Legion
2
- module Extensions
3
- module Tasker
4
- module Helpers
5
- module Base
6
- def send_task(**opts); end
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,66 +0,0 @@
1
- module Legion
2
- module Extensions
3
- module Tasker
4
- module Helpers
5
- module FetchDelayed
6
- def find_trigger(runner_class:, function:, **)
7
- sql = "SELECT `functions`.`id` as `function_id`, `runner_id`, `runners`.`namespace`
8
- FROM `legion`.`functions`
9
- INNER JOIN `legion`.`runners` ON (`functions`.`runner_id` = `runners`.`id`)
10
- WHERE `functions`.`name` = '#{function}'
11
- AND `runners`.`namespace` = '#{runner_class}' LIMIT 1;"
12
-
13
- cache = Legion::Cache.get(sql)
14
- return cache unless cache.nil?
15
-
16
- results = Legion::Data::Connection.sequel.fetch(sql).first
17
- Legion::Cache.set(sql, results) if results.is_a?(Hash) && results.count.positive?
18
- results
19
- end
20
-
21
- def find_delayed(**)
22
- sql = '
23
- SELECT tasks.id, tasks.relationship_id, tasks.function_id, tasks.created,
24
- relationships.delay as relationship_delay, relationships.chain_id,
25
- functions.name as function_name,
26
- runners.namespace as class, runners.id as runner_id,
27
- CONCAT( `exchange`, ".",`queue`,".",`functions`.`name`) AS runner_routing_key
28
- FROM legion.tasks
29
- INNER JOIN legion.functions ON (functions.id = tasks.function_id)
30
- INNER JOIN legion.runners ON (runners.id = functions.runner_id)
31
- INNER JOIN `legion`.`extensions` ON (`runners`.`extension_id` = `extensions`.`id`)
32
- LEFT JOIN legion.relationships ON (relationships.id = tasks.relationship_id)
33
- WHERE status = \'task.delayed\';'
34
-
35
- Legion::Data::Connection.sequel.fetch(sql)
36
- end
37
-
38
- def find_subtasks(trigger_id:, **)
39
- sql = "
40
- SELECT
41
- `relationships`.`id` as `relationship_id`, `debug`,
42
- `chain_id`, `allow_new_chains`, `delay`, `trigger_id`, `action_id`, `conditions`, `transformation`,
43
- `runners`.`namespace`, `runners`.`id` as `runner_id`, `runners`.`queue`,
44
- `runners`.`namespace` as runner_class,
45
- `functions`.`id` as `function_id`, `functions`.`name` as `function`,
46
- `extensions`.`exchange`,
47
- CONCAT( `exchange`, '.',`queue`,'.',`functions`.`name`) AS runner_routing_key
48
- FROM `legion`.`relationships`
49
- INNER JOIN `legion`.`functions` ON (`functions`.`id` = `relationships`.`action_id`)
50
- INNER JOIN `legion`.`runners` ON (`functions`.`runner_id` = `runners`.`id`)
51
- INNER JOIN `legion`.`extensions` ON (`runners`.`extension_id` = `extensions`.`id`)
52
- WHERE `relationships`.`trigger_id` = #{trigger_id} AND `relationships`.`active` = 1;
53
- "
54
-
55
- cache = Legion::Cache.get(sql)
56
- return cache unless cache.nil?
57
-
58
- results = Legion::Data::Connection.sequel.fetch(sql)
59
- Legion::Cache.set(sql, results, ttl: 5) if results.is_a?(Hash) && results.count.positive?
60
- results
61
- end
62
- end
63
- end
64
- end
65
- end
66
- end
@@ -1,49 +0,0 @@
1
- module Legion
2
- module Extensions
3
- module Tasker
4
- module Helpers
5
- module FindSubtask
6
- def find_trigger(runner_class:, function:, **)
7
- sql = "SELECT `functions`.`id` as `function_id`, `runner_id`, `runners`.`namespace`
8
- FROM `legion`.`functions`
9
- INNER JOIN `legion`.`runners` ON (`functions`.`runner_id` = `runners`.`id`)
10
- WHERE `functions`.`name` = '#{function}'
11
- AND `runners`.`namespace` = '#{runner_class}' LIMIT 1;"
12
-
13
- cache = Legion::Cache.get(sql)
14
- return cache unless cache.nil?
15
-
16
- results = Legion::Data::Connection.sequel.fetch(sql).first
17
- Legion::Cache.set(sql, results) if results.is_a?(Hash) && results.count.positive?
18
- results
19
- end
20
-
21
- def find_subtasks(trigger_id:, **)
22
- sql = "
23
- SELECT
24
- `relationships`.`id` as `relationship_id`, `debug`,
25
- `chain_id`, `allow_new_chains`, `delay`, `trigger_id`, `action_id`, `conditions`, `transformation`,
26
- `runners`.`namespace`, `runners`.`id` as `runner_id`, `runners`.`queue`,
27
- `runners`.`namespace` as runner_class,
28
- `functions`.`id` as `function_id`, `functions`.`name` as `function`,
29
- `extensions`.`exchange`,
30
- CONCAT( `exchange`, '.',`queue`,'.',`functions`.`name`) AS runner_routing_key
31
- FROM `legion`.`relationships`
32
- INNER JOIN `legion`.`functions` ON (`functions`.`id` = `relationships`.`action_id`)
33
- INNER JOIN `legion`.`runners` ON (`functions`.`runner_id` = `runners`.`id`)
34
- INNER JOIN `legion`.`extensions` ON (`runners`.`extension_id` = `extensions`.`id`)
35
- WHERE `relationships`.`trigger_id` = #{trigger_id} AND `relationships`.`active` = 1;
36
- "
37
-
38
- cache = Legion::Cache.get(sql)
39
- return cache unless cache.nil?
40
-
41
- results = Legion::Data::Connection.sequel.fetch(sql)
42
- Legion::Cache.set(sql, results, ttl: 5) if results.is_a?(Hash) && results.count.positive?
43
- results
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end