kaal-roda 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9d669a3e79751f031953db4430fda547ccc8e570c8f11acb5ab7ea4137e672e
4
- data.tar.gz: f96690361d2d3ef05e7f62690e721c80b592849ff54b765d87f7f9fb332b81ca
3
+ metadata.gz: 7a11aeb89323c30bbd519aaf6b5781045ffad311a36a6961df5df7b36d289a80
4
+ data.tar.gz: 8e1fcd5ed671d2938f0b1774d21c7e07ee4a5fbd75cbf473f170b5c2beeea585
5
5
  SHA512:
6
- metadata.gz: 13eb8bdfe6cbe98ef1fcbb14b5396ff0841b3c1599ed6287fd24110e1c18b6a7763021486ce36fe6e54cdc9971dc9af3742df9bbf54a55a1a354530ed6ebf5e7
7
- data.tar.gz: 9c0cfefe345dd333dbe759f9e359884a98fa4169c3c744013a44e7b084899d51fcad0320f938bde31e2e8c6f8da28b61aacaa5ab57618121d64274974c528334
6
+ metadata.gz: 84d2ee2371e4896f8d5225666d940c7a5e2aa1be8b6978a28cffe7d6e3be15c998457b0732de8b3845da7e4b50921ff2982cb9f4e905abac5aee56390e837076
7
+ data.tar.gz: a28fed7f7d93ed282c1b80d008d3d69f295c013a1df3b86c232ae313c07d75abc0c3729daf3c4677e7556542c68449a8858bd2c7fe047a8e22465b0da8283e84
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
 
@@ -55,8 +55,7 @@ end
55
55
  class App < Roda
56
56
  plugin :kaal
57
57
 
58
- kaal backend: Kaal::Backend::MemoryAdapter.new,
59
- scheduler_config_path: 'config/scheduler.yml',
58
+ kaal scheduler_config_path: 'config/kaal-scheduler.yml',
60
59
  namespace: 'my-app',
61
60
  start_scheduler: false
62
61
 
@@ -74,12 +73,12 @@ require 'redis'
74
73
  require 'kaal/roda'
75
74
 
76
75
  class App < Roda
77
- REDIS = Redis.new(url: ENV.fetch('REDIS_URL'))
76
+ REDIS = Redis.new(url: "redis://127.0.0.1:6379/0")
78
77
 
79
78
  plugin :kaal
80
79
 
81
80
  kaal redis: REDIS,
82
- scheduler_config_path: 'config/scheduler.yml',
81
+ scheduler_config_path: 'config/kaal-scheduler.yml',
83
82
  namespace: 'my-app',
84
83
  start_scheduler: false
85
84
  end
@@ -99,7 +98,7 @@ class App < Roda
99
98
 
100
99
  kaal database: database,
101
100
  adapter: 'postgres', # optional when Sequel can infer it
102
- scheduler_config_path: 'config/scheduler.yml'
101
+ scheduler_config_path: 'config/kaal-scheduler.yml'
103
102
  end
104
103
  ```
105
104
 
@@ -128,7 +127,7 @@ Preferred deployment model:
128
127
 
129
128
  ## Public API
130
129
 
131
- - `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)`
132
131
  - `Kaal::Roda.configure_backend!(backend: nil, database: nil, redis: nil, adapter: nil, configuration: Kaal.configuration)`
133
132
  - `Kaal::Roda.detect_backend_name(database, adapter: nil)`
134
133
  - `Kaal::Roda.load_scheduler_file!(root:, environment: nil)`
@@ -6,6 +6,6 @@
6
6
  # LICENSE file in the root directory of this source tree.
7
7
  module Kaal
8
8
  module Roda
9
- VERSION = '0.5.0'
9
+ VERSION = '0.6.0'
10
10
  end
11
11
  end
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
- normalized_scheduler_config_path = scheduler_config_path.to_s.strip
30
- normalized_namespace = namespace.to_s.strip
31
- configuration.scheduler_config_path = normalized_scheduler_config_path unless normalized_scheduler_config_path.empty?
32
- configuration.namespace = normalized_namespace unless normalized_namespace.empty?
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
@@ -0,0 +1,5 @@
1
+ module Kaal
2
+ module Roda
3
+ VERSION: String
4
+ end
5
+ 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
@@ -0,0 +1,9 @@
1
+ class Roda
2
+ module RodaPlugins
3
+ module Kaal
4
+ module ClassMethods
5
+ def kaal: (**::Kaal::rbs_any) -> ::Kaal::rbs_any
6
+ end
7
+ end
8
+ end
9
+ 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.5.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.5.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.5.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