Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
gvdongen committed Jan 22, 2024
1 parent 494d2c5 commit 0c16b05
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 43 deletions.
22 changes: 22 additions & 0 deletions typescript/food-ordering/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
*/.idea/*
*/dist
*/node_modules
*/services/proto/buf.lock
*/services/src/generated

# dependencies
*/.pnp
*/.pnp.js

# testing
/coverage

# production
*/build

*/npm-debug.log*
*/yarn-debug.log*
*/yarn-error.log*

# Local Netlify folder
*/.netlify
2 changes: 1 addition & 1 deletion typescript/food-ordering/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"bundle": "esbuild src/restate-app/app.ts --bundle --minify --sourcemap --platform=node --target=es2020 --outfile=dist/index.js",
"postbundle": "cd dist && zip -r index.zip index.js*",
"app": "node ./dist/app/app.js",
"app": "node ./dist/restaurant/server.js",
"restaurant-app": "node ./dist/restaurant/server.js",
"app-dev": "ts-node-dev --watch src --respawn --transpile-only src/restate-app/app.ts"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions typescript/food-ordering/app/src/restate-app/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as restate from "@restatedev/restate-sdk";
import * as driverDigitalTwin from "./driver-digital-twin";
import * as driverDigitalTwin from "./driver_digital_twin";
import * as driverDeliveryMatcher from "./driver_delivery_matcher";
import * as deliveryManager from "./delivery-manager";
import * as deliveryManager from "./delivery_manager";
import * as orderWorkflow from "./order_workflow";
import * as orderstatus from "./order_status_service";
import * as driverMobileAppSimulator from "./external/driver_mobile_app_sim";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const KAFKA_BOOTSTRAP_SERVERS = process.env.KAFKA_BOOTSTRAP_SERVERS || "localhos
const KAFKA_CONFIG: KafkaConfig = { brokers: [KAFKA_BOOTSTRAP_SERVERS] };
const KAFKA_TOPIC = "driver-updates";

export class KafkaPublisher {
export class Kafka_publisher {

private readonly kafka = new Kafka(KAFKA_CONFIG);
private readonly producer = this.kafka.producer();
private connected = false;

public async send(_ctx: restate.RpcContext, driverId: string, location: Location) {
public async send(driverId: string, location: Location) {
if (!this.connected) {
console.info("Connecting Kafka producer");
await this.producer.connect();
Expand All @@ -26,6 +26,6 @@ export class KafkaPublisher {
}
}

export function getPublisher(): KafkaPublisher {
return new KafkaPublisher();
export function getPublisher(): Kafka_publisher {
return new Kafka_publisher();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as restate from "@restatedev/restate-sdk";
import * as driverDigitalTwin from "./driver-digital-twin";
import * as driverDigitalTwin from "./driver_digital_twin";
import * as driverDeliveryMatcher from "./driver_delivery_matcher";
import * as geo from "./utils/geo";
import {DEMO_REGION, Location, DeliveryInformation, OrderAndPromise, Status} from "./types/types";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as restate from "@restatedev/restate-sdk";
import * as driverDeliveryMatcher from "./driver_delivery_matcher";
import * as deliveryManager from "./delivery-manager";
import * as deliveryManager from "./delivery_manager";
import {DeliveryRequest, DriverStatus, Location} from "./types/types";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
*/

import * as restate from "@restatedev/restate-sdk";
import * as driverDigitalTwin from "../driver-digital-twin";
import * as driverDigitalTwin from "../driver_digital_twin";
import * as geo from "../utils/geo";
import {DEMO_REGION, Location, DeliveryState} from "../types/types";
import { getPublisher } from "../clients/kafka-publisher";
import { getPublisher } from "../clients/kafka_publisher";
import {updateLocation} from "./driver_mobile_app_sim_utils";

/**
Expand Down Expand Up @@ -47,7 +47,7 @@ async function startDriver(ctx: restate.RpcContext, driverId: string) {

const location = await ctx.sideEffect(async () => geo.randomLocation());
ctx.set(CURRENT_LOCATION, location);
await kafkaPublisher.send(ctx, driverId, location);
await kafkaPublisher.send(driverId, location);

ctx.send(driverDigitalTwin.service).setDriverAvailable(driverId, DEMO_REGION);
ctx.send(service).pollForWork(driverId);
Expand Down Expand Up @@ -86,7 +86,7 @@ async function move(ctx: restate.RpcContext, driverId: string) {
const { newLocation, arrived } = updateLocation(currentLocation, nextTarget);

ctx.set(CURRENT_LOCATION, newLocation);
await kafkaPublisher.send(ctx, driverId, currentLocation);
await kafkaPublisher.send(driverId, currentLocation);

if (arrived) {
if (assignedDelivery.orderPickedUp) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as restate from "@restatedev/restate-sdk";
import * as deliveryManager from "./delivery-manager";
import * as deliveryManager from "./delivery_manager";
import {Order, Status} from "./types/types";
import * as orderstatus from "./order_status_service";
import { completed } from "./utils/utils";
Expand Down
2 changes: 1 addition & 1 deletion typescript/food-ordering/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ services:
- RESTATE_RUNTIME_ENDPOINT=http://runtime:8080

runtime:
image: docker.io/restatedev/restate:latest
image: docker.io/restatedev/restate:0.7
depends_on:
- restate_app
- restaurant_pos
Expand Down
28 changes: 0 additions & 28 deletions typescript/food-ordering/webui/.gitignore

This file was deleted.

0 comments on commit 0c16b05

Please sign in to comment.