diff --git a/README.md b/README.md index ac727462a933b0213b3df73fdec487f23f95eb01..4b54d1054a16687e313f53ac62da386e9bc00d9e 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,23 @@ $ curl 127.0.0.1:5002/showtimes/20151130 ``` Try your best to solve it. If you need hints, you will find the solution for this in the branch `simpleservices`, which you can obtain by running `git checkout simpleservices`. Note that after checking out this branch, you will have to start both the `movies` and `showtimes` microservices and then issue the curl request. The showtimes microservice will talk to movies microservice to deliver the final result. +The main change needed is simple. We just have to issue an HTTP GET request to the movies API endpoint. We do this by changing `showtime_record` as follows: +```python +movies_service = "http://127.0.0.1:5001/movies/{}" #we know this is where the service is running. We replace the {} with the actual ID of the movie we want. + +def showtimes_record(date): + if date not in showtimes: + raise NotFound + print(showtimes[date]) + result = [] + for movie_id in showtimes[date]: + resp = requests.get(movies_service.format(movie_id)) + result.append(resp.json()["title"]) + return nice_json(result) +``` ## Step 3: Dockerization of microservices +> We now have two microservices running on _localhost_ and talking to each other. If we need to move these services, it is not easy. +> Your next task is to wrap these microservices as a docker image and make them portable. Essentially, this involves specifying all the dependencies and running parameters explicitly in a `Dockerfile`. You can have a go at this by copying from this [tutorial](https://www.docker.com/blog/containerized-python-development-part-1/). Or, switch to the `dockerservices` branch where you will find the solution for steps 3 and 4. ## Step 4: How to make two dockerized microservices talk to each other