kaal-roda 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 +10 -10
- data/lib/kaal/roda/version.rb +1 -1
- data/lib/kaal/roda.rb +19 -6
- data/sig/00_types.rbs +12 -0
- data/sig/dependencies.rbs +54 -0
- data/sig/kaal/roda/version.rbs +5 -0
- data/sig/kaal/roda.rbs +39 -0
- data/sig/roda/plugins/kaal.rbs +9 -0
- metadata +8 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7a11aeb89323c30bbd519aaf6b5781045ffad311a36a6961df5df7b36d289a80
|
|
4
|
+
data.tar.gz: 8e1fcd5ed671d2938f0b1774d21c7e07ee4a5fbd75cbf473f170b5c2beeea585
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 84d2ee2371e4896f8d5225666d940c7a5e2aa1be8b6978a28cffe7d6e3be15c998457b0732de8b3845da7e4b50921ff2982cb9f4e905abac5aee56390e837076
|
|
7
|
+
data.tar.gz: a28fed7f7d93ed282c1b80d008d3d69f295c013a1df3b86c232ae313c07d75abc0c3729daf3c4677e7556542c68449a8858bd2c7fe047a8e22465b0da8283e84
|
data/README.md
CHANGED
|
@@ -25,11 +25,11 @@ gem 'sqlite3' # or pg / mysql2 for SQL
|
|
|
25
25
|
|
|
26
26
|
If you use SQL persistence, create the Kaal tables using Sequel migrations. `kaal` exposes the Sequel migration templates for:
|
|
27
27
|
|
|
28
|
-
- SQLite: `kaal_dispatches`, `kaal_locks`, `kaal_definitions`
|
|
29
|
-
- PostgreSQL: `kaal_dispatches`, `kaal_definitions`
|
|
30
|
-
- MySQL: `kaal_dispatches`, `kaal_definitions`
|
|
28
|
+
- SQLite: `kaal_dispatches`, `kaal_locks`, `kaal_definitions`, `kaal_delayed_jobs`
|
|
29
|
+
- PostgreSQL: `kaal_dispatches`, `kaal_definitions`, `kaal_delayed_jobs`
|
|
30
|
+
- MySQL: `kaal_dispatches`, `kaal_definitions`, `kaal_delayed_jobs`
|
|
31
31
|
|
|
32
|
-
Your app should also provide `config/scheduler.yml`.
|
|
32
|
+
Your app should also provide `config/kaal-scheduler.yml`.
|
|
33
33
|
|
|
34
34
|
## What It Provides
|
|
35
35
|
|
|
@@ -38,6 +38,7 @@ Your app should also provide `config/scheduler.yml`.
|
|
|
38
38
|
- redis convenience wiring when the app passes a redis client
|
|
39
39
|
- automatic SQL backend selection from the Sequel adapter unless the app passes `adapter:`
|
|
40
40
|
- explicit lifecycle helpers so web processes do not implicitly start background scheduler threads
|
|
41
|
+
- the normal Kaal runtime API inside a Roda app
|
|
41
42
|
|
|
42
43
|
## Minimal Roda
|
|
43
44
|
|
|
@@ -54,8 +55,7 @@ end
|
|
|
54
55
|
class App < Roda
|
|
55
56
|
plugin :kaal
|
|
56
57
|
|
|
57
|
-
kaal
|
|
58
|
-
scheduler_config_path: 'config/scheduler.yml',
|
|
58
|
+
kaal scheduler_config_path: 'config/kaal-scheduler.yml',
|
|
59
59
|
namespace: 'my-app',
|
|
60
60
|
start_scheduler: false
|
|
61
61
|
|
|
@@ -73,12 +73,12 @@ require 'redis'
|
|
|
73
73
|
require 'kaal/roda'
|
|
74
74
|
|
|
75
75
|
class App < Roda
|
|
76
|
-
REDIS = Redis.new(url:
|
|
76
|
+
REDIS = Redis.new(url: "redis://127.0.0.1:6379/0")
|
|
77
77
|
|
|
78
78
|
plugin :kaal
|
|
79
79
|
|
|
80
80
|
kaal redis: REDIS,
|
|
81
|
-
scheduler_config_path: 'config/scheduler.yml',
|
|
81
|
+
scheduler_config_path: 'config/kaal-scheduler.yml',
|
|
82
82
|
namespace: 'my-app',
|
|
83
83
|
start_scheduler: false
|
|
84
84
|
end
|
|
@@ -98,7 +98,7 @@ class App < Roda
|
|
|
98
98
|
|
|
99
99
|
kaal database: database,
|
|
100
100
|
adapter: 'postgres', # optional when Sequel can infer it
|
|
101
|
-
scheduler_config_path: 'config/scheduler.yml'
|
|
101
|
+
scheduler_config_path: 'config/kaal-scheduler.yml'
|
|
102
102
|
end
|
|
103
103
|
```
|
|
104
104
|
|
|
@@ -127,7 +127,7 @@ Preferred deployment model:
|
|
|
127
127
|
|
|
128
128
|
## Public API
|
|
129
129
|
|
|
130
|
-
- `Kaal::Roda.register!(app, backend: nil, database: nil, redis: nil, scheduler_config_path: 'config/scheduler.yml', namespace: nil, start_scheduler: false, adapter: nil, root: nil, environment: nil)`
|
|
130
|
+
- `Kaal::Roda.register!(app, backend: nil, database: nil, redis: nil, scheduler_config_path: 'config/kaal-scheduler.yml', namespace: nil, start_scheduler: false, adapter: nil, root: nil, environment: nil)`
|
|
131
131
|
- `Kaal::Roda.configure_backend!(backend: nil, database: nil, redis: nil, adapter: nil, configuration: Kaal.configuration)`
|
|
132
132
|
- `Kaal::Roda.detect_backend_name(database, adapter: nil)`
|
|
133
133
|
- `Kaal::Roda.load_scheduler_file!(root:, environment: nil)`
|
data/lib/kaal/roda/version.rb
CHANGED
data/lib/kaal/roda.rb
CHANGED
|
@@ -18,7 +18,7 @@ module Kaal
|
|
|
18
18
|
backend: nil,
|
|
19
19
|
database: nil,
|
|
20
20
|
redis: nil,
|
|
21
|
-
scheduler_config_path: 'config/scheduler.yml',
|
|
21
|
+
scheduler_config_path: 'config/kaal-scheduler.yml',
|
|
22
22
|
namespace: nil,
|
|
23
23
|
start_scheduler: false,
|
|
24
24
|
adapter: nil,
|
|
@@ -26,11 +26,12 @@ module Kaal
|
|
|
26
26
|
environment: nil
|
|
27
27
|
)
|
|
28
28
|
configuration = Kaal.configuration
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
load_config_file!(
|
|
30
|
+
root: root_path_for(app, root:),
|
|
31
|
+
environment: environment_name_for(app, environment:),
|
|
32
|
+
configuration:
|
|
33
|
+
)
|
|
34
|
+
apply_runtime_overrides(configuration:, scheduler_config_path:, namespace:)
|
|
34
35
|
configure_backend!(backend:, database:, redis:, adapter:, configuration:)
|
|
35
36
|
load_scheduler_file!(
|
|
36
37
|
root: root_path_for(app, root:),
|
|
@@ -66,6 +67,11 @@ module Kaal
|
|
|
66
67
|
configuration.backend = build_backend(backend_name, database)
|
|
67
68
|
end
|
|
68
69
|
|
|
70
|
+
def load_config_file!(root:, environment:, configuration: Kaal.configuration)
|
|
71
|
+
runtime_context = Kaal::Runtime::RuntimeContext.new(root_path: root, environment_name: environment.to_s)
|
|
72
|
+
Kaal::Config::FileLoader.new(configuration:, runtime_context:).load
|
|
73
|
+
end
|
|
74
|
+
|
|
69
75
|
def detect_backend_name(database, adapter: nil)
|
|
70
76
|
explicit_adapter = normalize_backend_name(adapter)
|
|
71
77
|
return explicit_adapter if explicit_adapter
|
|
@@ -113,6 +119,13 @@ module Kaal
|
|
|
113
119
|
end
|
|
114
120
|
end
|
|
115
121
|
|
|
122
|
+
def apply_runtime_overrides(configuration:, scheduler_config_path:, namespace:)
|
|
123
|
+
normalized_scheduler_config_path = scheduler_config_path.to_s.strip
|
|
124
|
+
normalized_namespace = namespace.to_s.strip
|
|
125
|
+
configuration.scheduler_config_path = normalized_scheduler_config_path unless normalized_scheduler_config_path.empty?
|
|
126
|
+
configuration.namespace = normalized_namespace unless normalized_namespace.empty?
|
|
127
|
+
end
|
|
128
|
+
|
|
116
129
|
def database_adapter_name(database)
|
|
117
130
|
return if database.nil?
|
|
118
131
|
|
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,54 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Backend
|
|
3
|
+
class MemoryAdapter
|
|
4
|
+
def initialize: (*rbs_any args, **rbs_any kwargs) -> void
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
class RedisAdapter
|
|
8
|
+
def initialize: (*rbs_any args, **rbs_any kwargs) -> void
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class SQLite
|
|
12
|
+
def initialize: (*rbs_any args, **rbs_any kwargs) -> void
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Postgres
|
|
16
|
+
def initialize: (*rbs_any args, **rbs_any kwargs) -> void
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class MySQL
|
|
20
|
+
def initialize: (*rbs_any args, **rbs_any kwargs) -> void
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.configuration: () -> rbs_any
|
|
25
|
+
def self.running?: () -> bool
|
|
26
|
+
def self.start!: () -> rbs_any
|
|
27
|
+
def self.stop!: (*rbs_any args, **rbs_any kwargs) -> rbs_any
|
|
28
|
+
def self.load_scheduler_file!: (*rbs_any args, **rbs_any kwargs) -> rbs_any
|
|
29
|
+
|
|
30
|
+
module Runtime
|
|
31
|
+
class RuntimeContext
|
|
32
|
+
def self.new: (*rbs_any args, **rbs_any kwargs) -> RuntimeContext
|
|
33
|
+
def self.environment_name_from: (Hash[String, String] env) -> String
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class SchedulerBootLoader
|
|
37
|
+
def initialize: (*rbs_any args, **rbs_any kwargs) -> void
|
|
38
|
+
def load_on_boot!: () -> rbs_any
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
module Config
|
|
43
|
+
class FileLoader
|
|
44
|
+
def initialize: (*rbs_any args, **rbs_any kwargs) -> void
|
|
45
|
+
def load: (*rbs_any args, **rbs_any kwargs) -> rbs_any
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class Roda
|
|
51
|
+
module RodaPlugins
|
|
52
|
+
def self.register_plugin: (*::Kaal::rbs_any args, **::Kaal::rbs_any kwargs) -> void
|
|
53
|
+
end
|
|
54
|
+
end
|
data/sig/kaal/roda.rbs
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Roda
|
|
3
|
+
self.@shutdown_hook_mutex: ::Kaal::rbs_any
|
|
4
|
+
|
|
5
|
+
def self.register!: (::Kaal::rbs_any app, ?backend: ::Kaal::rbs_any?, ?database: ::Kaal::rbs_any?, ?redis: ::Kaal::rbs_any?, ?scheduler_config_path: ::String, ?namespace: ::Kaal::rbs_any?, ?start_scheduler: bool, ?adapter: ::Kaal::rbs_any?, ?root: ::Kaal::rbs_any?, ?environment: ::Kaal::rbs_any?) -> ::Kaal::rbs_any
|
|
6
|
+
|
|
7
|
+
def self.configure_backend!: (?backend: ::Kaal::rbs_any?, ?database: ::Kaal::rbs_any?, ?redis: ::Kaal::rbs_any?, ?adapter: ::Kaal::rbs_any?, ?configuration: ::Kaal::rbs_any) -> ::Kaal::rbs_any
|
|
8
|
+
|
|
9
|
+
def self.load_config_file!: (root: ::Kaal::rbs_any, environment: ::Kaal::rbs_any, ?configuration: ::Kaal::rbs_any) -> ::Kaal::rbs_any
|
|
10
|
+
|
|
11
|
+
def self.detect_backend_name: (::Kaal::rbs_any database, ?adapter: ::Kaal::rbs_any?) -> ::Kaal::rbs_any
|
|
12
|
+
|
|
13
|
+
def self.load_scheduler_file!: (root: ::Kaal::rbs_any, ?environment: ::Kaal::rbs_any?) -> ::Kaal::rbs_any
|
|
14
|
+
|
|
15
|
+
def self.start!: () -> ::Kaal::rbs_any
|
|
16
|
+
|
|
17
|
+
def self.stop!: (?timeout: ::Integer) -> ::Kaal::rbs_any
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def self.build_redis_backend: (::Kaal::rbs_any redis, ::Kaal::rbs_any configuration) -> ::Kaal::rbs_any
|
|
22
|
+
|
|
23
|
+
def self.build_backend: (::Kaal::rbs_any backend_name, ::Kaal::rbs_any database) -> ::Kaal::rbs_any
|
|
24
|
+
|
|
25
|
+
def self.apply_runtime_overrides: (configuration: ::Kaal::rbs_any, scheduler_config_path: ::Kaal::rbs_any, namespace: ::Kaal::rbs_any) -> ::Kaal::rbs_any
|
|
26
|
+
|
|
27
|
+
def self.database_adapter_name: (::Kaal::rbs_any database) -> (nil | ::Kaal::rbs_any)
|
|
28
|
+
|
|
29
|
+
def self.normalize_backend_name: (::Kaal::rbs_any adapter_name) -> (nil | "sqlite" | "postgres" | "mysql")
|
|
30
|
+
|
|
31
|
+
def self.root_path_for: (::Kaal::rbs_any app, ?root: ::Kaal::rbs_any?) -> ::Kaal::rbs_any
|
|
32
|
+
|
|
33
|
+
def self.environment_name_for: (::Kaal::rbs_any app, ?environment: ::Kaal::rbs_any?) -> ::Kaal::rbs_any
|
|
34
|
+
|
|
35
|
+
def self.start_managed_scheduler!: () -> (nil | ::Kaal::rbs_any)
|
|
36
|
+
|
|
37
|
+
def self.install_shutdown_hook: () -> (nil | ::Kaal::rbs_any)
|
|
38
|
+
end
|
|
39
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kaal-roda
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nitesh Purohit
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - '='
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
19
|
+
version: 0.6.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - '='
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.
|
|
26
|
+
version: 0.6.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rack
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -79,6 +79,11 @@ files:
|
|
|
79
79
|
- lib/kaal/roda.rb
|
|
80
80
|
- lib/kaal/roda/version.rb
|
|
81
81
|
- lib/roda/plugins/kaal.rb
|
|
82
|
+
- sig/00_types.rbs
|
|
83
|
+
- sig/dependencies.rbs
|
|
84
|
+
- sig/kaal/roda.rbs
|
|
85
|
+
- sig/kaal/roda/version.rbs
|
|
86
|
+
- sig/roda/plugins/kaal.rbs
|
|
82
87
|
homepage: https://github.com/Code-Vedas/kaal
|
|
83
88
|
licenses:
|
|
84
89
|
- MIT
|