added initial batch decorator and fixed payload - still need to test batching
This commit is contained in:
parent
44c087aaae
commit
eff529a6ca
5 changed files with 57 additions and 6 deletions
|
|
@ -354,6 +354,8 @@ export abstract class BaseHandler implements IHandler {
|
|||
priority: schedule.priority || 5,
|
||||
immediately: schedule.immediately || false,
|
||||
description: schedule.description || `${handlerName} ${schedule.operation}`,
|
||||
payload: schedule.payload, // Include payload from decorator
|
||||
batch: schedule.batch, // Include batch config from decorator
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,20 @@ export function Handler(name: string) {
|
|||
/**
|
||||
* Operation decorator - marks a method as an operation
|
||||
* @param name Operation name
|
||||
* @param options Optional configuration including batch settings
|
||||
*/
|
||||
export function Operation(name: string): any {
|
||||
export function Operation(
|
||||
name: string,
|
||||
options?: {
|
||||
batch?: {
|
||||
enabled?: boolean;
|
||||
size?: number;
|
||||
delayInHours?: number;
|
||||
priority?: number;
|
||||
direct?: boolean;
|
||||
};
|
||||
}
|
||||
): any {
|
||||
return function (target: any, methodName: string, descriptor?: PropertyDescriptor): any {
|
||||
// Store metadata directly on the class constructor
|
||||
const constructor = target.constructor;
|
||||
|
|
@ -29,6 +41,7 @@ export function Operation(name: string): any {
|
|||
constructor.__operations.push({
|
||||
name,
|
||||
method: methodName,
|
||||
batch: options?.batch,
|
||||
});
|
||||
|
||||
return descriptor;
|
||||
|
|
@ -47,6 +60,13 @@ export function QueueSchedule(
|
|||
immediately?: boolean;
|
||||
description?: string;
|
||||
payload?: any;
|
||||
batch?: {
|
||||
enabled?: boolean;
|
||||
size?: number;
|
||||
delayInHours?: number;
|
||||
priority?: number;
|
||||
direct?: boolean;
|
||||
};
|
||||
}
|
||||
): any {
|
||||
return function (target: any, methodName: string, descriptor?: PropertyDescriptor): any {
|
||||
|
|
@ -94,11 +114,18 @@ export function ScheduledOperation(
|
|||
immediately?: boolean;
|
||||
description?: string;
|
||||
payload?: any;
|
||||
batch?: {
|
||||
enabled?: boolean;
|
||||
size?: number;
|
||||
delayInHours?: number;
|
||||
priority?: number;
|
||||
direct?: boolean;
|
||||
};
|
||||
}
|
||||
): any {
|
||||
return function (target: any, methodName: string, descriptor?: PropertyDescriptor): any {
|
||||
// Apply both decorators
|
||||
Operation(name)(target, methodName, descriptor);
|
||||
// Apply both decorators with batch configuration
|
||||
Operation(name, { batch: options?.batch })(target, methodName, descriptor);
|
||||
QueueSchedule(cronPattern, options)(target, methodName, descriptor);
|
||||
return descriptor;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue