This is a real server that will allow our app to make real HTTP calls, but the server itself doesn't do anything real. The server does, however, allow us to simulate various problems that may happen when integrating real third party code, such as slow responses, interrupted responses, and other issues.
The Sidekiq Book uses this app in a Docker Image. You can find it on Docker Hub
Generally, you should not have to run this from this repo unless you are doing development on the server itself. With that out of the way:
- Ensure you have Docker installed
dx/setup
(only required one time)dx/build
dx/start
- Then, in another terminal:
dx/exec bash
- You are now "logged in" to the Docker container.
After you "log in" to the container, you can edit code on your computer and it'll be available in the container. The container has Ruby installed, as well as whatever else is needed to run and test the app.
bin/test
will run the testsbin/ci
will run tests and then runbundle audit
bin/run
will run the app. Note: there is no auto-reload, so if you make changes, you have to restart. The app will be available athttp://localhost:8888
. There are minimal UIs for each fake service.bin/mk
is to be run on your computer and it will hit the API to do stuff.bin/mk -h
will give better help
This app contains four fake services: payments, email, order fulfillment, and an error-catcher (like Bugsnag). Each stores requests in memory and shows that in a basic UI when you run the app.
The purpose of these existing at all is to have a real networked service the sample app can connect to and provide a way to simulate bad behavior of the services. This can be used to simulate failure modes you will encounter.
To simulate bad behavior, use these headers when making requests:
X-Be-Slow
- If set to "true", will sleep a random amount of time. If set to a number, will sleep that many seconds.X-Throttle
- If set to "true" will return a 429.X-Crash
- If set to "true" will return a 503 or 504.
Slow can be combined with either Crash or Throttle.
In this directory:
.gitignore
- File of files to ignore in GitDockerfile.dx
- TheDockerfile
used to build an image you can use to run a container to do the development for the app.Dockerfile
- TheDockerfile
used to build an image pushed to DockerHub. This is the image used by the book.Gemfile
andGemfile.lock
- manages Ruby gems needed for the app.README.md
- This fileRakefile
- holds the test task because I could not figure out a better way to run it without Rake.app/
- The app itself, currently just one big file. Take that, Single Responsibility Principle!bin/
- Directory for scripts relevant to running, testing, or developing the app itself.docker-compose.dx.yml
- A Docker Compose file that runs the app.dx/
- Directory for all the shell scripts and files needed to run the dev environment.test/
- Tests for the app.
- Be sure that
Dockerfile
andDockerfile.dx
are consistent - Make sure all tests are passing via
bin/ci
and there are no warnings or other nonsense - Edit
bin/docker-hub/vars
to bump the version bin/docker-hub/build
bin/docker-hub/push
- Edit the sidekiq book's
automation/dev-environment/docker-compose.yml
to use the new version - Tag the repo as the same version in step 3 and push that tag