kaal 0.5.0 → 0.6.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 (101) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -24
  3. data/config/kaal.yml +12 -0
  4. data/lib/kaal/backend/adapter.rb +4 -0
  5. data/lib/kaal/cli.rb +38 -34
  6. data/lib/kaal/config/backend_factory.rb +178 -0
  7. data/lib/kaal/config/configuration.rb +65 -7
  8. data/lib/kaal/config/file_loader.rb +187 -0
  9. data/lib/kaal/config.rb +2 -0
  10. data/lib/kaal/runtime/scheduler_boot_loader.rb +1 -1
  11. data/lib/kaal/scheduler_file/loader.rb +1 -1
  12. data/lib/kaal/version.rb +1 -1
  13. data/lib/kaal.rb +7 -0
  14. data/sig/00_types.rbs +12 -0
  15. data/sig/dependencies.rbs +49 -0
  16. data/sig/kaal/active_record_support.rbs +23 -0
  17. data/sig/kaal/backend/adapter.rbs +26 -0
  18. data/sig/kaal/backend/dispatch_attempt_logger.rbs +17 -0
  19. data/sig/kaal/backend/dispatch_logging.rbs +23 -0
  20. data/sig/kaal/backend/dispatch_registry_accessor.rbs +17 -0
  21. data/sig/kaal/backend/memory_adapter.rbs +33 -0
  22. data/sig/kaal/backend/mysql.rbs +25 -0
  23. data/sig/kaal/backend/postgres.rbs +19 -0
  24. data/sig/kaal/backend/redis_adapter.rbs +41 -0
  25. data/sig/kaal/backend/sqlite.rbs +19 -0
  26. data/sig/kaal/cli.rbs +41 -0
  27. data/sig/kaal/config/backend_factory.rbs +41 -0
  28. data/sig/kaal/config/configuration.rbs +70 -0
  29. data/sig/kaal/config/delayed_job_security_policy.rbs +19 -0
  30. data/sig/kaal/config/file_loader.rbs +35 -0
  31. data/sig/kaal/config/scheduler_config_error.rbs +4 -0
  32. data/sig/kaal/config/scheduler_time_zone_resolver.rbs +19 -0
  33. data/sig/kaal/config.rbs +11 -0
  34. data/sig/kaal/core/coordinator.rbs +103 -0
  35. data/sig/kaal/core/enabled_entry_enumerator.rbs +21 -0
  36. data/sig/kaal/core/occurrence_finder.rbs +9 -0
  37. data/sig/kaal/core.rbs +9 -0
  38. data/sig/kaal/definition/database_engine.rbs +25 -0
  39. data/sig/kaal/definition/memory_engine.rbs +23 -0
  40. data/sig/kaal/definition/persistence_helpers.rbs +9 -0
  41. data/sig/kaal/definition/redis_engine.rbs +33 -0
  42. data/sig/kaal/definition/registry.rbs +29 -0
  43. data/sig/kaal/definitions/registration_service.rbs +27 -0
  44. data/sig/kaal/definitions/registry_accessor.rbs +17 -0
  45. data/sig/kaal/delayed_job/database_engine.rbs +37 -0
  46. data/sig/kaal/delayed_job/dispatch_failure_logger.rbs +7 -0
  47. data/sig/kaal/delayed_job/memory_engine.rbs +29 -0
  48. data/sig/kaal/delayed_job/mysql_version_support.rbs +15 -0
  49. data/sig/kaal/delayed_job/redis_engine.rbs +31 -0
  50. data/sig/kaal/delayed_job/registry.rbs +20 -0
  51. data/sig/kaal/dispatch/database_engine.rbs +39 -0
  52. data/sig/kaal/dispatch/memory_engine.rbs +23 -0
  53. data/sig/kaal/dispatch/redis_engine.rbs +25 -0
  54. data/sig/kaal/dispatch/registry.rbs +11 -0
  55. data/sig/kaal/internal/active_record/base_record.rbs +8 -0
  56. data/sig/kaal/internal/active_record/connection_support.rbs +25 -0
  57. data/sig/kaal/internal/active_record/database_backend.rbs +37 -0
  58. data/sig/kaal/internal/active_record/definition_record.rbs +8 -0
  59. data/sig/kaal/internal/active_record/definition_registry.rbs +27 -0
  60. data/sig/kaal/internal/active_record/delayed_job_record.rbs +8 -0
  61. data/sig/kaal/internal/active_record/delayed_job_registry.rbs +39 -0
  62. data/sig/kaal/internal/active_record/dispatch_record.rbs +8 -0
  63. data/sig/kaal/internal/active_record/dispatch_registry.rbs +43 -0
  64. data/sig/kaal/internal/active_record/lock_record.rbs +8 -0
  65. data/sig/kaal/internal/active_record/migration_templates.rbs +17 -0
  66. data/sig/kaal/internal/active_record/mysql_backend.rbs +45 -0
  67. data/sig/kaal/internal/active_record/postgres_backend.rbs +41 -0
  68. data/sig/kaal/internal/active_record.rbs +0 -0
  69. data/sig/kaal/internal/sequel/database_backend.rbs +39 -0
  70. data/sig/kaal/internal/sequel/mysql_backend.rbs +47 -0
  71. data/sig/kaal/internal/sequel/postgres_backend.rbs +43 -0
  72. data/sig/kaal/internal/sequel.rbs +0 -0
  73. data/sig/kaal/job_dispatcher.rbs +19 -0
  74. data/sig/kaal/persistence/database.rbs +19 -0
  75. data/sig/kaal/persistence/migration_templates.rbs +15 -0
  76. data/sig/kaal/register_conflict_support.rbs +11 -0
  77. data/sig/kaal/registry.rbs +44 -0
  78. data/sig/kaal/runtime/runtime_context.rbs +23 -0
  79. data/sig/kaal/runtime/scheduler_boot_loader.rbs +23 -0
  80. data/sig/kaal/runtime/signal_handler_chain.rbs +19 -0
  81. data/sig/kaal/runtime/signal_handler_installer.rbs +19 -0
  82. data/sig/kaal/runtime.rbs +11 -0
  83. data/sig/kaal/scheduler_file/hash_transform.rbs +9 -0
  84. data/sig/kaal/scheduler_file/helper_bundle.rbs +15 -0
  85. data/sig/kaal/scheduler_file/job_applier.rbs +43 -0
  86. data/sig/kaal/scheduler_file/job_normalizer.rbs +27 -0
  87. data/sig/kaal/scheduler_file/loader.rbs +69 -0
  88. data/sig/kaal/scheduler_file/payload_loader.rbs +33 -0
  89. data/sig/kaal/scheduler_file/placeholder_support.rbs +19 -0
  90. data/sig/kaal/scheduler_file.rbs +9 -0
  91. data/sig/kaal/sequel_support.rbs +25 -0
  92. data/sig/kaal/support/hash_tools.rbs +27 -0
  93. data/sig/kaal/utils/cron_humanizer.rbs +39 -0
  94. data/sig/kaal/utils/cron_utils.rbs +43 -0
  95. data/sig/kaal/utils/idempotency_key_generator.rbs +5 -0
  96. data/sig/kaal/utils.rbs +9 -0
  97. data/sig/kaal/version.rbs +3 -0
  98. data/sig/kaal.rbs +145 -0
  99. metadata +90 -3
  100. data/config/kaal.rb +0 -15
  101. /data/config/{scheduler.yml → kaal-scheduler.yml} +0 -0
