kaal-sinatra 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 +6 -7
- data/lib/kaal/sinatra/version.rb +1 -1
- data/lib/kaal/sinatra.rb +15 -6
- data/sig/00_types.rbs +12 -0
- data/sig/dependencies.rbs +53 -0
- data/sig/kaal/sinatra/version.rbs +5 -0
- data/sig/kaal/sinatra.rbs +51 -0
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c3b4b16c559eaaeecfad9d566002de7f38ac34f7ae27acbf5a123238442359b1
|
|
4
|
+
data.tar.gz: 57eafe07676544d15da4d25ebdc39e16e40fa88fe5b7baa15e2c2e260ade2055
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 36c671c3da1de727a3a568d584c6b5ed568c66f08cc2dd52700b1533384244bb401a92ba571b36c5c75718c3c9042aff426a5ce446e4a28c5a9d949b261bfa3d
|
|
7
|
+
data.tar.gz: 3a9f257a6d8f46b15dbe41b5e057fa260de987f9d422accf36cea1384f0b1f88f52574aecf6b9e5d70c12b8e49494db216ff975ccd0764b2c5221afa3a51b75c
|
data/README.md
CHANGED
|
@@ -29,7 +29,7 @@ If you use SQL persistence, create the Kaal tables using Sequel migrations. `kaa
|
|
|
29
29
|
- PostgreSQL: `kaal_dispatches`, `kaal_definitions`, `kaal_delayed_jobs`
|
|
30
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
|
|
|
@@ -56,8 +56,7 @@ register Kaal::Sinatra::Extension
|
|
|
56
56
|
|
|
57
57
|
Kaal::Sinatra.register!(
|
|
58
58
|
settings,
|
|
59
|
-
|
|
60
|
-
scheduler_config_path: 'config/scheduler.yml',
|
|
59
|
+
scheduler_config_path: 'config/kaal-scheduler.yml',
|
|
61
60
|
namespace: 'my-app',
|
|
62
61
|
start_scheduler: false
|
|
63
62
|
)
|
|
@@ -77,12 +76,12 @@ class ExampleHeartbeatJob
|
|
|
77
76
|
end
|
|
78
77
|
|
|
79
78
|
class App < Sinatra::Base
|
|
80
|
-
REDIS = Redis.new(url:
|
|
79
|
+
REDIS = Redis.new(url: "redis://127.0.0.1:6379/0")
|
|
81
80
|
|
|
82
81
|
register Kaal::Sinatra::Extension
|
|
83
82
|
|
|
84
83
|
kaal redis: REDIS,
|
|
85
|
-
scheduler_config_path: 'config/scheduler.yml',
|
|
84
|
+
scheduler_config_path: 'config/kaal-scheduler.yml',
|
|
86
85
|
namespace: 'my-app',
|
|
87
86
|
start_scheduler: false
|
|
88
87
|
end
|
|
@@ -101,7 +100,7 @@ Kaal::Sinatra.register!(
|
|
|
101
100
|
settings,
|
|
102
101
|
database: database,
|
|
103
102
|
adapter: 'postgres', # optional when Sequel can infer it
|
|
104
|
-
scheduler_config_path: 'config/scheduler.yml'
|
|
103
|
+
scheduler_config_path: 'config/kaal-scheduler.yml'
|
|
105
104
|
)
|
|
106
105
|
```
|
|
107
106
|
|
|
@@ -130,7 +129,7 @@ Preferred deployment model:
|
|
|
130
129
|
|
|
131
130
|
## Public API
|
|
132
131
|
|
|
133
|
-
- `Kaal::Sinatra.register!(app, backend: nil, database: nil, redis: nil, scheduler_config_path: 'config/scheduler.yml', namespace: nil, start_scheduler: false, adapter: nil)`
|
|
132
|
+
- `Kaal::Sinatra.register!(app, backend: nil, database: nil, redis: nil, scheduler_config_path: 'config/kaal-scheduler.yml', namespace: nil, start_scheduler: false, adapter: nil)`
|
|
134
133
|
- `Kaal::Sinatra.configure_backend!(backend: nil, database: nil, redis: nil, adapter: nil, configuration: Kaal.configuration)`
|
|
135
134
|
- `Kaal::Sinatra.load_scheduler_file!(root:, environment: nil)`
|
|
136
135
|
- `Kaal::Sinatra.start!`
|
data/lib/kaal/sinatra/version.rb
CHANGED
data/lib/kaal/sinatra.rb
CHANGED
|
@@ -18,17 +18,14 @@ 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
|
|
25
25
|
)
|
|
26
26
|
configuration = Kaal.configuration
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
configuration.scheduler_config_path = normalized_scheduler_config_path unless normalized_scheduler_config_path.empty?
|
|
30
|
-
configuration.namespace = normalized_namespace unless normalized_namespace.empty?
|
|
31
|
-
|
|
27
|
+
load_config_file!(root: root_path_for(app), environment: environment_name_for(app), configuration:)
|
|
28
|
+
apply_runtime_overrides(configuration:, scheduler_config_path:, namespace:)
|
|
32
29
|
configure_backend!(backend:, database:, redis:, adapter:, configuration:)
|
|
33
30
|
load_scheduler_file!(root: root_path_for(app), environment: environment_name_for(app))
|
|
34
31
|
|
|
@@ -61,6 +58,11 @@ module Kaal
|
|
|
61
58
|
return configuration.backend = build_backend(backend_name, database)
|
|
62
59
|
end
|
|
63
60
|
|
|
61
|
+
def load_config_file!(root:, environment:, configuration: Kaal.configuration)
|
|
62
|
+
runtime_context = Kaal::Runtime::RuntimeContext.new(root_path: root, environment_name: environment.to_s)
|
|
63
|
+
Kaal::Config::FileLoader.new(configuration:, runtime_context:).load
|
|
64
|
+
end
|
|
65
|
+
|
|
64
66
|
def detect_backend_name(database, adapter: nil)
|
|
65
67
|
explicit_adapter = normalize_backend_name(adapter)
|
|
66
68
|
return explicit_adapter if explicit_adapter
|
|
@@ -108,6 +110,13 @@ module Kaal
|
|
|
108
110
|
end
|
|
109
111
|
end
|
|
110
112
|
|
|
113
|
+
def apply_runtime_overrides(configuration:, scheduler_config_path:, namespace:)
|
|
114
|
+
normalized_scheduler_config_path = scheduler_config_path.to_s.strip
|
|
115
|
+
normalized_namespace = namespace.to_s.strip
|
|
116
|
+
configuration.scheduler_config_path = normalized_scheduler_config_path unless normalized_scheduler_config_path.empty?
|
|
117
|
+
configuration.namespace = normalized_namespace unless normalized_namespace.empty?
|
|
118
|
+
end
|
|
119
|
+
|
|
111
120
|
def database_adapter_name(database)
|
|
112
121
|
return if database.nil?
|
|
113
122
|
|
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,53 @@
|
|
|
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
|
+
module Sinatra
|
|
51
|
+
class Base
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Kaal
|
|
2
|
+
module Sinatra
|
|
3
|
+
self.@shutdown_hook_installed: ::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?) -> ::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) -> ::Kaal::rbs_any
|
|
32
|
+
|
|
33
|
+
def self.environment_name_for: (::Kaal::rbs_any app) -> ::Kaal::rbs_any
|
|
34
|
+
|
|
35
|
+
def self.settings_for: (::Kaal::rbs_any app) -> ::Kaal::rbs_any
|
|
36
|
+
|
|
37
|
+
def self.start_managed_scheduler!: () -> (nil | ::Kaal::rbs_any)
|
|
38
|
+
|
|
39
|
+
def self.install_shutdown_hook: () -> (nil | ::Kaal::rbs_any)
|
|
40
|
+
|
|
41
|
+
public
|
|
42
|
+
|
|
43
|
+
module Extension
|
|
44
|
+
def self.registered: (::Kaal::rbs_any app) -> ::Kaal::rbs_any
|
|
45
|
+
|
|
46
|
+
module ClassMethods
|
|
47
|
+
def kaal: (**::Kaal::rbs_any) -> ::Kaal::rbs_any
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kaal-sinatra
|
|
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
|
|
@@ -78,6 +78,10 @@ files:
|
|
|
78
78
|
- bin/update-bundle
|
|
79
79
|
- lib/kaal/sinatra.rb
|
|
80
80
|
- lib/kaal/sinatra/version.rb
|
|
81
|
+
- sig/00_types.rbs
|
|
82
|
+
- sig/dependencies.rbs
|
|
83
|
+
- sig/kaal/sinatra.rbs
|
|
84
|
+
- sig/kaal/sinatra/version.rbs
|
|
81
85
|
homepage: https://github.com/Code-Vedas/kaal
|
|
82
86
|
licenses:
|
|
83
87
|
- MIT
|