Skip to content

Commit

Permalink
Add WorkflowHostname configuration and update WorkflowService to use it
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed Sep 18, 2024
1 parent 7d3f7ba commit 1a15cb3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Common/Server/EnvironmentConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ export const WorkerHostname: Hostname = Hostname.fromString(
}`,
);

export const WorkflowHostname: Hostname = Hostname.fromString(
`${process.env["SERVER_WORKFLOW_HOSTNAME"] || "localhost"}:${
process.env["WORKFLOW_PORT"] || 80
}`,
);

export const HomeHostname: Hostname = Hostname.fromString(
`${process.env["SERVER_HOME_HOSTNAME"] || "localhost"}:${
process.env["HOME_PORT"] || 80
Expand Down
11 changes: 8 additions & 3 deletions Common/Server/Services/WorkflowService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppApiHostname } from "../EnvironmentConfig";
import { WorkflowHostname } from "../EnvironmentConfig";
import ClusterKeyAuthorization from "../Middleware/ClusterKeyAuthorization";
import { OnUpdate } from "../Types/Database/Hooks";
import DatabaseService from "./DatabaseService";
Expand All @@ -15,6 +15,7 @@ import {
} from "../../Types/Workflow/Component";
import API from "Common/Utils/API";
import Model from "Common/Models/DatabaseModels/Workflow";
import logger from "../Utils/Logger";

export class Service extends DatabaseService<Model> {
public constructor() {
Expand Down Expand Up @@ -63,18 +64,22 @@ export class Service extends DatabaseService<Model> {
});
}

logger.debug("Updating workflow on the workflow service");

await API.post<EmptyResponseData>(
new URL(
Protocol.HTTP,
AppApiHostname,
new Route("/api/workflow/update/" + onUpdate.updateBy.query._id!),
WorkflowHostname,
new Route("/workflow/update/" + onUpdate.updateBy.query._id!),
),
{},
{
...ClusterKeyAuthorization.getClusterKeyHeaders(),
},
);

logger.debug("Updated workflow on the workflow service");

return onUpdate;
}
}
Expand Down

0 comments on commit 1a15cb3

Please sign in to comment.