@@ -0,0 +1,187 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright Codevedas Inc. 2025-present
4
+ #
5
+ # This source code is licensed under the MIT license found in the
6
+ # LICENSE file in the root directory of this source tree.
7
+ require 'erb'
8
+ require 'yaml'
9
+
10
+ module Kaal
11
+ module Config
12
+ # Loads Kaal runtime configuration from config/kaal.yml and KAAL_* env vars.
13
+ class FileLoader
14
+ # Normalizes a single environment variable value into the requested config type.
15
+ class EnvValue
16
+ def initialize(value)
17
+ @value = value.to_s.strip
18
+ end
19
+
20
+ def coerce(key:, env_name:)
21
+ case key
22
+ when :tick_interval, :window_lookback, :window_lookahead, :lease_ttl, :recovery_window, :recovery_startup_jitter
23
+ coerce_integer(env_name)
24
+ when :enable_log_dispatch_registry, :enable_dispatch_recovery
25
+ coerce_boolean(env_name)
26
+ when :scheduler_conflict_policy, :scheduler_missing_file_policy
27
+ @value.to_sym
28
+ when :delayed_job_allowed_class_prefixes
29
+ @value.split(',').map(&:strip).reject(&:empty?)
30
+ else
31
+ @value
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def coerce_boolean(env_name)
38
+ normalized_value = @value.downcase
39
+ return true if %w[1 true yes on].include?(normalized_value)
40
+ return false if %w[0 false no off].include?(normalized_value)
41
+
42
+ raise Kaal::ConfigurationError, "ENV #{env_name} must be a boolean"
43
+ end
44
+
45
+ def coerce_integer(env_name)
46
+ raise Kaal::ConfigurationError, "ENV #{env_name} must be an integer" unless @value.match?(/\A-?\d+\z/)
47
+
48
+ @value.to_i
49
+ end
50
+ end
51
+
52
+ ENV_KEY_MAP = {
53
+ 'KAAL_BACKEND' => :backend,
54
+ 'KAAL_NAMESPACE' => :namespace,
55
+ 'KAAL_TICK_INTERVAL' => :tick_interval,
56
+ 'KAAL_WINDOW_LOOKBACK' => :window_lookback,
57
+ 'KAAL_WINDOW_LOOKAHEAD' => :window_lookahead,
58
+ 'KAAL_LEASE_TTL' => :lease_ttl,
59
+ 'KAAL_SCHEDULER_CONFIG_PATH' => :scheduler_config_path,
60
+ 'KAAL_ENABLE_LOG_DISPATCH_REGISTRY' => :enable_log_dispatch_registry,
61
+ 'KAAL_ENABLE_DISPATCH_RECOVERY' => :enable_dispatch_recovery,
62
+ 'KAAL_RECOVERY_WINDOW' => :recovery_window,
63
+ 'KAAL_RECOVERY_STARTUP_JITTER' => :recovery_startup_jitter,
64
+ 'KAAL_TIME_ZONE' => :time_zone,
65
+ 'KAAL_SCHEDULER_CONFLICT_POLICY' => :scheduler_conflict_policy,
66
+ 'KAAL_SCHEDULER_MISSING_FILE_POLICY' => :scheduler_missing_file_policy,
67
+ 'KAAL_DELAYED_JOB_ALLOWED_CLASS_PREFIXES' => :delayed_job_allowed_class_prefixes
68
+ }.freeze
69
+ CONFIG_KEY_TO_ENV_KEY = ENV_KEY_MAP.invert.freeze
70
+ CONFIGURATION_ASSIGNERS = {
71
+ namespace: ->(config, value) { config.namespace = value },
72
+ tick_interval: ->(config, value) { config.tick_interval = value },
73
+ window_lookback: ->(config, value) { config.window_lookback = value },
74
+ window_lookahead: ->(config, value) { config.window_lookahead = value },
75
+ lease_ttl: ->(config, value) { config.lease_ttl = value },
76
+ scheduler_config_path: ->(config, value) { config.scheduler_config_path = value },
77
+ enable_log_dispatch_registry: ->(config, value) { config.enable_log_dispatch_registry = value },
78
+ enable_dispatch_recovery: ->(config, value) { config.enable_dispatch_recovery = value },
79
+ recovery_window: ->(config, value) { config.recovery_window = value },
80
+ recovery_startup_jitter: ->(config, value) { config.recovery_startup_jitter = value },
81
+ time_zone: ->(config, value) { config.time_zone = value },
82
+ scheduler_conflict_policy: ->(config, value) { config.scheduler_conflict_policy = value },
83
+ scheduler_missing_file_policy: ->(config, value) { config.scheduler_missing_file_policy = value },
84
+ delayed_job_allowed_class_prefixes: ->(config, value) { config.delayed_job_allowed_class_prefixes = value },
85
+ logger: ->(config, value) { config.logger = value }
86
+ }.freeze
87
+
88
+ def initialize(configuration:, runtime_context:, env: ENV)
89
+ @configuration = configuration
90
+ @runtime_context = runtime_context
91
+ @env = env
92
+ @config_key_to_env_key = CONFIG_KEY_TO_ENV_KEY
93
+ end
94
+
95
+ def load(path: 'config/kaal.yml')
96
+ absolute_path = @runtime_context.resolve_path(path)
97
+ payload = File.exist?(absolute_path) ? parse_yaml(absolute_path) : {}
98
+ merged = merge_environment_config(payload)
99
+ merged = apply_env_overrides(merged)
100
+ apply_configuration(merged)
101
+ @configuration.validate!
102
+ @configuration
103
+ end
104
+
105
+ private
106
+
107
+ def parse_yaml(path)
108
+ rendered = render_yaml(path)
109
+ parsed = YAML.safe_load(rendered, aliases: true) || {}
110
+ raise Kaal::ConfigurationError, "Expected Kaal config YAML root to be a mapping in #{path}" unless parsed.is_a?(Hash)
111
+
112
+ Kaal::Support::HashTools.stringify_keys(parsed)
113
+ rescue Psych::Exception => e
114
+ raise Kaal::ConfigurationError, "Failed to parse Kaal config YAML at #{path}: #{e.message}"
115
+ end
116
+
117
+ def render_yaml(path)
118
+ ERB.new(File.read(path), trim_mode: '-').result
119
+ rescue StandardError, SyntaxError => e
120
+ raise Kaal::ConfigurationError, "Failed to evaluate Kaal config ERB at #{path}: #{e.message}"
121
+ end
122
+
123
+ def merge_environment_config(payload)
124
+ defaults = hash_section(payload['defaults'])
125
+ environment = hash_section(payload[@runtime_context.environment_name])
126
+
127
+ Kaal::Support::HashTools.deep_merge(defaults, environment)
128
+ end
129
+
130
+ def hash_section(value)
131
+ case value
132
+ in Hash
133
+ Kaal::Support::HashTools.stringify_keys(Kaal::Support::HashTools.deep_dup(value))
134
+ in nil
135
+ {}
136
+ else
137
+ raise Kaal::ConfigurationError, 'Kaal config sections must be mappings'
138
+ end
139
+ end
140
+
141
+ def apply_env_overrides(config)
142
+ merged = Kaal::Support::HashTools.deep_dup(config)
143
+
144
+ ENV_KEY_MAP.each do |env_key, config_key|
145
+ next unless @env.key?(env_key)
146
+
147
+ merged[config_key.to_s] = coerce_env_value(config_key, @env.fetch(env_key))
148
+ end
149
+
150
+ backend_url = @env['KAAL_BACKEND_URL']&.to_s&.strip
151
+ if @env.key?('KAAL_BACKEND_URL')
152
+ backend_config = hash_section(merged['backend_config'])
153
+ if backend_config.key?('connection')
154
+ backend_config['connection'] = backend_url
155
+ else
156
+ backend_config['url'] = backend_url
157
+ end
158
+ merged['backend_config'] = backend_config
159
+ end
160
+
161
+ merged
162
+ end
163
+
164
+ def coerce_env_value(key, value)
165
+ EnvValue.new(value).coerce(key:, env_name: @config_key_to_env_key.fetch(key))
166
+ end
167
+
168
+ def apply_configuration(config)
169
+ normalized = Kaal::Support::HashTools.symbolize_keys(config)
170
+ backend_config = normalized.delete(:backend_config) || {}
171
+ backend_name = normalized.delete(:backend)
172
+ @configuration.apply_backend_runtime_context(@runtime_context)
173
+
174
+ normalized.each do |key, value|
175
+ apply_configuration_value(key, value)
176
+ end
177
+
178
+ @configuration.backend_config = backend_config
179
+ @configuration.backend = backend_name if backend_name
180
+ end
181
+
182
+ def apply_configuration_value(key, value)
183
+ CONFIGURATION_ASSIGNERS[key]&.call(@configuration, value)
184
+ end
185
+ end
186
+ end
187
+ end
data/lib/kaal/config.rb CHANGED
@@ -5,7 +5,9 @@
5
5
  # This source code is licensed under the MIT license found in the
