Created
July 1, 2019 22:47
-
-
Save machty/c43646c0e2157a4c7c4f098ce8270dac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CheckoutBeaconRefreshLocationWorkerFake | |
include Sidekiq::Worker | |
sidekiq_options lock: :until_and_while_executing | |
def perform(id) | |
$tick ||= 0 | |
$tick += 1 | |
puts "STARTING #{$tick}" | |
sleep 5 | |
puts "DONE #{$tick}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6:46:19 PM worker.1 | CheckoutBeaconRefreshLocationWorkerFake JID-d62a2a531e984bdc9d949180 INFO: start | |
6:46:19 PM worker.1 | STARTING 1 | |
6:46:20 PM worker.1 | CheckoutBeaconRefreshLocationWorkerFake JID-1b8e1c31ce5d37d00c017fc4 INFO: start | |
6:46:20 PM worker.1 | CheckoutBeaconRefreshLocationWorkerFake JID-1b8e1c31ce5d37d00c017fc4 INFO: done: 0.019 sec | |
6:46:20 PM worker.1 | CheckoutBeaconRefreshLocationWorkerFake JID-bf07b3d391f496857efce83f INFO: start | |
6:46:20 PM worker.1 | CheckoutBeaconRefreshLocationWorkerFake JID-bf07b3d391f496857efce83f INFO: done: 0.018 sec | |
6:46:24 PM worker.1 | DONE 1 | |
6:46:24 PM worker.1 | CheckoutBeaconRefreshLocationWorkerFake JID-d62a2a531e984bdc9d949180 INFO: done: 5.025 sec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All of these commands where issued right after each other, in less than a second's time | |
[1] pry(main)> CheckoutBeaconRefreshLocationWorkerFake.perform_async(1) | |
=> "d62a2a531e984bdc9d949180" | |
[2] pry(main)> CheckoutBeaconRefreshLocationWorkerFake.perform_async(1) | |
=> "1b8e1c31ce5d37d00c017fc4" | |
[3] pry(main)> CheckoutBeaconRefreshLocationWorkerFake.perform_async(1) | |
=> "bf07b3d391f496857efce83f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment