smplkit 3.0.115 → 3.0.116
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/lib/smplkit/jobs/client.rb +10 -3
- data/lib/smplkit/jobs/models.rb +50 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bc58dc086c7fddd47a59bf3db2136dafb156549fe8d062957209ef0b0057b341
|
|
4
|
+
data.tar.gz: 422145f651bc3490f5210d436aee72682b40dc57407d3edd2c3ad65a80ff71db
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8bbddde3e3c7539bde483e6f0cf3faf9e9df1915560e8e42c107d53c0c79b035c971c4030daa301d9ed6b27ee78b834d445746113c5b227ffdd8389ddf4c1f49
|
|
7
|
+
data.tar.gz: ea6492fa6de7972f79ad7b56c84bcc53a6e7f157ce19c29d1e80087652eac775d3c028c171a50e4ce6afde8486cdf0abf86e958642b730a4286099d19ab7f674
|
data/lib/smplkit/jobs/client.rb
CHANGED
|
@@ -394,13 +394,15 @@ module Smplkit
|
|
|
394
394
|
# Convert the wrapper +environments+ map to the generated model hash.
|
|
395
395
|
#
|
|
396
396
|
# Each entry's +enabled+ is always written; a per-environment +schedule+
|
|
397
|
-
# (cron) override and +configuration+ override are
|
|
398
|
-
# present (omit to inherit the job's base +schedule+ /
|
|
399
|
-
# The read-only per-environment
|
|
397
|
+
# (cron) override, +timezone+ override, and +configuration+ override are
|
|
398
|
+
# each sent only when present (omit to inherit the job's base +schedule+ /
|
|
399
|
+
# +timezone+ / +configuration+). The read-only per-environment
|
|
400
|
+
# +next_run_at+ is never written.
|
|
400
401
|
def environments_to_wire(environments)
|
|
401
402
|
(environments || {}).each_with_object({}) do |(env_key, env), out|
|
|
402
403
|
attrs = { enabled: env.enabled }
|
|
403
404
|
attrs[:schedule] = env.schedule unless env.schedule.nil?
|
|
405
|
+
attrs[:timezone] = env.timezone unless env.timezone.nil?
|
|
404
406
|
attrs[:configuration] = HttpConfig.to_wire(env.configuration) unless env.configuration.nil?
|
|
405
407
|
out[env_key.to_s] = SmplkitGeneratedClient::Jobs::JobEnvironment.new(attrs)
|
|
406
408
|
end
|
|
@@ -418,6 +420,11 @@ module Smplkit
|
|
|
418
420
|
configuration: HttpConfig.to_wire(job.configuration),
|
|
419
421
|
concurrency_policy: job.concurrency_policy
|
|
420
422
|
}
|
|
423
|
+
# +timezone+ is only valid on a recurring (cron) job; an unset +nil+ is
|
|
424
|
+
# omitted, leaving the server default of UTC. (Unlike +schedule+, whose
|
|
425
|
+
# explicit +null+ creates a manual job, omitting +timezone+ simply
|
|
426
|
+
# inherits UTC — so it is sent only when present.)
|
|
427
|
+
attrs[:timezone] = job.timezone unless job.timezone.nil?
|
|
421
428
|
environments = job.environments
|
|
422
429
|
attrs[:environments] = environments_to_wire(environments) unless environments.nil? || environments.empty?
|
|
423
430
|
SmplkitGeneratedClient::Jobs::Job.new(attrs)
|
data/lib/smplkit/jobs/models.rb
CHANGED
|
@@ -79,7 +79,8 @@ module Smplkit
|
|
|
79
79
|
# (+{ enabled: true, schedule: "0 3 * * *", configuration: HttpConfig.new(...) }+)
|
|
80
80
|
# so callers can use the lightweight hash form without importing the model. A
|
|
81
81
|
# dict-form +configuration+ override is coerced to an {HttpConfig} so it
|
|
82
|
-
# serializes on save;
|
|
82
|
+
# serializes on save; optional +schedule+ cron and +timezone+ overrides pass
|
|
83
|
+
# through.
|
|
83
84
|
#
|
|
84
85
|
# @api private
|
|
85
86
|
def self.normalize_environments(environments)
|
|
@@ -94,6 +95,7 @@ module Smplkit
|
|
|
94
95
|
JobEnvironment.new(
|
|
95
96
|
enabled: value[:enabled] || value["enabled"] || false,
|
|
96
97
|
schedule: value[:schedule] || value["schedule"],
|
|
98
|
+
timezone: value[:timezone] || value["timezone"],
|
|
97
99
|
configuration: cfg
|
|
98
100
|
)
|
|
99
101
|
end
|
|
@@ -291,6 +293,13 @@ module Smplkit
|
|
|
291
293
|
# inherits the job's base {Job#schedule}. When present, it must be a
|
|
292
294
|
# 5-field UTC cron expression and is only meaningful on a recurring job —
|
|
293
295
|
# it cannot turn a one-off job recurring or vice-versa.
|
|
296
|
+
# @!attribute [rw] timezone
|
|
297
|
+
# @return [String, nil] Optional per-environment IANA timezone override for
|
|
298
|
+
# evaluating this environment's cron {#schedule} (recurring jobs only).
|
|
299
|
+
# +nil+ (the default) inherits the base {Job#timezone}, else UTC. When
|
|
300
|
+
# present, it must be a valid IANA zone key (e.g. +"America/New_York"+);
|
|
301
|
+
# it may be set on an environment that inherits the base schedule (it
|
|
302
|
+
# need not also override {#schedule}). Sent on writes only when present.
|
|
294
303
|
# @!attribute [rw] configuration
|
|
295
304
|
# @return [HttpConfig, nil] Optional per-environment request configuration
|
|
296
305
|
# that fully replaces the job's base {Job#configuration} for this
|
|
@@ -301,8 +310,8 @@ module Smplkit
|
|
|
301
310
|
# @return [String, nil] Read-only. The next scheduled fire time in this
|
|
302
311
|
# environment. +nil+ when the environment is not enabled, or once a
|
|
303
312
|
# one-off run has fired. Never written back on save.
|
|
304
|
-
JobEnvironment = Struct.new(:enabled, :schedule, :configuration, :next_run_at, keyword_init: true) do
|
|
305
|
-
def initialize(enabled: false, schedule: nil, configuration: nil, next_run_at: nil)
|
|
313
|
+
JobEnvironment = Struct.new(:enabled, :schedule, :timezone, :configuration, :next_run_at, keyword_init: true) do
|
|
314
|
+
def initialize(enabled: false, schedule: nil, timezone: nil, configuration: nil, next_run_at: nil)
|
|
306
315
|
super
|
|
307
316
|
end
|
|
308
317
|
|
|
@@ -318,6 +327,7 @@ module Smplkit
|
|
|
318
327
|
new(
|
|
319
328
|
enabled: src.enabled.nil? ? false : src.enabled,
|
|
320
329
|
schedule: src.schedule,
|
|
330
|
+
timezone: src.timezone,
|
|
321
331
|
configuration: cfg.nil? ? nil : HttpConfig.from_wire(cfg),
|
|
322
332
|
next_run_at: src.next_run_at
|
|
323
333
|
)
|
|
@@ -386,6 +396,16 @@ module Smplkit
|
|
|
386
396
|
# {#set_schedule}.
|
|
387
397
|
attr_accessor :schedule
|
|
388
398
|
|
|
399
|
+
# @return [String, nil] The base IANA timezone the cron {#schedule} is
|
|
400
|
+
# evaluated in (e.g. +"America/New_York"+); +nil+ (the default) means
|
|
401
|
+
# UTC. The base every environment inherits unless it sets its own
|
|
402
|
+
# {JobEnvironment#timezone}. The cron fires on this zone's wall clock
|
|
403
|
+
# (DST-aware) while +next_run_at+ is still reported as a UTC instant.
|
|
404
|
+
# Only valid on a recurring (cron) job — leave +nil+ for a manual or
|
|
405
|
+
# one-off job. Set it with {#set_timezone}; sent on writes only when
|
|
406
|
+
# present.
|
|
407
|
+
attr_accessor :timezone
|
|
408
|
+
|
|
389
409
|
# @return [HttpConfig] The base HTTP request to perform when the job fires.
|
|
390
410
|
# Per-environment overrides live in {#environments}.
|
|
391
411
|
attr_accessor :configuration
|
|
@@ -416,7 +436,7 @@ module Smplkit
|
|
|
416
436
|
attr_accessor :birth_environment
|
|
417
437
|
|
|
418
438
|
def initialize(client = nil, id:, name:, configuration:, schedule: nil,
|
|
419
|
-
description: nil, environments: nil,
|
|
439
|
+
timezone: nil, description: nil, environments: nil,
|
|
420
440
|
kind: nil, type: "http", concurrency_policy: "ALLOW",
|
|
421
441
|
birth_environment: nil, created_at: nil,
|
|
422
442
|
updated_at: nil, deleted_at: nil, version: nil)
|
|
@@ -428,6 +448,7 @@ module Smplkit
|
|
|
428
448
|
@kind = kind
|
|
429
449
|
@type = type
|
|
430
450
|
@schedule = schedule
|
|
451
|
+
@timezone = timezone
|
|
431
452
|
@configuration = configuration
|
|
432
453
|
@concurrency_policy = concurrency_policy
|
|
433
454
|
@birth_environment = birth_environment
|
|
@@ -580,6 +601,29 @@ module Smplkit
|
|
|
580
601
|
end
|
|
581
602
|
end
|
|
582
603
|
|
|
604
|
+
# Set the IANA timezone the cron schedule is evaluated in — base
|
|
605
|
+
# (+environment+ omitted) or per-environment.
|
|
606
|
+
#
|
|
607
|
+
# With +environment+ omitted (the default), sets the base {#timezone}
|
|
608
|
+
# every environment inherits unless it overrides it. With an +environment+
|
|
609
|
+
# given, sets that environment's per-environment +timezone+ override on
|
|
610
|
+
# {#environments}, creating the override entry if it doesn't exist yet
|
|
611
|
+
# (preserving any already-set +enabled+ / +schedule+ / +configuration+ on
|
|
612
|
+
# it). A timezone is only valid on a recurring (cron) job; +nil+ means UTC
|
|
613
|
+
# (base) or "inherit the base" (per-environment). Call {#save} to persist.
|
|
614
|
+
#
|
|
615
|
+
# @param timezone [String, nil] A valid IANA timezone key (e.g.
|
|
616
|
+
# +"America/New_York"+), or +nil+ for UTC / inherit.
|
|
617
|
+
# @param environment [String, nil] An environment key for a per-environment
|
|
618
|
+
# override, or +nil+ to set the base timezone.
|
|
619
|
+
def set_timezone(timezone, environment: nil)
|
|
620
|
+
if environment.nil?
|
|
621
|
+
@timezone = timezone
|
|
622
|
+
else
|
|
623
|
+
_environment_override(environment).timezone = timezone
|
|
624
|
+
end
|
|
625
|
+
end
|
|
626
|
+
|
|
583
627
|
# Trigger one immediate, manual run of this job (a +MANUAL+ run).
|
|
584
628
|
#
|
|
585
629
|
# @param environment [String, nil] Environment the run executes in.
|
|
@@ -633,6 +677,7 @@ module Smplkit
|
|
|
633
677
|
@kind = other.kind
|
|
634
678
|
@type = other.type
|
|
635
679
|
@schedule = other.schedule
|
|
680
|
+
@timezone = other.timezone
|
|
636
681
|
@configuration = other.configuration
|
|
637
682
|
@concurrency_policy = other.concurrency_policy
|
|
638
683
|
@created_at = other.created_at
|
|
@@ -663,6 +708,7 @@ module Smplkit
|
|
|
663
708
|
kind: a.kind,
|
|
664
709
|
type: a.type || "http",
|
|
665
710
|
schedule: a.schedule,
|
|
711
|
+
timezone: a.timezone,
|
|
666
712
|
configuration: HttpConfig.from_wire(a.configuration),
|
|
667
713
|
concurrency_policy: a.concurrency_policy || "ALLOW",
|
|
668
714
|
created_at: a.created_at,
|