Skip to content

Commit

Permalink
chore: update the docker compose sample to run properly on clusters (#88
Browse files Browse the repository at this point in the history
)

Signed-off-by: Harikrishnan Balagopal <[email protected]>
  • Loading branch information
HarikrishnanBalagopal authored Jan 8, 2022
1 parent 5b6532f commit b265395
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 55 deletions.
Binary file modified samples/docker-compose.zip
Binary file not shown.
51 changes: 0 additions & 51 deletions samples/docker-compose/m2kqacache.yaml

This file was deleted.

4 changes: 3 additions & 1 deletion samples/docker-compose/multiple-services/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import url from 'url';
import http from 'http';
import redis from "redis"

const api_endpoint = '/fib';
const api_endpoint = '/api/fib';
const usage_instructions = `usage: ${api_endpoint}?n=<your number>\n`;
const client = 'REDIS_URL' in process.env ? redis.createClient(process.env.REDIS_URL) : redis.createClient();
client.on("error", err => console.error(err));
Expand Down Expand Up @@ -30,6 +30,8 @@ function requestHandler(req, res) {
else console.error("failed to cache the answer for n. error:", err)
});
} else {
// ans returned by redis is a string
ans = parseInt(ans, 10);
console.log(`CACHE HIT for n = ${n} ans is ${ans}`);
}
res.writeHead(200, { "Content-Type": "application/json" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ services:
ports:
- "8080:80"
environment:
- API_URL=http://api:1234/fib
- API_URL=http://api:1234/api
4 changes: 2 additions & 2 deletions samples/docker-compose/multiple-services/web/fib.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<body>
<h1>Answer</h1>
<p><?php
$api_url = "http://api:1234/fib?n=";
$api_url = "http://api:1234/api/fib?n=";
$new_url = getenv("API_URL");
if ($new_url) $api_url = $new_url . "?n=";
if ($new_url) $api_url = $new_url . "/fib?n=";

$n = $_GET["n"];
if (ctype_digit($n)) {
Expand Down

0 comments on commit b265395

Please sign in to comment.