Module: Kaal::CLI::Helpers
- Defined in:
- lib/kaal/cli.rb,
sig/kaal/cli.rbs
Overview
Internal instance helpers excluded from the public Thor command surface.
Instance Method Summary collapse
- #config_path ⇒ Kaal::rbs_any
- #load_project! ⇒ Kaal::rbs_any
- #render_config_template(backend) ⇒ Kaal::rbs_any
- #root_path ⇒ Kaal::rbs_any
- #scheduler_path ⇒ Kaal::rbs_any
- #scheduler_template ⇒ "defaults:\n jobs:\n - key: \"example:heartbeat\"\n cron: \"*/5 * * * *\"\n job_class: \"ExampleHeartbeatJob\"\n enabled: true\n args:\n - \"{{fire_time.iso8601}}\"\n kwargs:\n idempotency_key: \"{{idempotency_key}}\"\n metadata:\n owner: \"ops\"\n"
Instance Method Details
#config_path ⇒ Kaal::rbs_any
32 33 34 35 36 37 |
# File 'lib/kaal/cli.rb', line 32 def config_path config = [:config] return File.(config) if config File.join(root_path, 'config', 'kaal.yml') end |
#load_project! ⇒ Kaal::rbs_any
19 20 21 22 23 24 25 26 |
# File 'lib/kaal/cli.rb', line 19 def load_project! Kaal.reset_configuration! Kaal.reset_registry! runtime_context = RuntimeContext.default(root_path: root_path) Kaal.load_config_file!(path: config_path, runtime_context:) Kaal.warn_on_risky_configuration! Kaal.load_scheduler_file!(runtime_context: runtime_context) end |
#render_config_template(backend) ⇒ Kaal::rbs_any
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/kaal/cli.rb', line 43 def render_config_template(backend) case backend when 'memory' " defaults:\n backend: memory\n namespace: kaal\n tick_interval: 5\n window_lookback: 120\n window_lookahead: 0\n lease_ttl: 125\n scheduler_config_path: config/kaal-scheduler.yml\n enable_dispatch_recovery: true\n enable_log_dispatch_registry: false\n delayed_job_allowed_class_prefixes: []\n backend_config: {}\n YAML\n when 'redis'\n <<~YAML\n defaults:\n backend: redis\n namespace: kaal\n tick_interval: 5\n window_lookback: 120\n window_lookahead: 0\n lease_ttl: 125\n scheduler_config_path: config/kaal-scheduler.yml\n enable_dispatch_recovery: true\n enable_log_dispatch_registry: false\n delayed_job_allowed_class_prefixes: []\n backend_config:\n url: redis://127.0.0.1:6379/0\n YAML\n else\n raise Thor::Error, \"Unsupported backend '\#{backend}'\"\n end\nend\n" |
#root_path ⇒ Kaal::rbs_any
28 29 30 |
# File 'lib/kaal/cli.rb', line 28 def root_path File.([:root]) end |
#scheduler_path ⇒ Kaal::rbs_any
39 40 41 |
# File 'lib/kaal/cli.rb', line 39 def scheduler_path File.join(root_path, 'config', 'kaal-scheduler.yml') end |
#scheduler_template ⇒ "defaults:\n jobs:\n - key: \"example:heartbeat\"\n cron: \"*/5 * * * *\"\n job_class: \"ExampleHeartbeatJob\"\n enabled: true\n args:\n - \"{{fire_time.iso8601}}\"\n kwargs:\n idempotency_key: \"{{idempotency_key}}\"\n metadata:\n owner: \"ops\"\n"
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/kaal/cli.rb', line 81 def scheduler_template " defaults:\n jobs:\n - key: \"example:heartbeat\"\n cron: \"*/5 * * * *\"\n job_class: \"ExampleHeartbeatJob\"\n enabled: true\n args:\n - \"{{fire_time.iso8601}}\"\n kwargs:\n idempotency_key: \"{{idempotency_key}}\"\n metadata:\n owner: \"ops\"\n YAML\nend\n" |