Skip to content

Commit

Permalink
Merge pull request #28 from RnDAO/feature/discord-scheduled-job
Browse files Browse the repository at this point in the history
Feature/discord scheduled job
  • Loading branch information
cyri113 authored May 30, 2023
2 parents b329b0e + 4a1aeca commit 41b4dd5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/enums/event.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
6 changes: 1 addition & 5 deletions src/interfaces/choreography.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ import { ITransaction } from './transaction.interface';
export interface IChoreography {
name: string;
transactions: ITransaction[];
}

export interface IChoreographyDict {
[key: string]: IChoreography;
}
}
15 changes: 11 additions & 4 deletions src/saga/choreography.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
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 = {
name: 'DISCORD_UPDATE_CHANNELS',
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;
10 changes: 10 additions & 0 deletions src/saga/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
];

0 comments on commit 41b4dd5

Please sign in to comment.