-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[connectors] Add a worker for Zendesk workflows (#8343)
* feat: add a worker and start it * set the workflow version to 0 * fix: fix imports in the workflow (activities were imported) * feat: remove the sleep as this workflow is a cron one * fix: copy paste the assertNever function since the types module cannot be imported in a workflow * chore: remove an unused config parameter * fix: use temporal's assertNever instead of a custom one
- Loading branch information
1 parent
5b27a5b
commit 43c97dc
Showing
6 changed files
with
58 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export const WORKFLOW_VERSION = 3; | ||
export const WORKFLOW_VERSION = 0; | ||
export const QUEUE_NAME = `zendesk-queue-v${WORKFLOW_VERSION}`; | ||
export const INTERVAL_BETWEEN_SYNCS_MS = 60_000; // 1 minute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { Context } from "@temporalio/activity"; | ||
import { Worker } from "@temporalio/worker"; | ||
import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin"; | ||
|
||
import { getTemporalWorkerConnection } from "@connectors/lib/temporal"; | ||
import { ActivityInboundLogInterceptor } from "@connectors/lib/temporal_monitoring"; | ||
import logger from "@connectors/logger/logger"; | ||
|
||
import * as activities from "./activities"; | ||
import { QUEUE_NAME } from "./config"; | ||
|
||
export async function runZendeskWorker() { | ||
const { connection, namespace } = await getTemporalWorkerConnection(); | ||
const worker = await Worker.create({ | ||
workflowsPath: require.resolve("./workflows"), | ||
activities, | ||
taskQueue: QUEUE_NAME, | ||
connection, | ||
reuseV8Context: true, | ||
namespace, | ||
maxConcurrentActivityTaskExecutions: 16, | ||
interceptors: { | ||
activityInbound: [ | ||
(ctx: Context) => { | ||
return new ActivityInboundLogInterceptor(ctx, logger); | ||
}, | ||
], | ||
}, | ||
bundlerOptions: { | ||
webpackConfigHook: (config) => { | ||
const plugins = config.resolve?.plugins ?? []; | ||
config.resolve!.plugins = [...plugins, new TsconfigPathsPlugin({})]; | ||
return config; | ||
}, | ||
}, | ||
}); | ||
|
||
await worker.run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters