Class: Smplkit::Jobs::JobEnvironment

Inherits:
Struct
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enabled: false, schedule: nil, configuration: nil, next_run_at: nil) ⇒ JobEnvironment

Returns a new instance of JobEnvironment.



305
306
307
# File 'lib/smplkit/jobs/models.rb', line 305

def initialize(enabled: false, schedule: nil, configuration: nil, next_run_at: nil)
  super
end

Instance Attribute Details

#configurationHttpConfig?

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.

Returns:

  • (HttpConfig, nil)

    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.



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/smplkit/jobs/models.rb', line 304

JobEnvironment = Struct.new(:enabled, :schedule, :configuration, :next_run_at, keyword_init: true) do
  def initialize(enabled: false, schedule: 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,
      configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg),
      next_run_at: src.next_run_at
    )
  end
end

#enabledBoolean

Returns Whether the job is enabled in this environment. Defaults to false.

Returns:

  • (Boolean)

    Whether the job is enabled in this environment. Defaults to false.



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/smplkit/jobs/models.rb', line 304

JobEnvironment = Struct.new(:enabled, :schedule, :configuration, :next_run_at, keyword_init: true) do
  def initialize(enabled: false, schedule: 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,
      configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg),
      next_run_at: src.next_run_at
    )
  end
end

#next_run_atString?

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.

Returns:

  • (String, nil)

    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.



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/smplkit/jobs/models.rb', line 304

JobEnvironment = Struct.new(:enabled, :schedule, :configuration, :next_run_at, keyword_init: true) do
  def initialize(enabled: false, schedule: 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,
      configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg),
      next_run_at: src.next_run_at
    )
  end
end

#scheduleString?

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.

Returns:

  • (String, nil)

    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.



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/smplkit/jobs/models.rb', line 304

JobEnvironment = Struct.new(:enabled, :schedule, :configuration, :next_run_at, keyword_init: true) do
  def initialize(enabled: false, schedule: 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,
      configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg),
      next_run_at: src.next_run_at
    )
  end
end

Class Method Details

.from_wire(src) ⇒ JobEnvironment

Parameters:

Returns:



314
315
316
317
318
319
320
321
322
323
324
# File 'lib/smplkit/jobs/models.rb', line 314

def self.from_wire(src)
  return new if src.nil?

  cfg = src.configuration
  new(
    enabled: src.enabled.nil? ? false : src.enabled,
    schedule: src.schedule,
    configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg),
    next_run_at: src.next_run_at
  )
end