From 89567044d16600f1b58291ce9f62182d11428d4b Mon Sep 17 00:00:00 2001 From: Mohammad Twin Date: Tue, 30 May 2023 13:13:39 +0400 Subject: [PATCH 1/3] feat: discord scheduled job was added --- src/enums/event.enum.ts | 2 ++ src/saga/transaction.ts | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/enums/event.enum.ts b/src/enums/event.enum.ts index d79559f..4c54865 100644 --- a/src/enums/event.enum.ts +++ b/src/enums/event.enum.ts @@ -8,6 +8,8 @@ enum BotEvent { // events that will be used in all ANALYTIC microservices enum AnalyzerEvent { RUN = 'RUN', + RUN_ONCE = 'RUN_ONCE', + SAVE = 'SAVE', } const ServerEvent = { diff --git a/src/saga/transaction.ts b/src/saga/transaction.ts index b95a96c..ddadab2 100644 --- a/src/saga/transaction.ts +++ b/src/saga/transaction.ts @@ -32,3 +32,13 @@ export const DISCORD_UPDATE_CHANNELS_TRANSACTIONS: ITransaction[] = [ // ...DEFAULT_TRANSACTION_PROPERTY, // }, ]; + +export const DISCORD_SCHEDULED_JOB_TRANSACTIONS: ITransaction[] = [ + { + queue: Queue.DISCORD_ANALYZER, + event: Event.DISCORD_ANALYZER.RUN_ONCE, + order: 1, + status: Status.NOT_STARTED, + ...DEFAULT_TRANSACTION_PROPERTY, + }, +]; From cbe1000589b995fc964961423f1c4e1a11f79886 Mon Sep 17 00:00:00 2001 From: Mohammad Twin Date: Tue, 30 May 2023 13:17:02 +0400 Subject: [PATCH 2/3] feat: new choreography was added fix: don't new to have interface for ChoreographyDict --- src/interfaces/choreography.interface.ts | 6 +----- src/saga/choreography.ts | 15 +++++++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/interfaces/choreography.interface.ts b/src/interfaces/choreography.interface.ts index 3cf1e84..f7865ef 100644 --- a/src/interfaces/choreography.interface.ts +++ b/src/interfaces/choreography.interface.ts @@ -3,8 +3,4 @@ import { ITransaction } from './transaction.interface'; export interface IChoreography { name: string; transactions: ITransaction[]; -} - -export interface IChoreographyDict { - [key: string]: IChoreography; -} +} \ No newline at end of file diff --git a/src/saga/choreography.ts b/src/saga/choreography.ts index 72e8ede..56f399b 100644 --- a/src/saga/choreography.ts +++ b/src/saga/choreography.ts @@ -1,5 +1,5 @@ -import { IChoreography, IChoreographyDict } from '../interfaces/choreography.interface'; -import { DISCORD_UPDATE_CHANNELS_TRANSACTIONS } from './transaction'; +import { IChoreography } from '../interfaces/choreography.interface'; +import { DISCORD_SCHEDULED_JOB_TRANSACTIONS, DISCORD_UPDATE_CHANNELS_TRANSACTIONS } from './transaction'; /* define the DISCORD_UPDATE_CHANNELS choreography */ const DISCORD_UPDATE_CHANNELS: IChoreography = { @@ -7,7 +7,14 @@ const DISCORD_UPDATE_CHANNELS: IChoreography = { transactions: DISCORD_UPDATE_CHANNELS_TRANSACTIONS, }; +/* define the DISCORD_SCHEDULED_JOB choreography */ +const DISCORD_SCHEDULED_JOB: IChoreography = { + name: 'DISCORD_SCHEDULED_JOB', + transactions: DISCORD_SCHEDULED_JOB_TRANSACTIONS, +}; + /* all available Choreographies, will grow overtime */ -export const ChoreographyDict: IChoreographyDict = { - DISCORD_UPDATE_CHANNELS: DISCORD_UPDATE_CHANNELS, +export const ChoreographyDict = { + DISCORD_UPDATE_CHANNELS, + DISCORD_SCHEDULED_JOB } as const; From 4a1aeca811d57ba445dabb2aa8f1ea402fe3b31b Mon Sep 17 00:00:00 2001 From: Mohammad Twin Date: Tue, 30 May 2023 13:46:58 +0400 Subject: [PATCH 3/3] version increased --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3062745..f99abd2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@togethercrew.dev/tc-messagebroker", - "version": "0.0.35", + "version": "0.0.36", "description": "a service that include common things that need in every microservies ", "main": "./dist/index.js", "types": "./dist/index.d.ts",