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,23 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Dispatch
|
|
3
|
+
class MemoryEngine < Registry
|
|
4
|
+
@dispatches: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@mutex: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
def initialize: () -> 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 clear: () -> Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
def size: () -> Kaal::rbs_any
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def build_key: (Kaal::rbs_any key, Kaal::rbs_any fire_time) -> ::String
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Dispatch
|
|
3
|
+
class RedisEngine < Registry
|
|
4
|
+
@redis: Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
@namespace: Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
@ttl: Kaal::rbs_any
|
|
9
|
+
|
|
10
|
+
DEFAULT_TTL: Kaal::rbs_any
|
|
11
|
+
|
|
12
|
+
def initialize: (Kaal::rbs_any redis, ?namespace: ::String, ?ttl: Kaal::rbs_any) -> void
|
|
13
|
+
|
|
14
|
+
def log_dispatch: (Kaal::rbs_any key, Kaal::rbs_any fire_time, Kaal::rbs_any node_id, ?::String status) -> Kaal::rbs_any
|
|
15
|
+
|
|
16
|
+
def find_dispatch: (Kaal::rbs_any key, Kaal::rbs_any fire_time) -> (nil | Kaal::rbs_any)
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def build_redis_key: (Kaal::rbs_any key, Kaal::rbs_any fire_time) -> ::String
|
|
21
|
+
|
|
22
|
+
def convert_timestamps: (Kaal::rbs_any record) -> Kaal::rbs_any
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Dispatch
|
|
3
|
+
class Registry
|
|
4
|
+
def log_dispatch: (Kaal::rbs_any _key, Kaal::rbs_any _fire_time, Kaal::rbs_any _node_id, ?::String _status) -> Kaal::rbs_any
|
|
5
|
+
|
|
6
|
+
def find_dispatch: (Kaal::rbs_any _key, Kaal::rbs_any _fire_time) -> Kaal::rbs_any
|
|
7
|
+
|
|
8
|
+
def dispatched?: (Kaal::rbs_any key, Kaal::rbs_any fire_time) -> (true | false)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Internal
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
module ConnectionSupport
|
|
5
|
+
CONFIGURE_MUTEX: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
def self.configure!: (?Kaal::rbs_any? connection) -> Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
def self.normalize_connection_config: (Kaal::rbs_any connection) -> Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
def self.current_connection_config: () -> Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
def self.extract_connection_config: (Kaal::rbs_any connection) -> Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
def self.normalize_connection_value: (Kaal::rbs_any key, Kaal::rbs_any value) -> Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
def self.integer_like?: (Kaal::rbs_any value) -> Kaal::rbs_any
|
|
18
|
+
|
|
19
|
+
def self.configs_match?: (Kaal::rbs_any current_config, Kaal::rbs_any target_config) -> (true | Kaal::rbs_any)
|
|
20
|
+
|
|
21
|
+
def self.connection_active?: () -> Kaal::rbs_any
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Internal
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
class DatabaseBackend < Kaal::Backend::Adapter
|
|
5
|
+
@lock_model: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@dispatch_registry: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
@definition_registry: Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
@namespace: Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
@delayed_store: Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
include Kaal::Backend::DispatchLogging
|
|
16
|
+
|
|
17
|
+
def initialize: (?Kaal::rbs_any? connection, ?lock_model: Kaal::rbs_any, ?dispatch_registry: Kaal::rbs_any?, ?definition_registry: Kaal::rbs_any?, ?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 resolved_namespace: () -> Kaal::rbs_any
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Internal
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
class DefinitionRegistry < Kaal::Definition::Registry
|
|
5
|
+
@model: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
def initialize: (?connection: Kaal::rbs_any?, ?model: Kaal::rbs_any) -> void
|
|
8
|
+
|
|
9
|
+
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
|
|
10
|
+
|
|
11
|
+
def remove_definition: (Kaal::rbs_any key) -> (nil | Kaal::rbs_any)
|
|
12
|
+
|
|
13
|
+
def find_definition: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
def all_definitions: () -> Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
def enabled_definitions: () -> Kaal::rbs_any
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def normalize: (Kaal::rbs_any record) -> (nil | Kaal::rbs_any)
|
|
22
|
+
|
|
23
|
+
def normalize_definition_record: (Kaal::rbs_any record) -> { 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 }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Internal
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
class DelayedJobRegistry < Kaal::DelayedJob::Registry
|
|
5
|
+
@model: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@use_skip_locked: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
def initialize: (?connection: Kaal::rbs_any?, ?model: Kaal::rbs_any, ?use_skip_locked: bool) -> void
|
|
10
|
+
|
|
11
|
+
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
|
|
12
|
+
|
|
13
|
+
def pop_due: (now: Kaal::rbs_any, limit: Kaal::rbs_any) -> Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def pop_due_with_skip_locked: (now: Kaal::rbs_any, limit: Kaal::rbs_any) -> Kaal::rbs_any
|
|
18
|
+
|
|
19
|
+
def pop_due_with_delete_confirmation: (now: Kaal::rbs_any, limit: Kaal::rbs_any) -> Kaal::rbs_any
|
|
20
|
+
|
|
21
|
+
public
|
|
22
|
+
|
|
23
|
+
def find_job: (Kaal::rbs_any job_id) -> Kaal::rbs_any
|
|
24
|
+
|
|
25
|
+
def all_jobs: () -> Kaal::rbs_any
|
|
26
|
+
|
|
27
|
+
def claim_strategy: () -> (:skip_locked | :delete_confirmation)
|
|
28
|
+
|
|
29
|
+
def self.normalize: (Kaal::rbs_any record) -> Kaal::rbs_any
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def insert_with_connection: (Kaal::rbs_any connection, Kaal::rbs_any attributes) -> Kaal::rbs_any
|
|
34
|
+
|
|
35
|
+
def self.parse_args: (Kaal::rbs_any args_payload) -> Kaal::rbs_any
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Internal
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
class DispatchRegistry < Kaal::Dispatch::Registry
|
|
5
|
+
@model: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@namespace: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
def initialize: (?connection: Kaal::rbs_any?, ?model: Kaal::rbs_any, ?namespace: Kaal::rbs_any?) -> void
|
|
10
|
+
|
|
11
|
+
def log_dispatch: (Kaal::rbs_any key, Kaal::rbs_any fire_time, Kaal::rbs_any node_id, ?::String status) -> Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
def find_dispatch: (Kaal::rbs_any key, Kaal::rbs_any fire_time) -> Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
def find_by_key: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
def find_by_node: (Kaal::rbs_any node_id) -> Kaal::rbs_any
|
|
18
|
+
|
|
19
|
+
def find_by_status: (Kaal::rbs_any status) -> Kaal::rbs_any
|
|
20
|
+
|
|
21
|
+
def cleanup: (?recovery_window: ::Integer) -> Kaal::rbs_any
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def query: (Kaal::rbs_any filters) -> Kaal::rbs_any
|
|
26
|
+
|
|
27
|
+
def namespaced_key: (Kaal::rbs_any key) -> ::String
|
|
28
|
+
|
|
29
|
+
def normalize: (Kaal::rbs_any record) -> (nil | { key: Kaal::rbs_any, fire_time: Kaal::rbs_any, dispatched_at: Kaal::rbs_any, node_id: Kaal::rbs_any, status: Kaal::rbs_any })
|
|
30
|
+
|
|
31
|
+
def strip_namespace: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
32
|
+
|
|
33
|
+
def query_scope: (Kaal::rbs_any filters) -> Kaal::rbs_any
|
|
34
|
+
|
|
35
|
+
def cleanup_scope: () -> Kaal::rbs_any
|
|
36
|
+
|
|
37
|
+
def namespace_scope: (Kaal::rbs_any relation) -> Kaal::rbs_any
|
|
38
|
+
|
|
39
|
+
def namespace_prefix: () -> ("" | ::String)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Internal
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
module MigrationTemplates
|
|
5
|
+
def self.for_backend: (Kaal::rbs_any backend) -> Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
def self.dispatches_template: () -> "class CreateKaalDispatches < ActiveRecord::Migration[7.1]\n def change\n create_table :kaal_dispatches do |t|\n t.string :key, null: false\n t.datetime :fire_time, null: false\n t.datetime :dispatched_at, null: false\n t.string :node_id, null: false\n t.string :status, null: false, default: 'dispatched', limit: 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"
|
|
8
|
+
|
|
9
|
+
def self.locks_template: () -> "class CreateKaalLocks < ActiveRecord::Migration[7.1]\n def change\n create_table :kaal_locks do |t|\n t.string :key, null: false\n t.datetime :acquired_at, null: false\n t.datetime :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"
|
|
10
|
+
|
|
11
|
+
def self.definitions_template: (Kaal::rbs_any backend) -> ::String
|
|
12
|
+
|
|
13
|
+
def self.delayed_jobs_template: (Kaal::rbs_any backend) -> ::String
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Internal
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
class MySQLBackend < Kaal::Backend::Adapter
|
|
5
|
+
@dispatch_registry: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@definition_registry: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
@namespace: Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
@use_skip_locked: Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
@delayed_store: Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
include Kaal::Backend::DispatchLogging
|
|
16
|
+
|
|
17
|
+
MAX_LOCK_NAME_LENGTH: 64
|
|
18
|
+
|
|
19
|
+
UNSET_SKIP_LOCKED_SUPPORT: Kaal::rbs_any
|
|
20
|
+
|
|
21
|
+
def initialize: (?Kaal::rbs_any? connection, ?dispatch_registry: Kaal::rbs_any?, ?definition_registry: Kaal::rbs_any?, ?namespace: Kaal::rbs_any?, ?use_skip_locked: 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.normalize_lock_name: (Kaal::rbs_any key) -> (Kaal::rbs_any | ::String)
|
|
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
|
+
|
|
41
|
+
def supports_skip_locked?: () -> Kaal::rbs_any
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Internal
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
class PostgresBackend < Kaal::Backend::Adapter
|
|
5
|
+
@dispatch_registry: Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
@definition_registry: Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
@namespace: Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
@delayed_store: Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
include Kaal::Backend::DispatchLogging
|
|
14
|
+
|
|
15
|
+
SIGNED_64_MAX: 9223372036854775807
|
|
16
|
+
|
|
17
|
+
UNSIGNED_64_RANGE: 18446744073709551616
|
|
18
|
+
|
|
19
|
+
def initialize: (?Kaal::rbs_any? connection, ?dispatch_registry: Kaal::rbs_any?, ?definition_registry: Kaal::rbs_any?, ?namespace: Kaal::rbs_any?) -> void
|
|
20
|
+
|
|
21
|
+
def dispatch_registry: () -> Kaal::rbs_any
|
|
22
|
+
|
|
23
|
+
def definition_registry: () -> Kaal::rbs_any
|
|
24
|
+
|
|
25
|
+
def delayed_store: () -> Kaal::rbs_any
|
|
26
|
+
|
|
27
|
+
def acquire: (Kaal::rbs_any key, Kaal::rbs_any _ttl) -> Kaal::rbs_any
|
|
28
|
+
|
|
29
|
+
def release: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
30
|
+
|
|
31
|
+
def self.calculate_lock_id: (Kaal::rbs_any key) -> Kaal::rbs_any
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def scalar: (Kaal::rbs_any sql, Kaal::rbs_any value) -> Kaal::rbs_any
|
|
36
|
+
|
|
37
|
+
def resolved_namespace: () -> Kaal::rbs_any
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
File without changes
|
|
@@ -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
|