Class: Smplkit::Jobs::JobEnvironment
- Inherits:
-
Struct
- Object
- Struct
- Smplkit::Jobs::JobEnvironment
- Defined in:
- lib/smplkit/jobs/models.rb
Overview
Per-environment enablement, schedule, and configuration override for a job.
A job runs in a given environment only when that environment has an entry in Smplkit::Jobs::Job#environments with enabled: true (scheduled there for a recurring job, triggerable there for a manual one); an environment with no entry (or enabled: false) is disabled there.
Instance Attribute Summary collapse
-
#configuration ⇒ HttpConfig?
Optional per-environment request configuration that fully replaces the job’s base Smplkit::Jobs::Job#configuration for this environment.
-
#enabled ⇒ Boolean
Whether the job is enabled in this environment.
-
#next_run_at ⇒ String?
Read-only.
-
#schedule ⇒ String?
Optional per-environment cron schedule override that varies the cadence in this environment.
-
#timezone ⇒ String?
Optional per-environment IANA timezone override for evaluating this environment’s cron #schedule (recurring jobs only).
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil) ⇒ JobEnvironment
constructor
A new instance of JobEnvironment.
Constructor Details
#initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil) ⇒ JobEnvironment
Returns a new instance of JobEnvironment.
314 315 316 |
# File 'lib/smplkit/jobs/models.rb', line 314 def initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil) super end |
Instance Attribute Details
#configuration ⇒ HttpConfig?
Returns Optional per-environment request configuration that fully replaces the job’s base Smplkit::Jobs::Job#configuration for this environment. nil (the default) inherits the base configuration. As with the base configuration, header values are returned in plaintext on reads, so a get-mutate-put round-trip preserves them.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/smplkit/jobs/models.rb', line 313 JobEnvironment = Struct.new(:enabled, :schedule, :timezone, :configuration, :next_run_at, keyword_init: true) do def initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil) super end # @api private — Build a {JobEnvironment} from the generated wire model. # # @param src [SmplkitGeneratedClient::Jobs::JobEnvironment, nil] The wire # model, or +nil+ for a disabled environment with no override. # @return [JobEnvironment] def self.from_wire(src) return new if src.nil? cfg = src.configuration new( enabled: src.enabled.nil? ? false : src.enabled, schedule: src.schedule, timezone: src.timezone, configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg), next_run_at: src.next_run_at ) end end |
#enabled ⇒ Boolean
Returns Whether the job is enabled in this environment. Defaults to false.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/smplkit/jobs/models.rb', line 313 JobEnvironment = Struct.new(:enabled, :schedule, :timezone, :configuration, :next_run_at, keyword_init: true) do def initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil) super end # @api private — Build a {JobEnvironment} from the generated wire model. # # @param src [SmplkitGeneratedClient::Jobs::JobEnvironment, nil] The wire # model, or +nil+ for a disabled environment with no override. # @return [JobEnvironment] def self.from_wire(src) return new if src.nil? cfg = src.configuration new( enabled: src.enabled.nil? ? false : src.enabled, schedule: src.schedule, timezone: src.timezone, configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg), next_run_at: src.next_run_at ) end end |
#next_run_at ⇒ String?
Returns Read-only. The next scheduled fire time in this environment. nil when the environment is not enabled, or once a one-off run has fired. Never written back on save.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/smplkit/jobs/models.rb', line 313 JobEnvironment = Struct.new(:enabled, :schedule, :timezone, :configuration, :next_run_at, keyword_init: true) do def initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil) super end # @api private — Build a {JobEnvironment} from the generated wire model. # # @param src [SmplkitGeneratedClient::Jobs::JobEnvironment, nil] The wire # model, or +nil+ for a disabled environment with no override. # @return [JobEnvironment] def self.from_wire(src) return new if src.nil? cfg = src.configuration new( enabled: src.enabled.nil? ? false : src.enabled, schedule: src.schedule, timezone: src.timezone, configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg), next_run_at: src.next_run_at ) end end |
#schedule ⇒ String?
Returns Optional per-environment cron schedule override that varies the cadence in this environment. nil (the default) inherits the job’s base Smplkit::Jobs::Job#schedule. When present, it must be a 5-field UTC cron expression and is only meaningful on a recurring job —it cannot turn a one-off job recurring or vice-versa.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/smplkit/jobs/models.rb', line 313 JobEnvironment = Struct.new(:enabled, :schedule, :timezone, :configuration, :next_run_at, keyword_init: true) do def initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil) super end # @api private — Build a {JobEnvironment} from the generated wire model. # # @param src [SmplkitGeneratedClient::Jobs::JobEnvironment, nil] The wire # model, or +nil+ for a disabled environment with no override. # @return [JobEnvironment] def self.from_wire(src) return new if src.nil? cfg = src.configuration new( enabled: src.enabled.nil? ? false : src.enabled, schedule: src.schedule, timezone: src.timezone, configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg), next_run_at: src.next_run_at ) end end |
#timezone ⇒ String?
Returns Optional per-environment IANA timezone override for evaluating this environment’s cron #schedule (recurring jobs only). nil (the default) inherits the base Smplkit::Jobs::Job#timezone, else UTC. When present, it must be a valid IANA zone key (e.g. “America/New_York”); it may be set on an environment that inherits the base schedule (it need not also override #schedule). Sent on writes only when present.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/smplkit/jobs/models.rb', line 313 JobEnvironment = Struct.new(:enabled, :schedule, :timezone, :configuration, :next_run_at, keyword_init: true) do def initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil) super end # @api private — Build a {JobEnvironment} from the generated wire model. # # @param src [SmplkitGeneratedClient::Jobs::JobEnvironment, nil] The wire # model, or +nil+ for a disabled environment with no override. # @return [JobEnvironment] def self.from_wire(src) return new if src.nil? cfg = src.configuration new( enabled: src.enabled.nil? ? false : src.enabled, schedule: src.schedule, timezone: src.timezone, configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg), next_run_at: src.next_run_at ) end end |
Class Method Details
.from_wire(src) ⇒ JobEnvironment
323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/smplkit/jobs/models.rb', line 323 def self.from_wire(src) return new if src.nil? cfg = src.configuration new( enabled: src.enabled.nil? ? false : src.enabled, schedule: src.schedule, timezone: src.timezone, configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg), next_run_at: src.next_run_at ) end |