wolf_core 1.1.21 → 1.1.22

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: 0f14ef011cf571a61ece3b25520aa01f57cdab3c399e6170ff3ad9cf4a825864
4
- data.tar.gz: 35235e19008b97c7d5e2234dab4c7bc698cba00837cb2792854342e2af74bebf
3
+ metadata.gz: 9a6580041048d921b8c344e53bac88fab4c32f1fe7852ef8bd55cb3b24fede29
4
+ data.tar.gz: fce541ab019ed32f821c9801160180b7b37233aa751dc6ad50707d75d9c76376
5
5
  SHA512:
6
- metadata.gz: 3fe7c44df3bb183c87aeb9e88ca56d5598c91edfe2729e11aff008b5854aedd0263de9952e8a81bba503857c112fc04dd512752ab4194ea0598a20eebcc66bc4
7
- data.tar.gz: 74bbdb0dc8574a08cbf8d0759d987b26fbba0fd3d92a4b0b23c0f768b20ee1936614d4a955cdae97000b877e3f64c62fd5365d4dd4c936239a242006803e45c5
6
+ metadata.gz: f0fab76a88aef0d4f895d4d5d2cbd5b4946037f17d2f1c34ef8f9b57b2427bd3ce8d81921df17c609302a34592955fdac85f296d7399101ef31db26b1495aa8a
7
+ data.tar.gz: 56dce903efb657ddbd752cb2acc0eb49dee889db550e0efe3a0328bb81d6b2c7650b9c9ad73d7be59c807f9ada44620e676d94332254bb75c65f279734f92a17
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "time"
4
4
  require "json"
5
+ require "digest"
5
6
 
6
7
  module WolfCore
7
8
  class JobSchedulerDataSource
@@ -15,6 +16,7 @@ module WolfCore
15
16
 
16
17
  def schedule_at(job_id:, run_at:, target:, config: {})
17
18
  Result.try do
19
+ job_id = shorten_job_id(job_id) if config[:can_shorten_job_id]
18
20
  expr = at_expression(run_at)
19
21
  normalized_target = normalize_target(target)
20
22
  response = schedule_with_expression(job_id: job_id, expr: expr, target: normalized_target, config: config)
@@ -24,6 +26,7 @@ module WolfCore
24
26
 
25
27
  def schedule_recurring(job_id:, schedule:, target:, config: {})
26
28
  Result.try do
29
+ job_id = shorten_job_id(job_id) if config[:can_shorten_job_id]
27
30
  expr = expression_from_schedule!(schedule)
28
31
  normalized_target = normalize_target(target)
29
32
  response = schedule_with_expression(job_id: job_id, expr: expr, target: normalized_target,
@@ -122,5 +125,14 @@ module WolfCore
122
125
  end
123
126
  "at(#{time.iso8601})"
124
127
  end
128
+
129
+ def shorten_job_id(job_id)
130
+ return job_id if job_id.length <= 64
131
+
132
+ hash = Digest::SHA1.hexdigest(job_id)[0, 8]
133
+ prefix_length = 64 - 1 - hash.length # reserve space for '-' and hash
134
+ prefix = job_id[0, prefix_length]
135
+ "#{prefix}-#{hash}"
136
+ end
125
137
  end
126
138
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WolfCore
4
- VERSION = "1.1.21"
4
+ VERSION = "1.1.22"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wolf_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.21
4
+ version: 1.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Roncallo