Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update port numbers #31

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Have a look at how to start up the runtime in a Docker container in [this reposi

- For MacOS:
```shell
docker run --name restate_dev --rm -p 8081:8081 -p 9091:9091 -p 9090:9090 -p 5432:5432 ghcr.io/restatedev/restate-dist:latest
docker run --name restate_dev --rm -p 8080:8080 -p 9070:9070 -p 9071:9071 ghcr.io/restatedev/restate-dist:latest
```
- For Linux:
```shell
Expand All @@ -47,11 +47,11 @@ Once the runtime is up, let it discover the services of the examples by executin

- For MacOS:
```shell
curl -X POST http://localhost:8081/endpoints -H 'content-type: application/json' -d '{"uri": "http://host.docker.internal:8080"}'
curl -X POST http://localhost:9070/endpoints -H 'content-type: application/json' -d '{"uri": "http://host.docker.internal:9080"}'
```
- For Linux:
```shell
curl -X POST http://localhost:8081/endpoints -H 'content-type: application/json' -d '{"uri": "http://localhost:8080"}'
curl -X POST http://localhost:9070/endpoints -H 'content-type: application/json' -d '{"uri": "http://localhost:9080"}'
```

This should give you the following output in case of the ticket reservation example:
Expand Down
2 changes: 1 addition & 1 deletion typescript/ecommerce-store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Local deployment doesn't use a pre-filled database, so you need to manually fill

```shell
cd deployment/local
./init_state.sh "localhost:9090"
./init_state.sh "localhost:8080"
```

Go to http://localhost:3000 to see the UI and buy some products.
Expand Down
2 changes: 1 addition & 1 deletion typescript/ecommerce-store/deployment/aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ssh -i shopping-demo-key.pem -L 5050:pgadmin.shopping-cart-demo:5050 -L 16686:ja
Then discover the services from within the ssh session:

```shell
curl -X POST http://restate-runtime.shopping-cart-demo:8081/endpoints -H 'content-type: application/json' -d '{"uri": "http://shopping-services.shopping-cart-demo:8080"}'
curl -X POST http://restate-runtime.shopping-cart-demo:9070/endpoints -H 'content-type: application/json' -d '{"uri": "http://shopping-services.shopping-cart-demo:8080"}'
```

This prints out the services were discovered by the Restate runtime.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ resource "aws_ecs_task_definition" "webapp" {
environment = [
{
name = "REACT_APP_RESTATE_HOST",
value = "http://localhost:9090"
value = "http://localhost:8080"
},
{
name = "REACT_APP_DATABASE_ENABLED",
Expand Down
4 changes: 2 additions & 2 deletions typescript/ecommerce-store/deployment/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ variable "service_desired_count" {

variable "restate_runtime_ingress_port" {
description = "The port of the restate runtime ingress endpoint"
default = 9090
default = 8080
}

variable "restate_runtime_discovery_port" {
description = "The port of the restate runtime to register service endpoints"
default = 8081
default = 9070
}

variable "webapp_port" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ version: "3.3"
services:
services:
image: dev.local/shopping-cart/services:0.0.1
ports:
- "8080:8080"
environment:
- DATABASE_ENABLED=true
- RESTATE_DEBUG_LOGGING=JOURNAL_VERBOSE
Expand All @@ -22,8 +20,8 @@ services:
- services
- jaeger
ports:
- "9090:9090"
- "8081:8081"
- "8080:8080"
- "9070:9070"
environment:
- RUST_LOG=info,restate=debug
- RESTATE_OBSERVABILITY__TRACING__ENDPOINT=http://jaeger:4317
Expand All @@ -34,7 +32,7 @@ services:
- runtime
- services
restart: "no"
entrypoint: ["sh", "-c", "sleep 5 && curl -X POST 'runtime:8081/endpoints' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}' || exit 1"]
entrypoint: ["sh", "-c", "sleep 5 && curl -X POST 'runtime:9070/endpoints' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}' || exit 1"]

db:
image: 'postgres:15.0-alpine'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ services:
environment:
- RESTATE_DEBUG_LOGGING=JOURNAL_VERBOSE
- DATABASE_ENABLED=false
ports:
- "8080:8080"

jaeger:
image: jaegertracing/all-in-one:1.47
Expand All @@ -22,8 +20,8 @@ services:
- services
- jaeger
ports:
- "9090:9090"
- "8081:8081"
- "8080:8080"
- "9070:9070"
environment:
- RUST_LOG=info,restate=debug
- RESTATE_OBSERVABILITY__TRACING__ENDPOINT=http://jaeger:4317
Expand All @@ -38,7 +36,7 @@ services:
- ../local/:/scripts
- ../data/:/data
entrypoint: ["sh", "-c", "sleep 5 && apk add --no-cache bash jq curl &&
curl -X POST 'runtime:8081/endpoints' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}' &&
curl -X POST 'runtime:9070/endpoints' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}' &&
sleep 3 && cd /scripts && chmod +x init_state.sh && ./init_state.sh runtime:9090
|| exit 1"]

Expand Down
6 changes: 3 additions & 3 deletions typescript/ecommerce-store/deployment/knative/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ You can visit the web app at http://localhost:3000
6. Forwards the ports of the Restate runtime:

```shell
kubectl port-forward -n shopping-cart svc/restate-runtime 8081:8081 9090:9090
kubectl port-forward -n shopping-cart svc/restate-runtime 8080:8080 9070:9070
```

7. Execute the service discovery:

```shell
curl -X POST http://localhost:8081/endpoint/discover -H 'content-type: application/json' -d '{"uri": "http://services.shopping-cart.svc.cluster.local"}'
curl -X POST http://localhost:9070/endpoint/discover -H 'content-type: application/json' -d '{"uri": "http://services.shopping-cart.svc.cluster.local"}'
```

8. Fill the state of the product service with a list of products:
```shell
cd deployment/local && ./init_state.sh "localhost:9090" && cd -
cd deployment/local && ./init_state.sh "localhost:8080" && cd -
```

6. Watch pods of the application
Expand Down
12 changes: 6 additions & 6 deletions typescript/ecommerce-store/deployment/knative/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ spec:
image: ghcr.io/restatedev/restate-dist:latest
imagePullPolicy: Never
ports:
- containerPort: 9090
- containerPort: 8080
name: grpc
- containerPort: 8081
- containerPort: 9070
name: meta

---
Expand All @@ -36,13 +36,13 @@ spec:
app: restate-runtime
ports:
- name: grpc
port: 9090
port: 8080
protocol: TCP
targetPort: 9090
targetPort: 8080
- name: meta
port: 8081
port: 9070
protocol: TCP
targetPort: 8081
targetPort: 9070

---
apiVersion: apps/v1
Expand Down
2 changes: 1 addition & 1 deletion typescript/ecommerce-store/deployment/local/init_state.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
export RESTATE_HOST=${1:-localhost:9090}
export RESTATE_HOST=${1:-localhost:8080}
jq -c '.data.products[]' ../data/products.json | while read i; do
id=$(echo $i | jq -r '.id')
quantity=$(echo $i | jq -r '.installments')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';

export const grpc = async (service: string, method: string, data: any) => {
const RESTATE_HOST = process.env.REACT_APP_RESTATE_HOST || "http://localhost:9090"
const RESTATE_HOST = process.env.REACT_APP_RESTATE_HOST || "http://localhost:8080"
return await (await axios.post(`${RESTATE_HOST}/io.shoppingcart.${service}/${method}`, data)).data;
};
1 change: 1 addition & 0 deletions typescript/ecommerce-store/services/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN npm run build

ENV NODE_ENV production

ENV PORT 8080
EXPOSE 8080
USER node
CMD ["dumb-init", "node", "./dist/app.js"]
2 changes: 1 addition & 1 deletion typescript/ecommerce-store/services/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ if (process.env.DATABASE_ENABLED === "true") {
});
}

restateServer.listen(8080);
restateServer.listen();
6 changes: 3 additions & 3 deletions typescript/food-ordering/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Create a new order for five cheeseburgers at `FastFood123` with immediate delive
You can do this via curl:

```shell
curl -X POST http://localhost:9090/OrderService/createOrder -H 'content-type: application/json' -d '{
curl -X POST http://localhost:8080/OrderService/createOrder -H 'content-type: application/json' -d '{
"key": "134",
"request": {"restaurantId": "FastFood123", "deliveryDelay": 0, "items": [{"productName": "cheeseburger", "quantity": 5}]}
}'
Expand All @@ -86,7 +86,7 @@ curl -X POST http://localhost:9090/OrderService/createOrder -H 'content-type: ap
Create a new order for five cheeseburgers at `FastFood123` with delivery delayed for 10 seconds:

