HTTP Requests and Sidekiq
Created by @sjreich
Many companies use a microservices architecture, in which many small parts of their system communicate with one another via HTTP requests. Typically, we use Sidekiq or similar libraries like Delayed Job and Resque, to make those requests asynchronously and to handle retrying requests if something goes wrong.
This exercise introduces the relevant concepts via Sidekiq.
The setup for this exercise is a bit complicated. Sorry.
- Bring in this repo, and its dependencies.
$ git clone <copy the address from github> $ cd sidekiq-and-http-exercise $ bundle install
- You'll need a Redis server running locally. In a new terminal window, run:
$ brew install redis $ redis-server
- Start the web server you'll be interacting with. In a new terminal window, run:
$ ruby server/server.rb
- Start the sidekiq background process(es). In a new terminal window, run:
$ bundle exec sidekiq -r ./client/sidekiq_workers.rb
The main file to work on is 'client/main.rb'. Read it, edit it, execute it.
$ ruby client/main.rb
You'll also need to edit 'client/sidekiq_workers.rb'. For your changes there to take effect,
you will need to kill off the existing sidekiq process(es) with
ctrl-C, and then restart
them using the command above.
When you're done, kill off everything with