kaal 0.4.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 +60 -25
- data/config/kaal.yml +12 -0
- data/lib/kaal/active_record_support.rb +2 -2
- data/lib/kaal/backend/adapter.rb +8 -0
- data/lib/kaal/backend/memory_adapter.rb +5 -0
- data/lib/kaal/backend/mysql.rb +25 -3
- data/lib/kaal/backend/postgres.rb +6 -2
- data/lib/kaal/backend/redis_adapter.rb +5 -0
- data/lib/kaal/backend/sqlite.rb +4 -0
- data/lib/kaal/cli.rb +38 -33
- data/lib/kaal/config/backend_factory.rb +178 -0
- data/lib/kaal/config/configuration.rb +98 -9
- data/lib/kaal/config/delayed_job_security_policy.rb +60 -0
- data/lib/kaal/config/file_loader.rb +187 -0
- data/lib/kaal/config.rb +3 -0
- data/lib/kaal/core/coordinator.rb +68 -19
- data/lib/kaal/delayed_job/database_engine.rb +116 -0
- data/lib/kaal/delayed_job/dispatch_failure_logger.rb +31 -0
- data/lib/kaal/delayed_job/memory_engine.rb +79 -0
- data/lib/kaal/delayed_job/mysql_version_support.rb +43 -0
- data/lib/kaal/delayed_job/redis_engine.rb +119 -0
- data/lib/kaal/delayed_job/registry.rb +39 -0
- data/lib/kaal/internal/active_record/database_backend.rb +5 -0
- data/lib/kaal/internal/active_record/delayed_job_record.rb +16 -0
- data/lib/kaal/internal/active_record/delayed_job_registry.rb +119 -0
- data/lib/kaal/internal/active_record/migration_templates.rb +33 -3
- data/lib/kaal/internal/active_record/mysql_backend.rb +23 -5
- data/lib/kaal/internal/active_record/postgres_backend.rb +4 -0
- data/lib/kaal/internal/active_record.rb +2 -0
- data/lib/kaal/internal/sequel/database_backend.rb +5 -0
- data/lib/kaal/internal/sequel/mysql_backend.rb +15 -1
- data/lib/kaal/internal/sequel/postgres_backend.rb +4 -0
- data/lib/kaal/internal/sequel.rb +1 -0
- data/lib/kaal/job_dispatcher.rb +108 -0
- data/lib/kaal/persistence/database.rb +4 -0
- data/lib/kaal/persistence/migration_templates.rb +35 -3
- data/lib/kaal/runtime/scheduler_boot_loader.rb +3 -1
- data/lib/kaal/scheduler_file/job_applier.rb +28 -53
- data/lib/kaal/scheduler_file/loader.rb +1 -1
- data/lib/kaal/sequel_support.rb +2 -2
- data/lib/kaal/version.rb +1 -1
- data/lib/kaal.rb +118 -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 +100 -3
- data/config/kaal.rb +0 -15
- /data/config/{scheduler.yml → kaal-scheduler.yml} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Internal
|
|
3
|
+
module Sequel
|
|
4
|
+
class DatabaseBackend < Kaal::Backend::Adapter
|
|
5
|
+
@database: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@namespace: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
@dispatch_registry: Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
@definition_registry: Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
@delayed_store: Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
include Kaal::Backend::DispatchLogging
|
|
16
|
+
|
|
17
|
+
def initialize: (Kaal::rbs_any database, ?namespace: Kaal::rbs_any?) -> void
|
|
18
|
+
|
|
19
|
+
def dispatch_registry: () -> Kaal::rbs_any
|
|
20
|
+
|
|
21
|
+
def definition_registry: () -> Kaal::rbs_any
|
|
22
|
+
|
|
23
|
+
def delayed_store: () -> Kaal::rbs_any
|
|
24
|
+
|
|
25
|
+
def acquire: (Kaal::rbs_any key, Kaal::rbs_any ttl) -> Kaal::rbs_any
|
|
26
|
+
|
|
27
|
+
def release: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
28
|
+
|
|
29
|
+
def cleanup_expired_locks: () -> Kaal::rbs_any
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def dataset: () -> Kaal::rbs_any
|
|
34
|
+
|
|
35
|
+
def resolved_namespace: () -> Kaal::rbs_any
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Internal
|
|
3
|
+
module Sequel
|
|
4
|
+
class MySQLBackend < Kaal::Backend::Adapter
|
|
5
|
+
@database: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@namespace: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
@use_skip_locked: Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
@dispatch_registry: Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
@definition_registry: Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
@delayed_store: Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
include Kaal::Backend::DispatchLogging
|
|
18
|
+
|
|
19
|
+
MAX_LOCK_NAME_LENGTH: 64
|
|
20
|
+
|
|
21
|
+
UNSET_SKIP_LOCKED_SUPPORT: Kaal::rbs_any
|
|
22
|
+
|
|
23
|
+
def initialize: (Kaal::rbs_any database, ?namespace: Kaal::rbs_any?, ?use_skip_locked: Kaal::rbs_any) -> void
|
|
24
|
+
|
|
25
|
+
def dispatch_registry: () -> Kaal::rbs_any
|
|
26
|
+
|
|
27
|
+
def definition_registry: () -> Kaal::rbs_any
|
|
28
|
+
|
|
29
|
+
def delayed_store: () -> Kaal::rbs_any
|
|
30
|
+
|
|
31
|
+
def acquire: (Kaal::rbs_any key, Kaal::rbs_any _ttl) -> Kaal::rbs_any
|
|
32
|
+
|
|
33
|
+
def release: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
34
|
+
|
|
35
|
+
def self.normalize_lock_name: (Kaal::rbs_any key) -> (Kaal::rbs_any | ::String)
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def scalar: (Kaal::rbs_any sql, *Kaal::rbs_any binds) -> Kaal::rbs_any
|
|
40
|
+
|
|
41
|
+
def resolved_namespace: () -> Kaal::rbs_any
|
|
42
|
+
|
|
43
|
+
def supports_skip_locked?: () -> Kaal::rbs_any
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Internal
|
|
3
|
+
module Sequel
|
|
4
|
+
class PostgresBackend < Kaal::Backend::Adapter
|
|
5
|
+
@database: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@namespace: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
@dispatch_registry: Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
@definition_registry: Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
@delayed_store: Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
include Kaal::Backend::DispatchLogging
|
|
16
|
+
|
|
17
|
+
SIGNED_64_MAX: 9223372036854775807
|
|
18
|
+
|
|
19
|
+
UNSIGNED_64_RANGE: 18446744073709551616
|
|
20
|
+
|
|
21
|
+
def initialize: (Kaal::rbs_any database, ?namespace: Kaal::rbs_any?) -> void
|
|
22
|
+
|
|
23
|
+
def dispatch_registry: () -> Kaal::rbs_any
|
|
24
|
+
|
|
25
|
+
def definition_registry: () -> Kaal::rbs_any
|
|
26
|
+
|
|
27
|
+
def delayed_store: () -> Kaal::rbs_any
|
|
28
|
+
|
|
29
|
+
def acquire: (Kaal::rbs_any key, Kaal::rbs_any _ttl) -> Kaal::rbs_any
|
|
30
|
+
|
|
31
|
+
def release: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
32
|
+
|
|
33
|
+
def self.calculate_lock_id: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def scalar: (Kaal::rbs_any sql, *Kaal::rbs_any binds) -> Kaal::rbs_any
|
|
38
|
+
|
|
39
|
+
def resolved_namespace: () -> Kaal::rbs_any
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module JobDispatcher
|
|
3
|
+
def self.resolve_job_class: (job_class_name: Kaal::rbs_any, key: Kaal::rbs_any, ?queue: Kaal::rbs_any?, ?apply_delayed_job_allow_list: bool) -> Kaal::rbs_any
|
|
4
|
+
|
|
5
|
+
def self.normalized_job_class_name: (job_class_name: Kaal::rbs_any, key: Kaal::rbs_any, ?apply_delayed_job_allow_list: bool) -> Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
def self.dispatch: (job_class: Kaal::rbs_any, queue: Kaal::rbs_any, args: Kaal::rbs_any, ?key: Kaal::rbs_any?) -> Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
def self.active_job_dispatch?: (Kaal::rbs_any job_class, Kaal::rbs_any queue) -> Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
def self.normalize_job_class_name: (Kaal::rbs_any job_class) -> Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
def self.normalize_job_class: (Kaal::rbs_any job_class_name, Kaal::rbs_any key, ?apply_delayed_job_allow_list: bool) -> Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
def self.validate_allowed_job_class_name!: (job_class_name: Kaal::rbs_any, key: Kaal::rbs_any) -> (nil | Kaal::rbs_any)
|
|
16
|
+
|
|
17
|
+
def self.validate_dispatch_interface: (Kaal::rbs_any job_class, Kaal::rbs_any key, Kaal::rbs_any queue) -> Kaal::rbs_any
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Persistence
|
|
3
|
+
class Database
|
|
4
|
+
@connection: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
attr_reader connection: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
def initialize: (Kaal::rbs_any connection) -> void
|
|
9
|
+
|
|
10
|
+
def definitions_dataset: () -> Kaal::rbs_any
|
|
11
|
+
|
|
12
|
+
def dispatches_dataset: () -> Kaal::rbs_any
|
|
13
|
+
|
|
14
|
+
def locks_dataset: () -> Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
def delayed_jobs_dataset: () -> Kaal::rbs_any
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Persistence
|
|
3
|
+
module MigrationTemplates
|
|
4
|
+
def self.for_backend: (Kaal::rbs_any backend) -> Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
def self.dispatches_template: () -> "Sequel.migration do\n change do\n create_table?(:kaal_dispatches) do\n primary_key :id\n String :key, null: false\n Time :fire_time, null: false\n Time :dispatched_at, null: false\n String :node_id, null: false\n String :status, null: false, default: 'dispatched', size: 50\n end\n\n add_index :kaal_dispatches, [:key, :fire_time], unique: true\n add_index :kaal_dispatches, :key\n add_index :kaal_dispatches, :node_id\n add_index :kaal_dispatches, :status\n add_index :kaal_dispatches, :fire_time\n end\nend\n"
|
|
7
|
+
|
|
8
|
+
def self.locks_template: () -> "Sequel.migration do\n change do\n create_table?(:kaal_locks) do\n primary_key :id\n String :key, null: false\n Time :acquired_at, null: false\n Time :expires_at, null: false\n end\n\n add_index :kaal_locks, :key, unique: true\n add_index :kaal_locks, :expires_at\n end\nend\n"
|
|
9
|
+
|
|
10
|
+
def self.definitions_template: () -> "Sequel.migration do\n change do\n create_table?(:kaal_definitions) do\n primary_key :id\n String :key, null: false\n String :cron, null: false\n TrueClass :enabled, null: false, default: true\n String :source, null: false\n String :metadata, text: true, null: false, default: '{}'\n Time :disabled_at\n Time :created_at, null: false\n Time :updated_at, null: false\n end\n\n add_index :kaal_definitions, :key, unique: true\n add_index :kaal_definitions, :enabled\n add_index :kaal_definitions, :source\n end\nend\n"
|
|
11
|
+
|
|
12
|
+
def self.delayed_jobs_template: (Kaal::rbs_any backend) -> ::String
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module RegisterConflictSupport
|
|
3
|
+
private
|
|
4
|
+
|
|
5
|
+
def resolve_register_conflict: (key: Kaal::rbs_any, cron: Kaal::rbs_any, enqueue: Kaal::rbs_any, existing_definition: Kaal::rbs_any, existing_entry: Kaal::rbs_any) -> (nil | Kaal::rbs_any)
|
|
6
|
+
|
|
7
|
+
def replace_file_registered_definition: (key: Kaal::rbs_any, cron: Kaal::rbs_any, enqueue: Kaal::rbs_any, existing_definition: Kaal::rbs_any) -> Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
def with_registered_definition_rollback: (Kaal::rbs_any key, Kaal::rbs_any existing_definition) { () -> Kaal::rbs_any } -> Kaal::rbs_any
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class Registry
|
|
3
|
+
@entries: Kaal::rbs_any
|
|
4
|
+
|
|
5
|
+
@mutex: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
include Enumerable[Kaal::rbs_any]
|
|
8
|
+
|
|
9
|
+
Entry: Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
def initialize: () -> void
|
|
12
|
+
|
|
13
|
+
def add: (key: Kaal::rbs_any, cron: Kaal::rbs_any, enqueue: Kaal::rbs_any) -> Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
def upsert: (key: Kaal::rbs_any, cron: Kaal::rbs_any, enqueue: Kaal::rbs_any) -> Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
def remove: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
18
|
+
|
|
19
|
+
def find: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
20
|
+
|
|
21
|
+
def all: () -> Kaal::rbs_any
|
|
22
|
+
|
|
23
|
+
def size: () -> Kaal::rbs_any
|
|
24
|
+
|
|
25
|
+
alias count size
|
|
26
|
+
|
|
27
|
+
def registered?: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
28
|
+
|
|
29
|
+
def clear: () -> Kaal::rbs_any
|
|
30
|
+
|
|
31
|
+
def each: () ?{ (Kaal::rbs_any) -> void } -> Kaal::rbs_any
|
|
32
|
+
|
|
33
|
+
def to_a: () -> Kaal::rbs_any
|
|
34
|
+
|
|
35
|
+
def inspect: () -> Kaal::rbs_any
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def validate_entry: (Kaal::rbs_any key, Kaal::rbs_any cron, Kaal::rbs_any enqueue) -> Kaal::rbs_any
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class RegistryError < StandardError
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class RuntimeContext
|
|
3
|
+
@root_path: Kaal::rbs_any
|
|
4
|
+
|
|
5
|
+
@environment_name: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
DEFAULT_ENVIRONMENT_NAME: "development"
|
|
8
|
+
|
|
9
|
+
ENVIRONMENT_KEYS: ::Array["KAAL_ENV" | "RAILS_ENV" | "APP_ENV" | "RACK_ENV"]
|
|
10
|
+
|
|
11
|
+
attr_reader environment_name: Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
attr_reader root_path: Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
def self.default: (?env: Kaal::rbs_any, ?root_path: Kaal::rbs_any) -> Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
def self.environment_name_from: (Kaal::rbs_any env) -> Kaal::rbs_any
|
|
18
|
+
|
|
19
|
+
def initialize: (root_path: Kaal::rbs_any, environment_name: Kaal::rbs_any) -> void
|
|
20
|
+
|
|
21
|
+
def resolve_path: (Kaal::rbs_any path) -> Kaal::rbs_any
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class SchedulerBootLoader
|
|
3
|
+
@configuration_provider: Kaal::rbs_any
|
|
4
|
+
|
|
5
|
+
@logger: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@runtime_context: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
@load_scheduler_file: Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
def initialize: (configuration_provider: Kaal::rbs_any, logger: Kaal::rbs_any, runtime_context: Kaal::rbs_any, load_scheduler_file: Kaal::rbs_any) -> void
|
|
12
|
+
|
|
13
|
+
def load_on_boot: () -> Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
def load_on_boot!: () -> (nil | Kaal::rbs_any)
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def load_scheduler_file: () -> Kaal::rbs_any
|
|
20
|
+
|
|
21
|
+
def fetch_configuration: () -> Kaal::rbs_any
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class SignalHandlerChain
|
|
3
|
+
@signal: Kaal::rbs_any
|
|
4
|
+
|
|
5
|
+
@previous_handler: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@logger: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
RESERVED_COMMAND_HANDLERS: ::Array["DEFAULT" | "IGNORE"]
|
|
10
|
+
|
|
11
|
+
def initialize: (signal: Kaal::rbs_any, previous_handler: Kaal::rbs_any, logger: Kaal::rbs_any) -> void
|
|
12
|
+
|
|
13
|
+
def call: (*Kaal::rbs_any, **Kaal::rbs_any) ?{ (Kaal::rbs_any) -> Kaal::rbs_any } -> (nil | Kaal::rbs_any)
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def invoke_callable: (*Kaal::rbs_any args) -> Kaal::rbs_any
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class SignalHandlerInstaller
|
|
3
|
+
@signal_module: Kaal::rbs_any
|
|
4
|
+
|
|
5
|
+
SIGNALS: ::Array["TERM" | "INT"]
|
|
6
|
+
|
|
7
|
+
IGNORE_HANDLER: "IGNORE"
|
|
8
|
+
|
|
9
|
+
def initialize: (?signal_module: Kaal::rbs_any) -> void
|
|
10
|
+
|
|
11
|
+
def install: (?signals: Kaal::rbs_any) { (Kaal::rbs_any, Kaal::rbs_any) -> Kaal::rbs_any } -> Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def capture_previous_handler: (Kaal::rbs_any signal) -> Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
def restore_previous_handler: (Kaal::rbs_any signal, Kaal::rbs_any previous_handler) -> (nil | Kaal::rbs_any)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class SchedulerFileLoader
|
|
3
|
+
class HelperBundle
|
|
4
|
+
@loader: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
def initialize: (loader: Kaal::rbs_any) -> void
|
|
7
|
+
|
|
8
|
+
def stringify_keys: (Kaal::rbs_any payload) -> Kaal::rbs_any
|
|
9
|
+
|
|
10
|
+
def resolve_placeholders: (Kaal::rbs_any value, Kaal::rbs_any context) -> Kaal::rbs_any
|
|
11
|
+
|
|
12
|
+
def validate_placeholders: (Kaal::rbs_any value, key: Kaal::rbs_any) -> Kaal::rbs_any
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class SchedulerFileLoader
|
|
3
|
+
class JobApplier
|
|
4
|
+
@configuration: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@definition_registry: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
@registry: Kaal::rbs_any
|
|
9
|
+
|
|
10
|
+
@logger: Kaal::rbs_any
|
|
11
|
+
|
|
12
|
+
@helper_bundle: Kaal::rbs_any
|
|
13
|
+
|
|
14
|
+
include Kaal::Support::HashTools
|
|
15
|
+
|
|
16
|
+
def initialize: (configuration: Kaal::rbs_any, definition_registry: Kaal::rbs_any, registry: Kaal::rbs_any, logger: Kaal::rbs_any, helper_bundle: Kaal::rbs_any) -> void
|
|
17
|
+
|
|
18
|
+
def apply: (Kaal::rbs_any job) -> (nil | { key: Kaal::rbs_any, existing_definition: Kaal::rbs_any, existing_registry_entry: Kaal::rbs_any })
|
|
19
|
+
|
|
20
|
+
def rollback_jobs: (Kaal::rbs_any applied_job_contexts) -> Kaal::rbs_any
|
|
21
|
+
|
|
22
|
+
def callback_for: (key: Kaal::rbs_any, job_class_name: Kaal::rbs_any, queue: Kaal::rbs_any, args_template: Kaal::rbs_any, kwargs_template: Kaal::rbs_any) -> Kaal::rbs_any
|
|
23
|
+
|
|
24
|
+
def resolved_job_class: (job_class_name: Kaal::rbs_any, key: Kaal::rbs_any, ?queue: Kaal::rbs_any?) -> Kaal::rbs_any
|
|
25
|
+
|
|
26
|
+
def conflict?: (key: Kaal::rbs_any, existing_definition: Kaal::rbs_any) -> (false | Kaal::rbs_any)
|
|
27
|
+
|
|
28
|
+
def rollback_job: (key: Kaal::rbs_any, existing_definition: Kaal::rbs_any, existing_registry_entry: Kaal::rbs_any) -> Kaal::rbs_any
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def persisted_metadata: (Kaal::rbs_any job, Kaal::rbs_any job_class) -> Kaal::rbs_any
|
|
33
|
+
|
|
34
|
+
def build_callback: (Kaal::rbs_any job, Kaal::rbs_any job_class) -> Kaal::rbs_any
|
|
35
|
+
|
|
36
|
+
def validate_keyword_keys: (Kaal::rbs_any raw_kwargs, Kaal::rbs_any key) -> nil
|
|
37
|
+
|
|
38
|
+
def dispatch_job: (Kaal::rbs_any job_class, Kaal::rbs_any queue, Kaal::rbs_any args, Kaal::rbs_any kwargs, Kaal::rbs_any key) -> Kaal::rbs_any
|
|
39
|
+
|
|
40
|
+
def active_job_dispatch?: (Kaal::rbs_any job_class, Kaal::rbs_any queue) -> Kaal::rbs_any
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class SchedulerFileLoader
|
|
3
|
+
class JobNormalizer
|
|
4
|
+
@hash_transform: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@placeholder_support: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
@cron_validator: Kaal::rbs_any
|
|
9
|
+
|
|
10
|
+
include Kaal::Support::HashTools
|
|
11
|
+
|
|
12
|
+
def initialize: (hash_transform: Kaal::rbs_any, placeholder_support: Kaal::rbs_any, cron_validator: Kaal::rbs_any) -> void
|
|
13
|
+
|
|
14
|
+
def call: (Kaal::rbs_any job_payload) -> ::Hash[:key | :cron | :job_class_name | Kaal::rbs_any, Kaal::rbs_any]
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def required_string: (Kaal::rbs_any payload, field: Kaal::rbs_any, error_prefix: Kaal::rbs_any) -> Kaal::rbs_any
|
|
19
|
+
|
|
20
|
+
def validate_cron: (key: Kaal::rbs_any, cron: Kaal::rbs_any) -> (nil | Kaal::rbs_any)
|
|
21
|
+
|
|
22
|
+
def extract_job_options: (Kaal::rbs_any payload, key: Kaal::rbs_any) -> { queue: Kaal::rbs_any, args: Kaal::rbs_any, kwargs: Kaal::rbs_any, enabled: Kaal::rbs_any, metadata: Kaal::rbs_any }
|
|
23
|
+
|
|
24
|
+
def validate_job_option_types: (key: Kaal::rbs_any, args: Kaal::rbs_any, kwargs: Kaal::rbs_any, queue: Kaal::rbs_any) -> (nil | Kaal::rbs_any)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class SchedulerFileLoader
|
|
3
|
+
@configuration: Kaal::rbs_any
|
|
4
|
+
|
|
5
|
+
@definition_registry: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@registry: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
@logger: Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
@runtime_context: Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
@placeholder_resolvers: Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
@payload_loader: Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
@job_normalizer: Kaal::rbs_any
|
|
18
|
+
|
|
19
|
+
@job_applier: Kaal::rbs_any
|
|
20
|
+
|
|
21
|
+
@helper_bundle: Kaal::rbs_any
|
|
22
|
+
|
|
23
|
+
include SchedulerHashTransform
|
|
24
|
+
|
|
25
|
+
include SchedulerPlaceholderSupport
|
|
26
|
+
|
|
27
|
+
include Kaal::Support::HashTools
|
|
28
|
+
|
|
29
|
+
PLACEHOLDER_PATTERN: ::Regexp
|
|
30
|
+
|
|
31
|
+
ALLOWED_PLACEHOLDERS: ::Hash[::String, Kaal::rbs_any]
|
|
32
|
+
|
|
33
|
+
def initialize: (configuration: Kaal::rbs_any, definition_registry: Kaal::rbs_any, registry: Kaal::rbs_any, logger: Kaal::rbs_any, ?runtime_context: Kaal::rbs_any) -> void
|
|
34
|
+
|
|
35
|
+
def load: () -> Kaal::rbs_any
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def handle_missing_file: (Kaal::rbs_any path) -> Kaal::rbs_any
|
|
40
|
+
|
|
41
|
+
def extract_jobs: (Kaal::rbs_any payload) -> Kaal::rbs_any
|
|
42
|
+
|
|
43
|
+
def validate_unique_keys: (Kaal::rbs_any jobs) -> Kaal::rbs_any
|
|
44
|
+
|
|
45
|
+
def normalize_job: (Kaal::rbs_any job_payload) -> Kaal::rbs_any
|
|
46
|
+
|
|
47
|
+
def extract_job_options: (Kaal::rbs_any payload, key: Kaal::rbs_any) -> Kaal::rbs_any
|
|
48
|
+
|
|
49
|
+
def apply_job: (Kaal::rbs_any job) -> Kaal::rbs_any
|
|
50
|
+
|
|
51
|
+
def rollback_applied_jobs: (?Kaal::rbs_any applied_job_contexts) -> Kaal::rbs_any
|
|
52
|
+
|
|
53
|
+
def rollback_applied_job: (key: Kaal::rbs_any, existing_definition: Kaal::rbs_any, existing_registry_entry: Kaal::rbs_any) -> Kaal::rbs_any
|
|
54
|
+
|
|
55
|
+
def skip_due_to_conflict?: (key: Kaal::rbs_any, existing_definition: Kaal::rbs_any) -> Kaal::rbs_any
|
|
56
|
+
|
|
57
|
+
def build_callback: (key: Kaal::rbs_any, job_class_name: Kaal::rbs_any, queue: Kaal::rbs_any, args_template: Kaal::rbs_any, kwargs_template: Kaal::rbs_any) -> Kaal::rbs_any
|
|
58
|
+
|
|
59
|
+
def resolve_job_class: (job_class_name: Kaal::rbs_any, key: Kaal::rbs_any, ?queue: Kaal::rbs_any?) -> Kaal::rbs_any
|
|
60
|
+
|
|
61
|
+
def payload_loader: () -> Kaal::rbs_any
|
|
62
|
+
|
|
63
|
+
def job_normalizer: () -> Kaal::rbs_any
|
|
64
|
+
|
|
65
|
+
def job_applier: () -> Kaal::rbs_any
|
|
66
|
+
|
|
67
|
+
def helper_bundle: () -> Kaal::rbs_any
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
class SchedulerFileLoader
|
|
3
|
+
class PayloadLoader
|
|
4
|
+
@configuration: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@runtime_context: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
@logger: Kaal::rbs_any
|
|
9
|
+
|
|
10
|
+
@hash_transform: Kaal::rbs_any
|
|
11
|
+
|
|
12
|
+
def initialize: (configuration: Kaal::rbs_any, runtime_context: Kaal::rbs_any, logger: Kaal::rbs_any, hash_transform: Kaal::rbs_any) -> void
|
|
13
|
+
|
|
14
|
+
def load: () -> (::Array[Kaal::rbs_any | nil] | ::Array[Kaal::rbs_any])
|
|
15
|
+
|
|
16
|
+
def handle_missing_file: (Kaal::rbs_any path) -> ::Array[Kaal::rbs_any]
|
|
17
|
+
|
|
18
|
+
def extract_jobs: (Kaal::rbs_any payload) -> Kaal::rbs_any
|
|
19
|
+
|
|
20
|
+
def validate_unique_keys: (Kaal::rbs_any jobs) -> (nil | Kaal::rbs_any)
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def scheduler_file_path: () -> Kaal::rbs_any
|
|
25
|
+
|
|
26
|
+
def parse_yaml: (Kaal::rbs_any path) -> Kaal::rbs_any
|
|
27
|
+
|
|
28
|
+
def render_yaml_erb: (Kaal::rbs_any path) -> Kaal::rbs_any
|
|
29
|
+
|
|
30
|
+
def fetch_hash: (Kaal::rbs_any payload, Kaal::rbs_any key) -> Kaal::rbs_any
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module SchedulerPlaceholderSupport
|
|
3
|
+
@placeholder_token_anchors: Kaal::rbs_any
|
|
4
|
+
|
|
5
|
+
private
|
|
6
|
+
|
|
7
|
+
def validate_placeholders: (Kaal::rbs_any input, key: Kaal::rbs_any) -> Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
def resolve_placeholders: (Kaal::rbs_any template, Kaal::rbs_any context) -> Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
def replace_placeholders: (Kaal::rbs_any text, Kaal::rbs_any context) -> Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
def validate_placeholder_key: (Kaal::rbs_any hash_key, key: Kaal::rbs_any) -> (nil | Kaal::rbs_any)
|
|
14
|
+
|
|
15
|
+
def validate_placeholder_syntax: (Kaal::rbs_any input, key: Kaal::rbs_any) -> Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
def placeholder_token_anchors: () -> Kaal::rbs_any
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Sequel
|
|
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?) -> Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
def self.require_sequel!: () -> 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.default_migration_name_for: (Kaal::rbs_any backend) -> ::String
|
|
16
|
+
|
|
17
|
+
def self.migration_suffixes_for: (Kaal::rbs_any backend) -> (::Array["dispatches" | "locks" | "definitions" | "delayed_jobs"] | ::Array["dispatches" | "definitions" | "delayed_jobs"])
|
|
18
|
+
|
|
19
|
+
def self.timestamp: (?::Integer offset) -> Kaal::rbs_any
|
|
20
|
+
|
|
21
|
+
def self.letter?: (Kaal::rbs_any char) -> Kaal::rbs_any
|
|
22
|
+
|
|
23
|
+
def self.digit?: (Kaal::rbs_any char) -> Kaal::rbs_any
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Support
|
|
3
|
+
module HashTools
|
|
4
|
+
def self.deep_dup: (Kaal::rbs_any value) -> Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
def self.stringify_keys: (Kaal::rbs_any value) -> Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
def self.symbolize_keys: (Kaal::rbs_any value) -> Kaal::rbs_any
|
|
9
|
+
|
|
10
|
+
def self.deep_merge: (Kaal::rbs_any left, Kaal::rbs_any right) -> Kaal::rbs_any
|
|
11
|
+
|
|
12
|
+
def self.constantize: (Kaal::rbs_any name) -> Kaal::rbs_any
|
|
13
|
+
|
|
14
|
+
def self.duplicable?: (Kaal::rbs_any value) -> Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
def self.transform_keys: (Kaal::rbs_any value) { (Kaal::rbs_any) -> Kaal::rbs_any } -> Kaal::rbs_any
|
|
17
|
+
|
|
18
|
+
def self.duplicate_child: (Kaal::rbs_any child) -> Kaal::rbs_any
|
|
19
|
+
|
|
20
|
+
def self.transform_child_keys: (Kaal::rbs_any child) { (Kaal::rbs_any) -> Kaal::rbs_any } -> Kaal::rbs_any
|
|
21
|
+
|
|
22
|
+
def self.transform_hash_keys: (Kaal::rbs_any value) { (Kaal::rbs_any) -> Kaal::rbs_any } -> Kaal::rbs_any
|
|
23
|
+
|
|
24
|
+
def self.transform_array_keys: (Kaal::rbs_any value) { (Kaal::rbs_any) -> Kaal::rbs_any } -> Kaal::rbs_any
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|