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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a6580041048d921b8c344e53bac88fab4c32f1fe7852ef8bd55cb3b24fede29
|
4
|
+
data.tar.gz: fce541ab019ed32f821c9801160180b7b37233aa751dc6ad50707d75d9c76376
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/wolf_core/version.rb
CHANGED