mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-17 18:05:42 +02:00
Worker fixes (#10562)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -65,6 +65,7 @@ import { getContextValue } from '@hcengineering/server-process-resources'
|
||||
import { createCollaboratorClient } from './collaborator'
|
||||
import { isError } from './errors'
|
||||
import { getClient, releaseClient, SERVICE_NAME } from './utils'
|
||||
import config from './config'
|
||||
|
||||
const activeExecutions = new Set<Ref<Execution>>()
|
||||
|
||||
@@ -634,7 +635,7 @@ async function setNextTimers (control: ProcessControl, execution: Execution): Pr
|
||||
|
||||
async function cleanTimers (control: ProcessControl, execution: Execution): Promise<void> {
|
||||
try {
|
||||
const queue = getPlatformQueue(SERVICE_NAME)
|
||||
const queue = getPlatformQueue(SERVICE_NAME, config.QueueRegion)
|
||||
const producer = queue.getProducer<TimeMachineMessage>(control.ctx, QueueTopic.TimeMachine)
|
||||
await producer.send(control.ctx, control.workspace, [
|
||||
{
|
||||
@@ -652,7 +653,7 @@ async function setTimer (control: ProcessControl, execution: Execution, transiti
|
||||
const targetDate: number = filled.value
|
||||
if (targetDate === undefined || typeof targetDate !== 'number' || targetDate === 0 || Number.isNaN(targetDate)) return
|
||||
try {
|
||||
const queue = getPlatformQueue(SERVICE_NAME)
|
||||
const queue = getPlatformQueue(SERVICE_NAME, config.QueueRegion)
|
||||
const producer = queue.getProducer<TimeMachineMessage>(control.ctx, QueueTopic.TimeMachine)
|
||||
|
||||
const data: ProcessMessage = {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { MeasureMetricsContext, type WorkspaceUuid } from '@hcengineering/core'
|
||||
import { getPlatformQueue } from '@hcengineering/kafka'
|
||||
import config from './config'
|
||||
|
||||
export async function SendTimeEvent (
|
||||
ctx: MeasureMetricsContext,
|
||||
@@ -8,7 +9,7 @@ export async function SendTimeEvent (
|
||||
data: any
|
||||
): Promise<void> {
|
||||
const SERVICE_NAME = 'time-machine'
|
||||
const queue = getPlatformQueue(SERVICE_NAME)
|
||||
const queue = getPlatformQueue(SERVICE_NAME, config.QueueRegion)
|
||||
|
||||
const producer = queue.getProducer<any>(ctx, topic as any)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ export async function runWorker (): Promise<void> {
|
||||
const db = await TimeMachineDB.init(config.DbUrl)
|
||||
|
||||
const ctx = new MeasureMetricsContext(SERVICE_NAME, {})
|
||||
const queue = getPlatformQueue(SERVICE_NAME)
|
||||
const queue = getPlatformQueue(SERVICE_NAME, config.QueueRegion)
|
||||
|
||||
// 1. Kafka Consumer for commands
|
||||
queue.createConsumer<TimeMachineMessage>(ctx, QueueTopic.TimeMachine, SERVICE_NAME, async (ctx, msg) => {
|
||||
|
||||
Reference in New Issue
Block a user