6
6
  # LICENSE file in the root directory of this source tree.
7
7
  require 'kaal/config/configuration'
8
+ require 'kaal/config/backend_factory'
8
9
  require 'kaal/config/delayed_job_security_policy'
10
+ require 'kaal/config/file_loader'
9
11
  require 'kaal/config/scheduler_config_error'
10
12
  require 'kaal/config/scheduler_time_zone_resolver'
11
13
 
@@ -5,7 +5,7 @@
5
5
  # This source code is licensed under the MIT license found in the
6
6
  # LICENSE file in the root directory of this source tree.
7
7
  module Kaal
8
- # Loads scheduler.yml at framework boot time while respecting missing-file policy.
8
+ # Loads kaal-scheduler.yml at framework boot time while respecting missing-file policy.
9
9
  class SchedulerBootLoader
10
10
  def initialize(configuration_provider:, logger:, runtime_context:, load_scheduler_file:)
11
11
  @configuration_provider = configuration_provider
@@ -14,7 +14,7 @@ require_relative 'job_normalizer'
14
14
  require_relative 'job_applier'
15
15
 
16
16
  module Kaal
17
- # Loads scheduler definitions from config/scheduler.yml and registers them.
17
+ # Loads scheduler definitions from config/kaal-scheduler.yml and registers them.
18
18
  class SchedulerFileLoader
