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.
- checksums.yaml +4 -4
- data/README.md +24 -24
- data/config/kaal.yml +12 -0
- data/lib/kaal/backend/adapter.rb +4 -0
- data/lib/kaal/cli.rb +38 -34
- data/lib/kaal/config/backend_factory.rb +178 -0
- data/lib/kaal/config/configuration.rb +65 -7
- data/lib/kaal/config/file_loader.rb +187 -0
- data/lib/kaal/config.rb +2 -0
- data/lib/kaal/runtime/scheduler_boot_loader.rb +1 -1
- data/lib/kaal/scheduler_file/loader.rb +1 -1
- data/lib/kaal/version.rb +1 -1
- data/lib/kaal.rb +7 -0
- data/sig/00_types.rbs +12 -0
- data/sig/dependencies.rbs +49 -0
- data/sig/kaal/active_record_support.rbs +23 -0
- data/sig/kaal/backend/adapter.rbs +26 -0
- data/sig/kaal/backend/dispatch_attempt_logger.rbs +17 -0
- data/sig/kaal/backend/dispatch_logging.rbs +23 -0
- data/sig/kaal/backend/dispatch_registry_accessor.rbs +17 -0
- data/sig/kaal/backend/memory_adapter.rbs +33 -0
- data/sig/kaal/backend/mysql.rbs +25 -0
- data/sig/kaal/backend/postgres.rbs +19 -0
- data/sig/kaal/backend/redis_adapter.rbs +41 -0
- data/sig/kaal/backend/sqlite.rbs +19 -0
- data/sig/kaal/cli.rbs +41 -0
- data/sig/kaal/config/backend_factory.rbs +41 -0
- data/sig/kaal/config/configuration.rbs +70 -0
- data/sig/kaal/config/delayed_job_security_policy.rbs +19 -0
- data/sig/kaal/config/file_loader.rbs +35 -0
- data/sig/kaal/config/scheduler_config_error.rbs +4 -0
- data/sig/kaal/config/scheduler_time_zone_resolver.rbs +19 -0
- data/sig/kaal/config.rbs +11 -0
- data/sig/kaal/core/coordinator.rbs +103 -0
- data/sig/kaal/core/enabled_entry_enumerator.rbs +21 -0
- data/sig/kaal/core/occurrence_finder.rbs +9 -0
- data/sig/kaal/core.rbs +9 -0
- data/sig/kaal/definition/database_engine.rbs +25 -0
- data/sig/kaal/definition/memory_engine.rbs +23 -0
- data/sig/kaal/definition/persistence_helpers.rbs +9 -0
- data/sig/kaal/definition/redis_engine.rbs +33 -0
- data/sig/kaal/definition/registry.rbs +29 -0
- data/sig/kaal/definitions/registration_service.rbs +27 -0
- data/sig/kaal/definitions/registry_accessor.rbs +17 -0
- data/sig/kaal/delayed_job/database_engine.rbs +37 -0
- data/sig/kaal/delayed_job/dispatch_failure_logger.rbs +7 -0
- data/sig/kaal/delayed_job/memory_engine.rbs +29 -0
- data/sig/kaal/delayed_job/mysql_version_support.rbs +15 -0
- data/sig/kaal/delayed_job/redis_engine.rbs +31 -0
- data/sig/kaal/delayed_job/registry.rbs +20 -0
- data/sig/kaal/dispatch/database_engine.rbs +39 -0
- data/sig/kaal/dispatch/memory_engine.rbs +23 -0
- data/sig/kaal/dispatch/redis_engine.rbs +25 -0
- data/sig/kaal/dispatch/registry.rbs +11 -0
- data/sig/kaal/internal/active_record/base_record.rbs +8 -0
- data/sig/kaal/internal/active_record/connection_support.rbs +25 -0
- data/sig/kaal/internal/active_record/database_backend.rbs +37 -0
- data/sig/kaal/internal/active_record/definition_record.rbs +8 -0
- data/sig/kaal/internal/active_record/definition_registry.rbs +27 -0
- data/sig/kaal/internal/active_record/delayed_job_record.rbs +8 -0
- data/sig/kaal/internal/active_record/delayed_job_registry.rbs +39 -0
- data/sig/kaal/internal/active_record/dispatch_record.rbs +8 -0
- data/sig/kaal/internal/active_record/dispatch_registry.rbs +43 -0
- data/sig/kaal/internal/active_record/lock_record.rbs +8 -0
- data/sig/kaal/internal/active_record/migration_templates.rbs +17 -0
- data/sig/kaal/internal/active_record/mysql_backend.rbs +45 -0
- data/sig/kaal/internal/active_record/postgres_backend.rbs +41 -0
- data/sig/kaal/internal/active_record.rbs +0 -0
- data/sig/kaal/internal/sequel/database_backend.rbs +39 -0
- data/sig/kaal/internal/sequel/mysql_backend.rbs +47 -0
- data/sig/kaal/internal/sequel/postgres_backend.rbs +43 -0
- data/sig/kaal/internal/sequel.rbs +0 -0
- data/sig/kaal/job_dispatcher.rbs +19 -0
- data/sig/kaal/persistence/database.rbs +19 -0
- data/sig/kaal/persistence/migration_templates.rbs +15 -0
- data/sig/kaal/register_conflict_support.rbs +11 -0
- data/sig/kaal/registry.rbs +44 -0
- data/sig/kaal/runtime/runtime_context.rbs +23 -0
- data/sig/kaal/runtime/scheduler_boot_loader.rbs +23 -0
- data/sig/kaal/runtime/signal_handler_chain.rbs +19 -0
- data/sig/kaal/runtime/signal_handler_installer.rbs +19 -0
- data/sig/kaal/runtime.rbs +11 -0
- data/sig/kaal/scheduler_file/hash_transform.rbs +9 -0
- data/sig/kaal/scheduler_file/helper_bundle.rbs +15 -0
- data/sig/kaal/scheduler_file/job_applier.rbs +43 -0
- data/sig/kaal/scheduler_file/job_normalizer.rbs +27 -0
- data/sig/kaal/scheduler_file/loader.rbs +69 -0
- data/sig/kaal/scheduler_file/payload_loader.rbs +33 -0
- data/sig/kaal/scheduler_file/placeholder_support.rbs +19 -0
- data/sig/kaal/scheduler_file.rbs +9 -0
- data/sig/kaal/sequel_support.rbs +25 -0
- data/sig/kaal/support/hash_tools.rbs +27 -0
- data/sig/kaal/utils/cron_humanizer.rbs +39 -0
- data/sig/kaal/utils/cron_utils.rbs +43 -0
- data/sig/kaal/utils/idempotency_key_generator.rbs +5 -0
- data/sig/kaal/utils.rbs +9 -0
- data/sig/kaal/version.rbs +3 -0
- data/sig/kaal.rbs +145 -0
- metadata +90 -3
- data/config/kaal.rb +0 -15
- /data/config/{scheduler.yml → kaal-scheduler.yml} +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class Configuration
|
|
3
|
+
@values: Kaal::rbs_any
|
|
4
|
+
|
|
5
|
+
@backend_name: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@backend_runtime_context: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
DEFAULTS: { tick_interval: 5, window_lookback: 120, window_lookahead: 0, lease_ttl: 125, namespace: "kaal", backend: nil, backend_config: ::Hash[Kaal::rbs_any, Kaal::rbs_any], logger: nil, time_zone: nil, enable_log_dispatch_registry: false, enable_dispatch_recovery: true, recovery_window: 86400, recovery_startup_jitter: 5, scheduler_config_path: "config/kaal-scheduler.yml", scheduler_conflict_policy: :error, scheduler_missing_file_policy: :warn, delayed_job_allowed_class_prefixes: ::Array[Kaal::rbs_any] }
|
|
10
|
+
|
|
11
|
+
def initialize: () -> void
|
|
12
|
+
|
|
13
|
+
def method_missing: (Kaal::rbs_any method_name, *Kaal::rbs_any args) -> Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
def respond_to_missing?: (Kaal::rbs_any method_name, ?bool include_private) -> Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
def validate: () -> Kaal::rbs_any
|
|
18
|
+
|
|
19
|
+
attr_accessor backend_runtime_context: Kaal::rbs_any
|
|
20
|
+
|
|
21
|
+
def validation_warnings: () -> Kaal::rbs_any
|
|
22
|
+
|
|
23
|
+
def validate!: () -> self
|
|
24
|
+
|
|
25
|
+
def to_h: () -> { tick_interval: Kaal::rbs_any, window_lookback: Kaal::rbs_any, window_lookahead: Kaal::rbs_any, lease_ttl: Kaal::rbs_any, namespace: Kaal::rbs_any, backend: Kaal::rbs_any, backend_config: Kaal::rbs_any, logger: Kaal::rbs_any, time_zone: Kaal::rbs_any, enable_log_dispatch_registry: Kaal::rbs_any, enable_dispatch_recovery: Kaal::rbs_any, recovery_window: Kaal::rbs_any, recovery_startup_jitter: Kaal::rbs_any, scheduler_config_path: Kaal::rbs_any, scheduler_conflict_policy: Kaal::rbs_any, scheduler_missing_file_policy: Kaal::rbs_any, delayed_job_allowed_class_prefixes: Kaal::rbs_any }
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def validation_errors: () -> Kaal::rbs_any
|
|
30
|
+
|
|
31
|
+
def add_tick_interval_error: (Kaal::rbs_any errors) -> (nil | Kaal::rbs_any)
|
|
32
|
+
|
|
33
|
+
def add_window_lookback_error: (Kaal::rbs_any errors) -> (nil | Kaal::rbs_any)
|
|
34
|
+
|
|
35
|
+
def add_window_lookahead_error: (Kaal::rbs_any errors) -> (nil | Kaal::rbs_any)
|
|
36
|
+
|
|
37
|
+
def add_lease_ttl_error: (Kaal::rbs_any errors) -> (nil | Kaal::rbs_any)
|
|
38
|
+
|
|
39
|
+
def add_namespace_error: (Kaal::rbs_any errors) -> (nil | Kaal::rbs_any)
|
|
40
|
+
|
|
41
|
+
def add_backend_config_error: (Kaal::rbs_any errors) -> (nil | Kaal::rbs_any)
|
|
42
|
+
|
|
43
|
+
def add_lease_ttl_window_error: (Kaal::rbs_any errors) -> (nil | Kaal::rbs_any)
|
|
44
|
+
|
|
45
|
+
def add_scheduler_config_path_error: (Kaal::rbs_any errors) -> (nil | Kaal::rbs_any)
|
|
46
|
+
|
|
47
|
+
def add_scheduler_conflict_policy_error: (Kaal::rbs_any errors) -> (nil | Kaal::rbs_any)
|
|
48
|
+
|
|
49
|
+
def add_scheduler_missing_file_policy_error: (Kaal::rbs_any errors) -> (nil | Kaal::rbs_any)
|
|
50
|
+
|
|
51
|
+
def add_delayed_job_security_warning: (Kaal::rbs_any warnings) -> (nil | Kaal::rbs_any)
|
|
52
|
+
|
|
53
|
+
def handle_known_key: (Kaal::rbs_any method_name) { (Kaal::rbs_any, Kaal::rbs_any) -> Kaal::rbs_any } -> (::Array[false | nil] | ::Array[true | Kaal::rbs_any])
|
|
54
|
+
|
|
55
|
+
def set_value: (Kaal::rbs_any key, Kaal::rbs_any value) -> Kaal::rbs_any
|
|
56
|
+
|
|
57
|
+
def normalize_value: (Kaal::rbs_any key, Kaal::rbs_any value) -> Kaal::rbs_any
|
|
58
|
+
|
|
59
|
+
def normalize_backend: (Kaal::rbs_any value) -> Kaal::rbs_any
|
|
60
|
+
|
|
61
|
+
def normalize_backend_config: (Kaal::rbs_any value) -> Kaal::rbs_any
|
|
62
|
+
|
|
63
|
+
def rebuild_symbolic_backend_if_needed: (Kaal::rbs_any key) -> (nil | Kaal::rbs_any)
|
|
64
|
+
|
|
65
|
+
def normalize_delayed_job_allowed_class_prefixes: (Kaal::rbs_any value) -> Kaal::rbs_any
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
class ConfigurationError < StandardError
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Config
|
|
3
|
+
module DelayedJobSecurityPolicy
|
|
4
|
+
NON_SHARED_BACKEND_CLASS_NAMES: ::Array["NilClass" | "Kaal::Backend::MemoryAdapter" | "Kaal::Backend::NullAdapter"]
|
|
5
|
+
|
|
6
|
+
WARNING_MESSAGE: "Delayed jobs resolve stored job_class values at dispatch time. delayed_job_allowed_class_prefixes is empty, so class resolution is unrestricted on this shared backend. Configure a restrictive delayed_job_allowed_class_prefixes list for production deployments."
|
|
7
|
+
|
|
8
|
+
def self.warning_for: (Kaal::rbs_any configuration) -> (nil | Kaal::rbs_any)
|
|
9
|
+
|
|
10
|
+
def self.production_like_environment?: (?env: Kaal::rbs_any, ?rails: Kaal::rbs_any) -> Kaal::rbs_any
|
|
11
|
+
|
|
12
|
+
def self.shared_delayed_job_backend?: (Kaal::rbs_any backend) -> Kaal::rbs_any
|
|
13
|
+
|
|
14
|
+
def self.current_rails: () -> (nil | Kaal::rbs_any)
|
|
15
|
+
|
|
16
|
+
def self.rails_environment: (Kaal::rbs_any rails) -> Kaal::rbs_any
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Config
|
|
3
|
+
class FileLoader
|
|
4
|
+
@configuration: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@runtime_context: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
@env: Kaal::rbs_any
|
|
9
|
+
|
|
10
|
+
ENV_KEY_MAP: ::Hash[::String, ::Symbol]
|
|
11
|
+
|
|
12
|
+
def initialize: (configuration: Kaal::rbs_any, runtime_context: Kaal::rbs_any, ?env: Kaal::rbs_any) -> void
|
|
13
|
+
|
|
14
|
+
def load: (?path: ::String) -> Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def parse_yaml: (Kaal::rbs_any path) -> Kaal::rbs_any
|
|
19
|
+
|
|
20
|
+
def merge_environment_config: (Kaal::rbs_any payload) -> Kaal::rbs_any
|
|
21
|
+
|
|
22
|
+
def hash_section: (Kaal::rbs_any value) -> (::Hash[Kaal::rbs_any, Kaal::rbs_any] | Kaal::rbs_any)
|
|
23
|
+
|
|
24
|
+
def apply_env_overrides: (Kaal::rbs_any config) -> Kaal::rbs_any
|
|
25
|
+
|
|
26
|
+
def coerce_env_value: (Kaal::rbs_any key, Kaal::rbs_any value) -> Kaal::rbs_any
|
|
27
|
+
|
|
28
|
+
def coerce_boolean_env: (Kaal::rbs_any key, Kaal::rbs_any value) -> (true | false | Kaal::rbs_any)
|
|
29
|
+
|
|
30
|
+
def env_name_for: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
31
|
+
|
|
32
|
+
def apply_configuration: (Kaal::rbs_any config) -> Kaal::rbs_any
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class SchedulerTimeZoneResolver
|
|
3
|
+
@configuration: Kaal::rbs_any
|
|
4
|
+
|
|
5
|
+
DEFAULT_TIME_ZONE: "UTC"
|
|
6
|
+
|
|
7
|
+
def initialize: (configuration: Kaal::rbs_any) -> void
|
|
8
|
+
|
|
9
|
+
def time_zone_identifier: () -> Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def configured_time_zone: () -> Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
def normalized_time_zone_value: () -> Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
def raw_time_zone_value: () -> Kaal::rbs_any
|
|
18
|
+
end
|
|
19
|
+
end
|
data/sig/kaal/config.rbs
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class Coordinator
|
|
3
|
+
@configuration: Kaal::rbs_any
|
|
4
|
+
|
|
5
|
+
@registry: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@thread: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
@running: Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
@stop_requested: Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
@mutex: Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
@tick_cv: Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
@scheduler_time_zone_resolver: Kaal::rbs_any
|
|
18
|
+
|
|
19
|
+
@occurrence_finder: Kaal::rbs_any
|
|
20
|
+
|
|
21
|
+
@enabled_entry_enumerator: Kaal::rbs_any
|
|
22
|
+
|
|
23
|
+
DELAYED_JOB_BATCH_SIZE: 100
|
|
24
|
+
|
|
25
|
+
DELAYED_JOB_MAX_BATCHES_PER_TICK: 10
|
|
26
|
+
|
|
27
|
+
DELAYED_JOB_DELETE_CONFIRMATION_JITTER_MAX: ::Float
|
|
28
|
+
|
|
29
|
+
def initialize: (configuration: Kaal::rbs_any, registry: Kaal::rbs_any) -> void
|
|
30
|
+
|
|
31
|
+
def start!: () -> Kaal::rbs_any
|
|
32
|
+
|
|
33
|
+
def stop!: (?timeout: ::Integer) -> (false | true)
|
|
34
|
+
|
|
35
|
+
def running?: () -> Kaal::rbs_any
|
|
36
|
+
|
|
37
|
+
def restart!: () -> Kaal::rbs_any
|
|
38
|
+
|
|
39
|
+
def tick!: () -> Kaal::rbs_any
|
|
40
|
+
|
|
41
|
+
def reset!: () -> Kaal::rbs_any
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def request_stop: () -> Kaal::rbs_any
|
|
46
|
+
|
|
47
|
+
def run_loop: () -> Kaal::rbs_any
|
|
48
|
+
|
|
49
|
+
def stop_requested?: () -> Kaal::rbs_any
|
|
50
|
+
|
|
51
|
+
def execute_tick: () -> Kaal::rbs_any
|
|
52
|
+
|
|
53
|
+
def calculate_and_dispatch_due_times: (Kaal::rbs_any entry) -> (nil | Kaal::rbs_any)
|
|
54
|
+
|
|
55
|
+
def parse_cron: (Kaal::rbs_any cron_expression) -> Kaal::rbs_any
|
|
56
|
+
|
|
57
|
+
def find_occurrences: (Kaal::rbs_any cron, Kaal::rbs_any start_time, Kaal::rbs_any end_time) -> Kaal::rbs_any
|
|
58
|
+
|
|
59
|
+
def dispatch_if_due: (Kaal::rbs_any entry, Kaal::rbs_any fire_time, Kaal::rbs_any now) -> Kaal::rbs_any
|
|
60
|
+
|
|
61
|
+
def recover_missed_runs: () -> Kaal::rbs_any
|
|
62
|
+
|
|
63
|
+
def recover_entry: (Kaal::rbs_any entry, Kaal::rbs_any start_time, Kaal::rbs_any end_time) -> Kaal::rbs_any
|
|
64
|
+
|
|
65
|
+
def cleanup_old_dispatch_records: (Kaal::rbs_any recovery_window) -> Kaal::rbs_any
|
|
66
|
+
|
|
67
|
+
def already_dispatched?: (Kaal::rbs_any key, Kaal::rbs_any fire_time) -> Kaal::rbs_any
|
|
68
|
+
|
|
69
|
+
def acquire_lock: (Kaal::rbs_any lock_key) -> Kaal::rbs_any
|
|
70
|
+
|
|
71
|
+
def each_enabled_entry: () { (Kaal::rbs_any) -> Kaal::rbs_any } -> Kaal::rbs_any
|
|
72
|
+
|
|
73
|
+
def dispatch_work: (Kaal::rbs_any entry, Kaal::rbs_any fire_time) -> Kaal::rbs_any
|
|
74
|
+
|
|
75
|
+
def dispatch_due_delayed_jobs: () -> Kaal::rbs_any
|
|
76
|
+
|
|
77
|
+
def dispatch_delayed_job: (Kaal::rbs_any job, Kaal::rbs_any delayed_store) -> Kaal::rbs_any
|
|
78
|
+
|
|
79
|
+
def delayed_store_for_tick: () -> Kaal::rbs_any
|
|
80
|
+
|
|
81
|
+
def stop_delayed_dispatch?: () -> Kaal::rbs_any
|
|
82
|
+
|
|
83
|
+
def apply_delayed_job_claim_jitter_if_needed: (Kaal::rbs_any delayed_store) -> (nil | Kaal::rbs_any)
|
|
84
|
+
|
|
85
|
+
def generate_idempotency_key: (Kaal::rbs_any cron_key, Kaal::rbs_any fire_time) -> Kaal::rbs_any
|
|
86
|
+
|
|
87
|
+
def generate_lock_key: (Kaal::rbs_any cron_key, Kaal::rbs_any fire_time) -> ::String
|
|
88
|
+
|
|
89
|
+
def generate_delayed_lock_key: (Kaal::rbs_any job_id) -> ::String
|
|
90
|
+
|
|
91
|
+
def sleep_until_next_tick: () -> Kaal::rbs_any
|
|
92
|
+
|
|
93
|
+
def scheduler_time_zone_resolver: () -> Kaal::rbs_any
|
|
94
|
+
|
|
95
|
+
def occurrence_finder: () -> Kaal::rbs_any
|
|
96
|
+
|
|
97
|
+
def enabled_entry_enumerator: () -> Kaal::rbs_any
|
|
98
|
+
|
|
99
|
+
def log_configuration_error: (Kaal::rbs_any prefix, Kaal::rbs_any error, ?logger: Kaal::rbs_any) -> Kaal::rbs_any
|
|
100
|
+
|
|
101
|
+
def log_runtime_error: (Kaal::rbs_any prefix, Kaal::rbs_any error, ?logger: Kaal::rbs_any) -> Kaal::rbs_any
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class EnabledEntryEnumerator
|
|
3
|
+
@configuration: Kaal::rbs_any
|
|
4
|
+
|
|
5
|
+
@registry: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@definition_registry_provider: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
def initialize: (configuration: Kaal::rbs_any, registry: Kaal::rbs_any, ?definition_registry_provider: Kaal::rbs_any) -> void
|
|
10
|
+
|
|
11
|
+
def each: () { (Kaal::rbs_any) -> Kaal::rbs_any } -> Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def yield_registry_entries: () { (Kaal::rbs_any) -> Kaal::rbs_any } -> Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
def resolve_entries: () -> Kaal::rbs_any
|
|
18
|
+
|
|
19
|
+
def build_entry: (Kaal::rbs_any definition) -> (nil | Kaal::rbs_any)
|
|
20
|
+
end
|
|
21
|
+
end
|
data/sig/kaal/core.rbs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Definition
|
|
3
|
+
class DatabaseEngine < Registry
|
|
4
|
+
@database: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
def initialize: (database: Kaal::rbs_any) -> void
|
|
7
|
+
|
|
8
|
+
def upsert_definition: (key: Kaal::rbs_any, cron: Kaal::rbs_any, ?enabled: bool, ?source: ::String, ?metadata: ::Hash[Kaal::rbs_any, Kaal::rbs_any]) -> Kaal::rbs_any
|
|
9
|
+
|
|
10
|
+
def remove_definition: (Kaal::rbs_any key) -> (nil | Kaal::rbs_any)
|
|
11
|
+
|
|
12
|
+
def find_definition: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
13
|
+
|
|
14
|
+
def all_definitions: () -> Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
def enabled_definitions: () -> Kaal::rbs_any
|
|
17
|
+
|
|
18
|
+
def self.normalize_row: (Kaal::rbs_any row) -> (nil | { key: Kaal::rbs_any, cron: Kaal::rbs_any, enabled: Kaal::rbs_any, source: Kaal::rbs_any, metadata: Kaal::rbs_any, created_at: Kaal::rbs_any, updated_at: Kaal::rbs_any, disabled_at: Kaal::rbs_any })
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def dataset: () -> Kaal::rbs_any
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Definition
|
|
3
|
+
class MemoryEngine < Registry
|
|
4
|
+
@definitions: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@mutex: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
include Kaal::Support::HashTools
|
|
9
|
+
|
|
10
|
+
def initialize: () -> void
|
|
11
|
+
|
|
12
|
+
def upsert_definition: (key: Kaal::rbs_any, cron: Kaal::rbs_any, ?enabled: bool, ?source: ::String, ?metadata: ::Hash[Kaal::rbs_any, Kaal::rbs_any]) -> Kaal::rbs_any
|
|
13
|
+
|
|
14
|
+
def remove_definition: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
def find_definition: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
17
|
+
|
|
18
|
+
def all_definitions: () -> Kaal::rbs_any
|
|
19
|
+
|
|
20
|
+
def clear: () -> Kaal::rbs_any
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Definition
|
|
3
|
+
module PersistenceHelpers
|
|
4
|
+
def self.disabled_at_for: (Kaal::rbs_any existing, Kaal::rbs_any enabled, Kaal::rbs_any now) -> (nil | Kaal::rbs_any)
|
|
5
|
+
|
|
6
|
+
def self.parse_metadata: (Kaal::rbs_any value) -> Kaal::rbs_any
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Definition
|
|
3
|
+
class RedisEngine < Registry
|
|
4
|
+
@redis: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@namespace: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
include Kaal::Support::HashTools
|
|
9
|
+
|
|
10
|
+
def initialize: (Kaal::rbs_any redis, ?namespace: ::String) -> void
|
|
11
|
+
|
|
12
|
+
def upsert_definition: (key: Kaal::rbs_any, cron: Kaal::rbs_any, ?enabled: bool, ?source: ::String, ?metadata: ::Hash[Kaal::rbs_any, Kaal::rbs_any]) -> Kaal::rbs_any
|
|
13
|
+
|
|
14
|
+
def remove_definition: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
def find_definition: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
17
|
+
|
|
18
|
+
def all_definitions: () -> Kaal::rbs_any
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def storage_key: () -> ::String
|
|
23
|
+
|
|
24
|
+
def deserialize: (Kaal::rbs_any raw) -> Kaal::rbs_any
|
|
25
|
+
|
|
26
|
+
def self.serialize_payload: (Kaal::rbs_any payload) -> Kaal::rbs_any
|
|
27
|
+
|
|
28
|
+
def self.deserialize_payload: (Kaal::rbs_any raw) -> Kaal::rbs_any
|
|
29
|
+
|
|
30
|
+
def self.parse_time: (Kaal::rbs_any value) -> Kaal::rbs_any
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Definition
|
|
3
|
+
module AttributeHelpers
|
|
4
|
+
def self.definition_attributes: (Kaal::rbs_any definition) -> { key: Kaal::rbs_any, cron: Kaal::rbs_any, source: Kaal::rbs_any, metadata: Kaal::rbs_any }
|
|
5
|
+
|
|
6
|
+
def self.persisted_definition_attributes: (Kaal::rbs_any definition) -> (::Hash[Kaal::rbs_any, Kaal::rbs_any] | { enabled: Kaal::rbs_any, metadata: Kaal::rbs_any })
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class Registry
|
|
10
|
+
def upsert_definition: (**Kaal::rbs_any) -> Kaal::rbs_any
|
|
11
|
+
|
|
12
|
+
def remove_definition: (Kaal::rbs_any _key) -> Kaal::rbs_any
|
|
13
|
+
|
|
14
|
+
def find_definition: (Kaal::rbs_any _key) -> Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
def all_definitions: () -> Kaal::rbs_any
|
|
17
|
+
|
|
18
|
+
def enabled_definitions: () -> Kaal::rbs_any
|
|
19
|
+
|
|
20
|
+
def enable_definition: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
21
|
+
|
|
22
|
+
def disable_definition: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def update_definition_enabled_state: (Kaal::rbs_any key, enabled: Kaal::rbs_any) -> (nil | Kaal::rbs_any)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Definitions
|
|
3
|
+
class RegistrationService
|
|
4
|
+
@configuration: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@definition_registry: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
@registry: Kaal::rbs_any
|
|
9
|
+
|
|
10
|
+
include RegisterConflictSupport
|
|
11
|
+
|
|
12
|
+
attr_reader configuration: Kaal::rbs_any
|
|
13
|
+
|
|
14
|
+
attr_reader definition_registry: Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
attr_reader registry: Kaal::rbs_any
|
|
17
|
+
|
|
18
|
+
def initialize: (configuration: Kaal::rbs_any, definition_registry: Kaal::rbs_any, registry: Kaal::rbs_any) -> void
|
|
19
|
+
|
|
20
|
+
def call: (key: Kaal::rbs_any, cron: Kaal::rbs_any, enqueue: Kaal::rbs_any) -> Kaal::rbs_any
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def rollback_registered_definition: (Kaal::rbs_any key, Kaal::rbs_any existing_definition) -> (Kaal::rbs_any | Kaal::rbs_any | nil)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Definitions
|
|
3
|
+
class RegistryAccessor
|
|
4
|
+
@configuration: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@fallback_registry_provider: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
def initialize: (configuration: Kaal::rbs_any, fallback_registry_provider: Kaal::rbs_any) -> void
|
|
9
|
+
|
|
10
|
+
def call: () -> Kaal::rbs_any
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def fallback_registry: () -> Kaal::rbs_any
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module DelayedJob
|
|
3
|
+
class DatabaseEngine < Registry
|
|
4
|
+
@database: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@use_skip_locked: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
def initialize: (database: Kaal::rbs_any, ?use_skip_locked: bool) -> void
|
|
9
|
+
|
|
10
|
+
def enqueue: (job_id: Kaal::rbs_any, run_at: Kaal::rbs_any, job_class: Kaal::rbs_any, args: Kaal::rbs_any, ?queue: Kaal::rbs_any?, ?connection: Kaal::rbs_any?) -> Kaal::rbs_any
|
|
11
|
+
|
|
12
|
+
def pop_due: (now: Kaal::rbs_any, limit: Kaal::rbs_any) -> Kaal::rbs_any
|
|
13
|
+
|
|
14
|
+
def find_job: (Kaal::rbs_any job_id, ?connection: Kaal::rbs_any) -> Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
def all_jobs: () -> Kaal::rbs_any
|
|
17
|
+
|
|
18
|
+
def claim_strategy: () -> (:skip_locked | :delete_confirmation)
|
|
19
|
+
|
|
20
|
+
def self.normalize_row: (Kaal::rbs_any row) -> Kaal::rbs_any
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def pop_due_with_skip_locked: (now: Kaal::rbs_any, limit: Kaal::rbs_any) -> Kaal::rbs_any
|
|
25
|
+
|
|
26
|
+
def pop_due_with_delete_confirmation: (now: Kaal::rbs_any, limit: Kaal::rbs_any) -> Kaal::rbs_any
|
|
27
|
+
|
|
28
|
+
def self.parse_args: (Kaal::rbs_any args_payload) -> Kaal::rbs_any
|
|
29
|
+
|
|
30
|
+
def dataset_for: (Kaal::rbs_any connection) -> Kaal::rbs_any
|
|
31
|
+
|
|
32
|
+
def dataset: () -> Kaal::rbs_any
|
|
33
|
+
|
|
34
|
+
def connection: () -> Kaal::rbs_any
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module DelayedJob
|
|
3
|
+
class MemoryEngine < Registry
|
|
4
|
+
@jobs: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@mutex: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
include Kaal::Support::HashTools
|
|
9
|
+
|
|
10
|
+
def initialize: () -> void
|
|
11
|
+
|
|
12
|
+
def enqueue: (job_id: Kaal::rbs_any, run_at: Kaal::rbs_any, job_class: Kaal::rbs_any, args: Kaal::rbs_any, ?queue: Kaal::rbs_any?, **Kaal::rbs_any) -> Kaal::rbs_any
|
|
13
|
+
|
|
14
|
+
def pop_due: (now: Kaal::rbs_any, limit: Kaal::rbs_any) -> Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
def find_job: (Kaal::rbs_any job_id) -> Kaal::rbs_any
|
|
17
|
+
|
|
18
|
+
def all_jobs: () -> Kaal::rbs_any
|
|
19
|
+
|
|
20
|
+
def clear: () -> Kaal::rbs_any
|
|
21
|
+
|
|
22
|
+
def claim_strategy: () -> :atomic_pop
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def build_job: (job_id: Kaal::rbs_any, run_at: Kaal::rbs_any, job_class: Kaal::rbs_any, args: Kaal::rbs_any, queue: Kaal::rbs_any) -> { job_id: Kaal::rbs_any, run_at: Kaal::rbs_any, job_class: Kaal::rbs_any, args: Kaal::rbs_any, queue: Kaal::rbs_any, created_at: Kaal::rbs_any }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module DelayedJob
|
|
3
|
+
module MySQLVersionSupport
|
|
4
|
+
MINIMUM_SKIP_LOCKED_VERSION: 80000
|
|
5
|
+
|
|
6
|
+
def self.skip_locked_supported?: (Kaal::rbs_any version_string) -> Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
def self.version_number: (Kaal::rbs_any version_string) -> (0 | Kaal::rbs_any)
|
|
9
|
+
|
|
10
|
+
def self.version_components: (Kaal::rbs_any version_string) -> ::Array[Kaal::rbs_any]
|
|
11
|
+
|
|
12
|
+
def self.integer_prefix: (Kaal::rbs_any value) -> (nil | Kaal::rbs_any)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module DelayedJob
|
|
3
|
+
class RedisEngine < Registry
|
|
4
|
+
@redis: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@namespace: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
def initialize: (Kaal::rbs_any redis, ?namespace: ::String) -> void
|
|
9
|
+
|
|
10
|
+
def enqueue: (job_id: Kaal::rbs_any, run_at: Kaal::rbs_any, job_class: Kaal::rbs_any, args: Kaal::rbs_any, ?queue: Kaal::rbs_any?, **Kaal::rbs_any) -> Kaal::rbs_any
|
|
11
|
+
|
|
12
|
+
def pop_due: (now: Kaal::rbs_any, limit: Kaal::rbs_any) -> Kaal::rbs_any
|
|
13
|
+
|
|
14
|
+
def find_job: (Kaal::rbs_any job_id) -> Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
def all_jobs: () -> Kaal::rbs_any
|
|
17
|
+
|
|
18
|
+
def claim_strategy: () -> :atomic_pop
|
|
19
|
+
|
|
20
|
+
def self.deserialize: (Kaal::rbs_any raw) -> Kaal::rbs_any
|
|
21
|
+
|
|
22
|
+
def self.parse_time: (Kaal::rbs_any value) -> Kaal::rbs_any
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def payloads_key: () -> ::String
|
|
27
|
+
|
|
28
|
+
def schedule_key: () -> ::String
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module DelayedJob
|
|
3
|
+
class DuplicateJobError < StandardError
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class Registry
|
|
7
|
+
def enqueue: (**Kaal::rbs_any) -> Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
def pop_due: (**Kaal::rbs_any) -> Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
def find_job: (Kaal::rbs_any _job_id) -> Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
def all_jobs: () -> Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
def claim_strategy: () -> Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
def requires_dispatch_lock?: () -> false
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Dispatch
|
|
3
|
+
class DatabaseEngine < Registry
|
|
4
|
+
@database: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@namespace: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
def initialize: (database: Kaal::rbs_any, ?namespace: Kaal::rbs_any?) -> void
|
|
9
|
+
|
|
10
|
+
def log_dispatch: (Kaal::rbs_any key, Kaal::rbs_any fire_time, Kaal::rbs_any node_id, ?::String status) -> Kaal::rbs_any
|
|
11
|
+
|
|
12
|
+
def find_dispatch: (Kaal::rbs_any key, Kaal::rbs_any fire_time) -> Kaal::rbs_any
|
|
13
|
+
|
|
14
|
+
def find_by_key: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
def find_by_node: (Kaal::rbs_any node_id) -> Kaal::rbs_any
|
|
17
|
+
|
|
18
|
+
def find_by_status: (Kaal::rbs_any status) -> Kaal::rbs_any
|
|
19
|
+
|
|
20
|
+
def cleanup: (?recovery_window: ::Integer) -> Kaal::rbs_any
|
|
21
|
+
|
|
22
|
+
def self.normalize_row: (Kaal::rbs_any row, ?namespace: Kaal::rbs_any?) -> (nil | { key: Kaal::rbs_any, fire_time: Kaal::rbs_any, dispatched_at: Kaal::rbs_any, node_id: Kaal::rbs_any, status: Kaal::rbs_any })
|
|
23
|
+
|
|
24
|
+
def self.strip_namespace: (Kaal::rbs_any key, namespace: Kaal::rbs_any) -> Kaal::rbs_any
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def dataset: () -> Kaal::rbs_any
|
|
29
|
+
|
|
30
|
+
def namespaced_key: (Kaal::rbs_any key) -> (Kaal::rbs_any | ::String)
|
|
31
|
+
|
|
32
|
+
def query: (Kaal::rbs_any filters) -> Kaal::rbs_any
|
|
33
|
+
|
|
34
|
+
def query_dataset: (Kaal::rbs_any filters) -> Kaal::rbs_any
|
|
35
|
+
|
|
36
|
+
def cleanup_dataset: () -> Kaal::rbs_any
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|