```shell
curl -X POST http://localhost:9090/OrderService/createOrder -H 'content-type: application/json' -d '{
curl -X POST http://localhost:8080/OrderService/createOrder -H 'content-type: application/json' -d '{
"key": "174",
"request": {"restaurantId": "FastFood123", "deliveryDelay": 10000, "items": [{"productName": "cheeseburger", "quantity": 5}]}
}'
Expand All @@ -95,7 +95,7 @@ curl -X POST http://localhost:9090/OrderService/createOrder -H 'content-type: ap
You can also check the status of the delivery via:

```shell
curl -X POST http://localhost:9090/OrderService/getOrderStatus -H 'content-type: application/json' -d '{ "key": "174" }'
curl -X POST http://localhost:8080/OrderService/getOrderStatus -H 'content-type: application/json' -d '{ "key": "174" }'
```

To understand the requests that are done, you can have a look at the logs of the runtime, service and PoS server.
Expand Down
12 changes: 5 additions & 7 deletions typescript/food-ordering/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ services:
environment:
- RESTATE_DEBUG_LOGGING=JOURNAL_VERBOSE
- POS_ENDPOINT=http://pos_server:5050
ports:
- "8080:8080"

jaeger:
image: jaegertracing/all-in-one:1.47
Expand All @@ -23,8 +21,8 @@ services:
- services
- jaeger
ports:
- "9090:9090"
- "8081:8081"
- "8080:8080"
- "9070:9070"
environment:
- RESTATE_OBSERVABILITY__TRACING__ENDPOINT=http://jaeger:4317

Expand All @@ -35,7 +33,7 @@ services:
- services
restart: "no"
entrypoint: ["sh", "-c", "sleep 5 && apk add --no-cache bash jq curl &&
curl -X POST 'runtime:8081/endpoints' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}'
curl -X POST 'runtime:9070/endpoints' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}'
|| exit 1"]

grpcui:
Expand All @@ -45,13 +43,13 @@ services:
depends_on:
runtimesetup:
condition: service_completed_successfully
entrypoint: ["/bin/grpcui", "-bind=0.0.0.0", "-port=3030", "-plaintext", "runtime:9090"]
entrypoint: ["/bin/grpcui", "-bind=0.0.0.0", "-port=3030", "-plaintext", "runtime:8080"]

pos_server:
image: dev.local/food-ordering/pos_server:0.0.1
depends_on:
- runtimesetup
environment:
- RESTATE_RUNTIME_ENDPOINT=http://runtime:9090
- RESTATE_RUNTIME_ENDPOINT=http://runtime:8080
ports:
- "5050:5050"
2 changes: 1 addition & 1 deletion typescript/food-ordering/pos_server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import axios from "axios";
*/

const RESTATE_RUNTIME_ENDPOINT =
process.env.RESTATE_RUNTIME_ENDPOINT || "http://localhost:9090";
process.env.RESTATE_RUNTIME_ENDPOINT || "http://localhost:8080";

const app = express();
const port = 5050;
Expand Down
1 change: 1 addition & 0 deletions typescript/food-ordering/services/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm prune --omit=dev
ENV NODE_ENV production

EXPOSE 8080
ENV PORT 8080
USER node
CMD ["dumb-init", "node", "./dist/app.js"]
2 changes: 1 addition & 1 deletion typescript/food-ordering/services/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ import { orderApi, orderService } from "./order_service";
restate
.createServer()
.bindKeyedRouter(orderApi.path, orderService)
.listen(8080);
.listen();
4 changes: 2 additions & 2 deletions typescript/payment-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ Now [launch the runtime](../../README.md#launching-the-runtime) and [discover th
Make a sample payment. The 'key' parameter is the idempotency token.

```shell
curl -X POST localhost:9090/payments/makePayment -H 'content-type: application/json' -d '{"key": "some-string-id", "request": { "accountId": "abc", "amount": 100 } }'
curl -X POST localhost:8080/payments/makePayment -H 'content-type: application/json' -d '{"key": "some-string-id", "request": { "accountId": "abc", "amount": 100 } }'
```

Cancel a payment. The 'key' parameter is the idempotency token, there is no further request data.

```shell
curl -X POST localhost:9090/payments/cancelPayment -H 'content-type: application/json' -d '{"key": "some-string-id"}'
curl -X POST localhost:8080/payments/cancelPayment -H 'content-type: application/json' -d '{"key": "some-string-id"}'
```
2 changes: 1 addition & 1 deletion typescript/payment-api/src/payment_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ restate
.createServer()
.bindKeyedRouter("payments", rounter)
.bindKeyedRouter("accounts", accounts.router)
.listen(8080);
.listen();

// ----------------------------------------------------------------------------
// miscellaneous utils
Expand Down
4 changes: 2 additions & 2 deletions typescript/ticket-reservation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Now [launch the runtime](../../README.md#launching-the-runtime) and [discover th
We can now invoke the `addTicket` method of the user session service by executing:

```shell
curl -X POST http://localhost:9090/UserSession/addTicket -H 'content-type: application/json' -d '{"key": "user_1", "request": "Rolling-stones-A22"}'
curl -X POST http://localhost:8080/UserSession/addTicket -H 'content-type: application/json' -d '{"key": "user_1", "request": "Rolling-stones-A22"}'
```

The first time, this should give us `true` back. The second time, it returns `false`
Expand All @@ -109,7 +109,7 @@ because a single seat cannot be reserved twice.
Now let user `user_1` buy the ticket by calling the `checkout` method of the user session service:

```shell
curl -X POST http://localhost:9090/UserSession/checkout -H 'content-type: application/json' -d '{"key": "user_1"}'
curl -X POST http://localhost:8080/UserSession/checkout -H 'content-type: application/json' -d '{"key": "user_1"}'
```

That's it! We managed to run the example, add a ticket to the user session cart, and buy it!
2 changes: 1 addition & 1 deletion typescript/ticket-reservation/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ restate
.bindKeyedRouter(userSessionApi.path, userSessionRouter)
.bindKeyedRouter(ticketDbApi.path, ticketDbRouter)
.bindRouter(checkoutApi.path, checkoutRouter)
.listen(8080);
.listen();