Skip to content

Commit 231e6d5

Browse files
committed
add section about Sidekiq jobs
1 parent f7e0850 commit 231e6d5

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

README.md

+44
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,50 @@ class SomeOrganizer
207207
self.if(:key_set_on_context, self.chain(DoThingA, ThenB, ThenC), DoDifferentThingB),
208208
EitherWayDoThis
209209
end
210+
211+
```
212+
213+
### Sidekiq Jobs
214+
Sometimes you want to asyncify an interactor.
215+
216+
```ruby
217+
# before
218+
class SomeInteractor
219+
include Interactify
220+
221+
def call
222+
# ...
223+
end
224+
end
225+
226+
clsas SomeInteractorJob
227+
include Sidekiq::Job
228+
229+
def perform(*args)
230+
SomeInteractor.call(*args)
231+
end
232+
end
233+
234+
SomeInteractor.call(*args)
235+
code is changed to
236+
SomeInteractorJob.perform_async(*args)
237+
```
238+
239+
```ruby
240+
# after
241+
class SomeInteractor
242+
include Interactify
243+
244+
def call
245+
# ...
246+
end
247+
end
248+
249+
# no need to manually create a job class or handle the perform/call impedance mismatch
250+
SomeInteractor::Async.call(*args)
251+
252+
# This also makes it easy to add cron jobs to run interactors. As any interactor can be asyncified.
253+
# By using it's internal Async class.
210254
```
211255

212256
## FAQs

0 commit comments

Comments
 (0)