sidekiq-sorbet 0.1.0 → 0.2.0
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/CHANGELOG.md +6 -0
- data/lib/sidekiq/sorbet/class_methods.rb +28 -0
- data/lib/sidekiq/sorbet/version.rb +1 -1
- data/lib/tapioca/dsl/compilers/sidekiq_sorbet.rb +40 -0
- 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: '078966faedc5ed9f43d8521911fdf7d42019686248a00792e60b0af31c385f31'
|
|
4
|
+
data.tar.gz: 1186336551a72813a8112127d534d84332f2b95e2aaf3432dcf49bfb9b90d8d2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 336219d342d70bc744e27c3dbd1fd74469765ae200962fa20914b9a7b94e5b5bfa13e57ac44643f2c85a053d226b13d5eea5f078e7bd76978141c0884ea36ae5
|
|
7
|
+
data.tar.gz: f0fe8bc2956348bdaf4e6e8adf671e457b8cdaeca4400e445ffba325cf4f9b33a285941e40ee8407686b6197a602fdd30fd4d21d936d08ca0eab8612978594e2
|
data/CHANGELOG.md
CHANGED
|
@@ -22,6 +22,34 @@ module Sidekiq
|
|
|
22
22
|
perform_async(serialized)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
# Enqueues a job to be performed at a specific time with validated arguments
|
|
26
|
+
#
|
|
27
|
+
# @param time [Time, Numeric] When to perform the job (timestamp or Time object)
|
|
28
|
+
# @param kwargs [Hash] Arguments matching the Args T::Struct (or empty if no Args)
|
|
29
|
+
# @return [String] Sidekiq job ID
|
|
30
|
+
# @raise [InvalidArgsError] if arguments fail validation
|
|
31
|
+
# @raise [SerializationError] if serialization fails
|
|
32
|
+
sig { params(time: T.any(Time, Numeric), kwargs: T.untyped).returns(String) }
|
|
33
|
+
def run_at(time, **kwargs)
|
|
34
|
+
args_instance = build_args(**kwargs)
|
|
35
|
+
serialized = serialize_args(args_instance)
|
|
36
|
+
perform_at(time, serialized)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Enqueues a job to be performed after a delay with validated arguments
|
|
40
|
+
#
|
|
41
|
+
# @param interval [Numeric] How long to wait before performing (in seconds)
|
|
42
|
+
# @param kwargs [Hash] Arguments matching the Args T::Struct (or empty if no Args)
|
|
43
|
+
# @return [String] Sidekiq job ID
|
|
44
|
+
# @raise [InvalidArgsError] if arguments fail validation
|
|
45
|
+
# @raise [SerializationError] if serialization fails
|
|
46
|
+
sig { params(interval: Numeric, kwargs: T.untyped).returns(String) }
|
|
47
|
+
def run_in(interval, **kwargs)
|
|
48
|
+
args_instance = build_args(**kwargs)
|
|
49
|
+
serialized = serialize_args(args_instance)
|
|
50
|
+
perform_in(interval, serialized)
|
|
51
|
+
end
|
|
52
|
+
|
|
25
53
|
# Executes a job synchronously with validated arguments
|
|
26
54
|
#
|
|
27
55
|
# @param kwargs [Hash] Arguments matching the Args T::Struct (or empty if no Args)
|
|
@@ -47,6 +47,8 @@ module Tapioca
|
|
|
47
47
|
root.create_path(constant) do |klass|
|
|
48
48
|
generate_argument_accessors(klass) if args_class
|
|
49
49
|
generate_run_async_method(klass)
|
|
50
|
+
generate_run_at_method(klass)
|
|
51
|
+
generate_run_in_method(klass)
|
|
50
52
|
generate_run_sync_method(klass)
|
|
51
53
|
end
|
|
52
54
|
end
|
|
@@ -91,6 +93,26 @@ module Tapioca
|
|
|
91
93
|
)
|
|
92
94
|
end
|
|
93
95
|
|
|
96
|
+
sig { params(klass: RBI::Scope).void }
|
|
97
|
+
def generate_run_at_method(klass)
|
|
98
|
+
klass.create_method(
|
|
99
|
+
"run_at",
|
|
100
|
+
parameters: build_time_params_signature,
|
|
101
|
+
return_type: "String",
|
|
102
|
+
class_method: true,
|
|
103
|
+
)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
sig { params(klass: RBI::Scope).void }
|
|
107
|
+
def generate_run_in_method(klass)
|
|
108
|
+
klass.create_method(
|
|
109
|
+
"run_in",
|
|
110
|
+
parameters: build_interval_params_signature,
|
|
111
|
+
return_type: "String",
|
|
112
|
+
class_method: true,
|
|
113
|
+
)
|
|
114
|
+
end
|
|
115
|
+
|
|
94
116
|
sig { params(klass: RBI::Scope).void }
|
|
95
117
|
def generate_run_sync_method(klass)
|
|
96
118
|
klass.create_method(
|
|
@@ -118,6 +140,24 @@ module Tapioca
|
|
|
118
140
|
RBI::TypedParam.new(param: param, type: type)
|
|
119
141
|
end
|
|
120
142
|
end
|
|
143
|
+
|
|
144
|
+
sig { returns(T::Array[RBI::TypedParam]) }
|
|
145
|
+
def build_time_params_signature
|
|
146
|
+
time_param = RBI::TypedParam.new(
|
|
147
|
+
param: RBI::ReqParam.new("time"),
|
|
148
|
+
type: "T.any(Time, Numeric)",
|
|
149
|
+
)
|
|
150
|
+
[time_param, *build_params_signature]
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
sig { returns(T::Array[RBI::TypedParam]) }
|
|
154
|
+
def build_interval_params_signature
|
|
155
|
+
interval_param = RBI::TypedParam.new(
|
|
156
|
+
param: RBI::ReqParam.new("interval"),
|
|
157
|
+
type: "Numeric",
|
|
158
|
+
)
|
|
159
|
+
[interval_param, *build_params_signature]
|
|
160
|
+
end
|
|
121
161
|
end
|
|
122
162
|
end
|
|
123
163
|
end
|