19
19
  include SchedulerHashTransform
20
20
  include SchedulerPlaceholderSupport
data/lib/kaal/version.rb CHANGED
@@ -5,5 +5,5 @@
5
5
  # This source code is licensed under the MIT license found in the
6
6
  # LICENSE file in the root directory of this source tree.
7
7
  module Kaal
8
- VERSION = '0.5.0'
8
+ VERSION = '0.6.0'
9
9
  end
data/lib/kaal.rb CHANGED
@@ -88,6 +88,13 @@ module Kaal
88
88
  yield(configuration) if block_given?
89
89
  end
90
90
 
91
+ def load_config_file!(path: 'config/kaal.yml', runtime_context: RuntimeContext.default)
92
+ Config::FileLoader.new(
93
+ configuration: configuration,
94
+ runtime_context:
95
+ ).load(path:)
96
+ end
97
+
91
98
  def register(key:, cron:, enqueue:)
92
99
  registration_service.call(key:, cron:, enqueue:)
93
100
  end
data/sig/00_types.rbs ADDED
@@ -0,0 +1,12 @@
1
+ module Kaal
2
+ interface _RBSOpaque
3
+ end
4
+
5
+ interface _RBSCallable
6
+ def call: (*rbs_any args, **rbs_any kwargs) -> rbs_any
7
+ end
8
+
9
+ type rbs_scalar = nil | bool | Integer | Float | Rational | String | Symbol | Time
10
+ type rbs_hash_key = String | Symbol | Integer
11
+ type rbs_any = rbs_scalar | _RBSOpaque | _RBSCallable | Array[rbs_any] | Hash[rbs_hash_key, rbs_any]
12
+ end
@@ -0,0 +1,49 @@
1
+ class Thor
2
+ class Error < StandardError
3
+ end
4
+
5
+ class Base
6
+ module Shell
7
+ def self.new: () -> Kaal::_RBSOpaque
8
+ end
9
+
10
+ def self.shell: () -> singleton(Shell)
11
+ end
12
+
13
+ def self.package_name: (String name) -> void
14
+ def self.class_option: (*Kaal::rbs_any args, **Kaal::rbs_any kwargs) -> void
15
+ def self.desc: (String usage, String description) -> void
16
+ def self.option: (*Kaal::rbs_any args, **Kaal::rbs_any kwargs) -> void
17
+ def self.no_commands: () { () -> Kaal::rbs_any } -> void
18
+ end
19
+
20
+ class Redis
21
+ def initialize: (*Kaal::rbs_any args, **Kaal::rbs_any kwargs) -> void
22
+ end
23
+
24
+ module Sequel
25
+ class Database
26
+ def connection: () -> Kaal::_RBSOpaque
27
+ def database_type: () -> String
28
+ def adapter_scheme: () -> String
29
+ end
30
+
31
+ def self.connect: (*Kaal::rbs_any args, **Kaal::rbs_any kwargs) -> Database
32
+ end
33
+
34
+ module ActiveSupport
35
+ module Inflector
36
+ def self.underscore: (String value) -> String
37
+ end
38
+ end
39
+
40
+ module ActiveRecord
41
+ class ConnectionNotEstablished < StandardError
42
+ end
43
+
44
+ class RecordNotUnique < StandardError
45
+ end
46
+
47
+ class Base
48
+ end
49
+ end
@@ -0,0 +1,23 @@
1
+ module Kaal
2
+ module ActiveRecord
3
+ def self.install_postgres_migration: (target_dir: Kaal::rbs_any, ?migration_name: ::String) -> Kaal::rbs_any
4
+
5
+ def self.install_mysql_migration: (target_dir: Kaal::rbs_any, ?migration_name: ::String) -> Kaal::rbs_any
6
+
7
+ def self.install_sqlite_migration: (target_dir: Kaal::rbs_any, ?migration_name: ::String) -> Kaal::rbs_any
8
+
9
+ def self.install_migrations: (target_dir: Kaal::rbs_any, backend: Kaal::rbs_any, ?migration_name: Kaal::rbs_any?, ?time_source: Kaal::rbs_any) -> Kaal::rbs_any
10
+
11
+ def self.require_activerecord!: () -> Kaal::rbs_any
12
+
13
+ def self.normalize_migration_name: (Kaal::rbs_any name, fallback: Kaal::rbs_any) -> Kaal::rbs_any
14
+
15
+ def self.underscore: (Kaal::rbs_any value) -> Kaal::rbs_any
16
+
17
+ def self.default_migration_class_for: (Kaal::rbs_any backend) -> ::String
18
+
19
+ def self.migration_suffixes_for: (Kaal::rbs_any backend) -> (::Array["dispatches" | "locks" | "definitions" | "delayed_jobs"] | ::Array["dispatches" | "definitions" | "delayed_jobs"])
20
+
21
+ def self.alphanumeric?: (Kaal::rbs_any char) -> Kaal::rbs_any
22
+ end
23
+ end
@@ -0,0 +1,26 @@
1
+ module Kaal
2
+ module Backend
3
+ class Adapter
4
+ def acquire: (Kaal::rbs_any _key, Kaal::rbs_any _ttl) -> Kaal::rbs_any
5
+
6
+ def release: (Kaal::rbs_any _key) -> Kaal::rbs_any
7
+
8
+ def with_lock: (Kaal::rbs_any key, ttl: Kaal::rbs_any) { () -> Kaal::rbs_any } -> (nil | Kaal::rbs_any)
9
+
10
+ def definition_registry: () -> nil
11
+
12
+ def delayed_store: () -> nil
13
+ end
14
+
15
+ class NullAdapter < Adapter
16
+ def acquire: (Kaal::rbs_any _key, Kaal::rbs_any _ttl) -> true
17
+
18
+ def release: (Kaal::rbs_any _key) -> true
19
+
20
+ def with_lock: (Kaal::rbs_any _key, **Kaal::rbs_any) { () -> Kaal::rbs_any } -> Kaal::rbs_any
21
+ end
22
+
23
+ class LockAdapterError < StandardError
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ module Kaal
2
+ module Backend
3
+ class DispatchAttemptLogger
4
+ @configuration: Kaal::rbs_any
5
+
6
+ @dispatch_registry_provider: Kaal::rbs_any
7
+
8
+ @logger: Kaal::rbs_any
9
+
10
+ @node_id_provider: Kaal::rbs_any
11
+
12
+ def initialize: (configuration: Kaal::rbs_any, dispatch_registry_provider: Kaal::rbs_any, ?logger: Kaal::rbs_any?, ?node_id_provider: Kaal::rbs_any) -> void
13
+
14
+ def call: (Kaal::rbs_any lock_key) -> Kaal::rbs_any
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,23 @@
1
+ module Kaal
2
+ module Backend
3
+ module DispatchLogging
4
+ @dispatch_attempt_logger: Kaal::rbs_any
5
+
6
+ def dispatch_registry: () -> nil
7
+
8
+ def log_dispatch_attempt: (Kaal::rbs_any key) -> Kaal::rbs_any
9
+
10
+ def parse_lock_key: (Kaal::rbs_any key) -> Kaal::rbs_any
11
+
12
+ def self.parse_lock_key: (Kaal::rbs_any key) -> ::Array[Kaal::rbs_any]
13
+
14
+ def self.validate_lock_key!: (Kaal::rbs_any valid, Kaal::rbs_any message) -> (Kaal::rbs_any | nil)
15
+
16
+ def self.invalid_dispatch_lock_key!: (Kaal::rbs_any message) -> Kaal::rbs_any
17
+
18
+ private
19
+
20
+ def dispatch_attempt_logger: () -> Kaal::rbs_any
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ module Kaal
2
+ module Backend
3
+ class DispatchRegistryAccessor
4
+ @configuration: Kaal::rbs_any
5
+
6
+ def initialize: (configuration: Kaal::rbs_any) -> void
7
+
8
+ def dispatched?: (Kaal::rbs_any key, Kaal::rbs_any fire_time) -> Kaal::rbs_any
9
+
10
+ def registry: () -> Kaal::rbs_any
11
+
12
+ private
13
+
14
+ def fetch_registry: () -> (nil | Kaal::rbs_any)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,33 @@
1
+ module Kaal
2
+ module Backend
3
+ class MemoryAdapter < Adapter
4
+ @locks: Kaal::rbs_any
5
+
6
+ @mutex: Kaal::rbs_any
7
+
8
+ @dispatch_registry: Kaal::rbs_any
9
+
10
+ @definition_registry: Kaal::rbs_any
11
+
12
+ @delayed_store: Kaal::rbs_any
13
+
14
+ include DispatchLogging
15
+
16
+ def initialize: () -> void
17
+
18
+ def dispatch_registry: () -> Kaal::rbs_any
19
+
20
+ def definition_registry: () -> Kaal::rbs_any
21
+
22
+ def delayed_store: () -> Kaal::rbs_any
23
+
24
+ def acquire: (Kaal::rbs_any key, Kaal::rbs_any ttl) -> Kaal::rbs_any
25
+
26
+ def release: (Kaal::rbs_any key) -> Kaal::rbs_any
27
+
28
+ private
29
+
30
+ def prune_expired_locks: () -> Kaal::rbs_any
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ module Kaal
2
+ module Backend
3
+ class MySQL < Adapter
4
+ @engine: Kaal::rbs_any
5
+
6
+ UNSET_SKIP_LOCKED_SUPPORT: Kaal::rbs_any
7
+
8
+ def initialize: (?database: Kaal::rbs_any?, ?connection: Kaal::rbs_any?, ?namespace: Kaal::rbs_any?, ?use_skip_locked: Kaal::rbs_any) -> void
9
+
10
+ def dispatch_registry: () -> Kaal::rbs_any
11
+
12
+ def definition_registry: () -> Kaal::rbs_any
13
+
14
+ def delayed_store: () -> Kaal::rbs_any
15
+
16
+ def acquire: (Kaal::rbs_any key, Kaal::rbs_any ttl) -> Kaal::rbs_any
17
+
18
+ def release: (Kaal::rbs_any key) -> Kaal::rbs_any
19
+
20
+ def self.build_sequel_backend: (Kaal::rbs_any database, Kaal::rbs_any namespace, Kaal::rbs_any use_skip_locked) -> Kaal::rbs_any
21
+
22
+ def self.build_active_record_backend: (Kaal::rbs_any connection, Kaal::rbs_any namespace, Kaal::rbs_any use_skip_locked) -> Kaal::rbs_any
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ module Kaal
2
+ module Backend
3
+ class Postgres < Adapter
4
+ @engine: Kaal::rbs_any
5
+
6
+ def initialize: (?database: Kaal::rbs_any?, ?connection: Kaal::rbs_any?, ?namespace: Kaal::rbs_any?) -> void
7
+
8
+ def dispatch_registry: () -> Kaal::rbs_any
9
+
10
+ def definition_registry: () -> Kaal::rbs_any
11
+
12
+ def delayed_store: () -> Kaal::rbs_any
13
+
14
+ def acquire: (Kaal::rbs_any key, Kaal::rbs_any ttl) -> Kaal::rbs_any
15
+
16
+ def release: (Kaal::rbs_any key) -> Kaal::rbs_any
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,41 @@
1
+ module Kaal
2
+ module Backend
3
+ class RedisAdapter < Adapter
4
+ @redis: Kaal::rbs_any
5
+
6
+ @namespace: Kaal::rbs_any
7
+
8
+ @lock_value_generator: Kaal::rbs_any
9
+
10
+ @lock_values: Kaal::rbs_any
11
+
12
+ @mutex: Kaal::rbs_any
13
+
14
+ @dispatch_registry: Kaal::rbs_any
15
+
16
+ @definition_registry: Kaal::rbs_any
17
+
18
+ @delayed_store: Kaal::rbs_any
19
+
20
+ include DispatchLogging
21
+
22
+ def initialize: (Kaal::rbs_any redis, ?namespace: ::String) -> void
23
+
24
+ def dispatch_registry: () -> Kaal::rbs_any
25
+
26
+ def definition_registry: () -> Kaal::rbs_any
27
+
28
+ def delayed_store: () -> Kaal::rbs_any
29
+
30
+ def acquire: (Kaal::rbs_any key, Kaal::rbs_any ttl) -> Kaal::rbs_any
31
+
32
+ def release: (Kaal::rbs_any key) -> Kaal::rbs_any
33
+
34
+ private
35
+
36
+ def generate_lock_value: () -> Kaal::rbs_any
37
+
38
+ def prune_expired_lock_values: () -> Kaal::rbs_any
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,19 @@
1
+ module Kaal
2
+ module Backend
3
+ class SQLite < Adapter
4
+ @engine: Kaal::rbs_any
5
+
6
+ def initialize: (?database: Kaal::rbs_any?, ?connection: Kaal::rbs_any?, ?namespace: Kaal::rbs_any?, **Kaal::rbs_any) -> void
7
+
8
+ def dispatch_registry: () -> Kaal::rbs_any
9
+
10
+ def definition_registry: () -> Kaal::rbs_any
11
+
12
+ def delayed_store: () -> Kaal::rbs_any
13
+
14
+ def acquire: (Kaal::rbs_any key, Kaal::rbs_any ttl) -> Kaal::rbs_any
15
+
16
+ def release: (Kaal::rbs_any key) -> Kaal::rbs_any
17
+ end
18
+ end
19
+ end
data/sig/kaal/cli.rbs ADDED
@@ -0,0 +1,41 @@
1
+ module Kaal
2
+ class CLI < Thor
3
+ module Helpers
4
+ private
5
+
6
+ def load_project!: () -> Kaal::rbs_any
7
+
8
+ def root_path: () -> Kaal::rbs_any
9
+
10
+ def config_path: () -> Kaal::rbs_any
11
+
12
+ def scheduler_path: () -> Kaal::rbs_any
13
+
14
+ def render_config_template: (Kaal::rbs_any backend) -> Kaal::rbs_any
15
+
16
+ def scheduler_template: () -> "defaults:\n jobs:\n - key: \"example:heartbeat\"\n cron: \"*/5 * * * *\"\n job_class: \"ExampleHeartbeatJob\"\n enabled: true\n args:\n - \"{{fire_time.iso8601}}\"\n kwargs:\n idempotency_key: \"{{idempotency_key}}\"\n metadata:\n owner: \"ops\"\n"
17
+ end
18
+
19
+ def init: () -> Kaal::rbs_any
20
+
21
+ def start: () -> Kaal::rbs_any
22
+
23
+ def status: () -> Kaal::rbs_any
24
+
25
+ def tick: () -> Kaal::rbs_any
26
+
27
+ def explain: (Kaal::rbs_any expression) -> Kaal::rbs_any
28
+
29
+ def next: (Kaal::rbs_any expression) -> Kaal::rbs_any
30
+
31
+ def self.exit_on_failure?: () -> true
32
+
33
+ def self.write_file: (Kaal::rbs_any path, Kaal::rbs_any contents) -> (nil | Kaal::rbs_any)
34
+
35
+ def self.install_foreground_signal_handlers: (Kaal::rbs_any signal_state) -> Kaal::rbs_any
36
+
37
+ def self.restore_signal_handlers: (Kaal::rbs_any previous_handlers) -> Kaal::rbs_any
38
+
39
+ def self.shutdown_scheduler: (signal: Kaal::rbs_any, signal_state: Kaal::rbs_any, ?previous_handler: Kaal::rbs_any?, ?shell: Kaal::rbs_any?) -> Kaal::rbs_any
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ module Kaal
2
+ module Config
3
+ module BackendFactory
4
+ SUPPORTED_BACKENDS: ::Array["memory" | "redis" | "sqlite" | "postgres" | "mysql"]
5
+
6
+ def self.normalize_name: (Kaal::rbs_any name) -> (nil | Kaal::rbs_any)
7
+
8
+ def self.build: (Kaal::rbs_any name, backend_config: Kaal::rbs_any, namespace: Kaal::rbs_any, ?runtime_context: Kaal::rbs_any?) -> Kaal::rbs_any
9
+
10
+ def self.normalize_backend_config: (Kaal::rbs_any backend_config) -> Kaal::rbs_any
11
+
12
+ def self.build_redis_backend: (Kaal::rbs_any config, Kaal::rbs_any namespace) -> Kaal::rbs_any
13
+
14
+ def self.build_sqlite_backend: (Kaal::rbs_any config, Kaal::rbs_any namespace, Kaal::rbs_any runtime_context) -> Kaal::rbs_any
15
+
16
+ def self.build_postgres_backend: (Kaal::rbs_any config, Kaal::rbs_any namespace) -> Kaal::rbs_any
17
+
18
+ def self.build_mysql_backend: (Kaal::rbs_any config, Kaal::rbs_any namespace) -> Kaal::rbs_any
19
+
20
+ def self.build_sqlite_connection: (Kaal::rbs_any connection, Kaal::rbs_any runtime_context) -> Kaal::rbs_any
21
+
22
+ def self.normalize_connection_hash: (Kaal::rbs_any connection, Kaal::rbs_any default_adapter, Kaal::rbs_any runtime_context) -> Kaal::rbs_any
23
+
24
+ def self.resolve_sqlite_database_path: (Kaal::rbs_any database, Kaal::rbs_any runtime_context) -> Kaal::rbs_any
25
+
26
+ def self.sqlite_uri?: (Kaal::rbs_any value) -> Kaal::rbs_any
27
+
28
+ def self.sequel_sqlite_database: (Kaal::rbs_any target, Kaal::rbs_any runtime_context) -> Kaal::rbs_any
29
+
30
+ def self.ensure_sqlite_directory!: (Kaal::rbs_any database_path) -> Kaal::rbs_any
31
+
32
+ def self.adapter_name_for_error: (Kaal::rbs_any adapter) -> ("postgres" | "mysql")
33
+
34
+ def self.string_value: (Kaal::rbs_any value) -> Kaal::rbs_any
35
+
36
+ def self.require_redis!: () -> Kaal::rbs_any
37
+
38
+ def self.require_sequel!: () -> Kaal::rbs_any
39
+ end
40
+ end
41
+ end