restatedev / examples

Restate examples
https://restate.dev
MIT License
45 stars 9 forks source link

Update Deno Example to Match TypeScript QuickStart Pathing #158

Closed y12studio closed 4 months ago

y12studio commented 4 months ago

The Deno example uses /greeter/greet, while the TypeScript QuickStart example uses /Greeter/greet.

To improve the onboarding experience for new users, it would be helpful to keep these examples consistent. Using the same path format in both the Deno example and the TypeScript QuickStart would make it easier for beginners to follow along.

https://docs.restate.dev/get_started/quickstart/?sdk=ts

$ docker compose up
restate_dev-1  | 2024-07-06T12:04:37.977889Z INFO restate_server
restate_dev-1  |   Starting Restate Server 1.0.2 (604592b x86_64-unknown-linux-gnu 2024-06-20)
restate_dev-1  |     node_name: "0d3166802d27"
restate_dev-1  |     config_source: [default]
restate_dev-1  |     base_dir: /restate-data/0d3166802d27/
app-1          | Hit:1 http://deb.debian.org/debian stable InRelease
app-1          | Hit:2 http://deb.debian.org/debian stable-updates InRelease
app-1          | Hit:3 http://deb.debian.org/debian-security stable-security InRelease
app-1          | Reading package lists...
app-1          | Reading package lists...
app-1          | Building dependency tree...
app-1          | Reading state information...
app-1          | busybox is already the newest version (1:1.35.0-4+b3).
app-1          | 0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
app-1          | Connecting to raw.githubusercontent.com (185.199.110.133:443)
app-1          | wget: note: TLS certificate validation not implemented
app-1          | wget: can't open 'deno.jsonc': File exists
app-1          | Connecting to raw.githubusercontent.com (185.199.108.133:443)
app-1          | wget: note: TLS certificate validation not implemented
app-1          | wget: can't open 'main.ts': File exists
app-1          | Task start deno run --allow-net --allow-env main.ts
app-1          | [restate] [2024-07-06T12:04:39.994Z] WARN:  Accepting requests without validating request signatures; worker access must be restricted
app-1          | Listening on http://localhost:9080/
restate_dev-1  | 2024-07-06T12:04:40.553173Z INFO restate_grpc_util
restate_dev-1  |   Server 'metadata-store-grpc' listening
restate_dev-1  |     net.host.addr: 0.0.0.0
restate_dev-1  |     net.host.port: 5123
restate_dev-1  | 2024-07-06T12:04:41.226494Z INFO restate_node
restate_dev-1  |   My Node ID is N0:2
restate_dev-1  | 2024-07-06T12:04:41.270326Z INFO restate_ingress_http::server
restate_dev-1  |   Ingress HTTP listening
restate_dev-1  |     net.host.addr: 0.0.0.0
restate_dev-1  |     net.host.port: 8080
restate_dev-1  | 2024-07-06T12:04:41.270477Z INFO restate_network::networking
restate_dev-1  |   Connection to node N0:2 failed with cannot connect: The service is currently unavailable error trying to connect: tcp connect error: Connection refused (os error 111), next retry is attempt 2/10
restate_dev-1  |   in restate_network::networking::send
restate_dev-1  |     to: N0
restate_dev-1  |     msg: GetProcessorsStateRequest
restate_dev-1  | 2024-07-06T12:04:41.270956Z INFO restate_grpc_util
restate_dev-1  |   Server 'node-grpc' listening
restate_dev-1  |     net.host.addr: 0.0.0.0
restate_dev-1  |     net.host.port: 5122
restate_dev-1  | 2024-07-06T12:04:41.270979Z INFO restate_admin::service
restate_dev-1  |   Admin API listening
restate_dev-1  |     net.host.addr: 0.0.0.0
restate_dev-1  |     net.host.port: 9070
restate_dev-1  | 2024-07-06T12:04:41.834568Z INFO restate_worker::partition_processor_manager
restate_dev-1  |   Plan applied from attaching to controller N0:2
curl-1         | {"message":"Invalid path: path doesn't end in /invoke/SvcName/handlerName and also not in /discover: http://app:9080/"} == Info: Host restate_dev:9070 was resolved.
curl-1         | == Info: IPv6: (none)
curl-1         | == Info: IPv4: 172.25.0.2
curl-1         | == Info:   Trying 172.25.0.2:9070...
curl-1         | == Info: Connected to restate_dev (172.25.0.2) port 9070
curl-1         | => Send header, 143 bytes (0x8f)
curl-1         | 0000: POST /deployments HTTP/1.1
curl-1         | 001c: Host: restate_dev:9070
curl-1         | 0034: User-Agent: curl/8.8.0
curl-1         | 004c: Accept: */*
curl-1         | 0059: content-type: application/json
curl-1         | 0079: Content-Length: 26
curl-1         | 008d: 
curl-1         | => Send data, 26 bytes (0x1a)
curl-1         | 0000: {"uri": "http://app:9080"}
restate_dev-1  | 2024-07-06T12:04:47.679385Z INFO restate_admin::schema_registry::updater
restate_dev-1  |   Overwriting existing service schemas
restate_dev-1  |     rpc.service: greeter
curl-1         | == Info: upload completely sent off: 26 bytes
curl-1         | <= Recv header, 22 bytes (0x16)
curl-1         | 0000: HTTP/1.1 201 Created
curl-1         | <= Recv header, 32 bytes (0x20)
curl-1         | 0000: content-type: application/json
curl-1         | <= Recv header, 51 bytes (0x33)
curl-1         | 0000: location: /deployments/dp_10ohzfK7w7QasWxvRWs2vKN
curl-1         | <= Recv header, 21 bytes (0x15)
curl-1         | 0000: content-length: 379
curl-1         | <= Recv header, 37 bytes (0x25)
curl-1         | 0000: date: Sat, 06 Jul 2024 12:04:47 GMT
curl-1         | <= Recv header, 2 bytes (0x2)
curl-1         | 0000: 
curl-1         | <= Recv data, 379 bytes (0x17b)
curl-1         | 0000: {"id":"dp_10ohzfK7w7QasWxvRWs2vKN","services":[{"name":"greeter"
curl-1         | 0040: ,"handlers":[{"name":"greet","ty":"Shared","input_description":"
curl-1         | 0080: one of [\"none\", \"value of content-type 'application/json'\"]"
curl-1         | 00c0: ,"output_description":"value of content-type 'application/json'"
curl-1         | 0100: }],"ty":"Service","deployment_id":"dp_10ohzfK7w7QasWxvRWs2vKN","
curl-1         | 0140: revision":2,"public":true,"idempotency_retention":"1day"}]}
curl-1         | {"id":"dp_10ohzfK7w7QasWxvRWs2vKN","services":[{"name":"greeter","handlers":[{"name":"greet","ty":"Shared","input_description":"one of [\"none\", \"value of content-type 'application/json'\"]","output_description":"value of content-type 'application/json'"}],"ty":"Service","deployment_id":"dp_10ohzfK7w7QasWxvRWs2vKN","revision":2,"public":true,"idempotency_retention":"1day"}]}== Info: Connection #0 to host restate_dev left intact
curl-1         | == Info: Host restate_dev:8080 was resolved.
curl-1         | == Info: IPv6: (none)
curl-1         | == Info: IPv4: 172.25.0.2
curl-1         | == Info:   Trying 172.25.0.2:8080...
curl-1         | == Info: Connected to restate_dev (172.25.0.2) port 8080
curl-1         | => Send header, 144 bytes (0x90)
curl-1         | 0000: POST /Greeter/greet HTTP/1.1
curl-1         | 001e: Host: restate_dev:8080
curl-1         | 0036: User-Agent: curl/8.8.0
curl-1         | 004e: Accept: */*
curl-1         | 005b: content-type: application/json
curl-1         | 007b: Content-Length: 4
curl-1         | 008e: 
curl-1         | => Send data, 4 bytes (0x4)
curl-1         | 0000: "Hi"
curl-1         | == Info: upload completely sent off: 4 bytes
curl-1         | <= Recv header, 24 bytes (0x18)
curl-1         | 0000: HTTP/1.1 404 Not Found
curl-1         | <= Recv header, 32 bytes (0x20)
curl-1         | 0000: content-type: application/json
curl-1         | <= Recv header, 77 bytes (0x4d)
curl-1         | 0000: vary: origin, access-control-request-method, access-control-requ
curl-1         | 0040: est-headers
curl-1         | <= Recv header, 40 bytes (0x28)
curl-1         | 0000: access-control-allow-credentials: true
curl-1         | <= Recv header, 20 bytes (0x14)
curl-1         | 0000: content-length: 23
curl-1         | <= Recv header, 37 bytes (0x25)
curl-1         | 0000: date: Sat, 06 Jul 2024 12:04:48 GMT
curl-1         | <= Recv header, 2 bytes (0x2)
curl-1         | 0000: 
curl-1         | <= Recv data, 23 bytes (0x17)
curl-1         | 0000: {"message":"not found"}
curl-1         | {"message":"not found"}== Info: Connection #0 to host restate_dev left intact

compose.yaml

services:
  app:
    image: denoland/deno:debian-1.44.4
    working_dir: /app
    ports:
      - "9080:9080"
    command:
      - /bin/sh
      - -c
      - |
        apt-get update && apt-get install -y busybox
        busybox wget https://raw.githubusercontent.com/restatedev/examples/main/templates/deno/deno.jsonc
        busybox wget https://raw.githubusercontent.com/restatedev/examples/main/templates/deno/main.ts
        deno task start
  restate_dev:
    image: docker.io/restatedev/restate:1.0
    ports:
      - 8080:8080 
      - 9070:9070 
      - 9071:9071
  curl:
    image: docker.io/curlimages/curl
    command:
      - /bin/sh
      - -c 
      - |
        sleep 5
        curl -s --retry 12 --retry-all-errors http://app:9080
        curl -s http://restate_dev:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://app:9080"}' --trace-ascii -
        sleep 1
        curl -s http://restate_dev:8080/Greeter/greet -H 'content-type: application/json' -d '"Hi"' --trace-ascii -
        sleep 1000