@omnixal/openclaw-nats-plugin 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Controller, Get, Post, Patch, Delete,
|
|
3
3
|
Body, Param, BaseController,
|
|
4
|
-
UseMiddleware, Subscribe,
|
|
4
|
+
UseMiddleware, Subscribe, OnQueueReady,
|
|
5
5
|
type Message,
|
|
6
6
|
type OneBunResponse,
|
|
7
7
|
} from '@onebun/core';
|
|
@@ -16,6 +16,11 @@ export class SchedulerController extends BaseController {
|
|
|
16
16
|
super();
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
@OnQueueReady()
|
|
20
|
+
async onQueueReady(): Promise<void> {
|
|
21
|
+
await this.scheduler.restoreJobs();
|
|
22
|
+
}
|
|
23
|
+
|
|
19
24
|
@Post()
|
|
20
25
|
async createJob(@Body(createCronBodySchema) body: CreateCronBody): Promise<OneBunResponse> {
|
|
21
26
|
if (!body.subject.startsWith('agent.events.')) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Service, BaseService, QueueService
|
|
1
|
+
import { Service, BaseService, QueueService } from '@onebun/core';
|
|
2
2
|
import { SchedulerRepository } from './scheduler.repository';
|
|
3
3
|
import { PublisherService } from '../publisher/publisher.service';
|
|
4
4
|
import { ulid } from 'ulid';
|
|
@@ -12,7 +12,7 @@ interface AddJobInput {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
@Service()
|
|
15
|
-
export class SchedulerService extends BaseService
|
|
15
|
+
export class SchedulerService extends BaseService {
|
|
16
16
|
constructor(
|
|
17
17
|
private repo: SchedulerRepository,
|
|
18
18
|
private queueService: QueueService,
|
|
@@ -25,7 +25,7 @@ export class SchedulerService extends BaseService implements OnModuleInit {
|
|
|
25
25
|
return this.queueService.getScheduler();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async
|
|
28
|
+
async restoreJobs(): Promise<void> {
|
|
29
29
|
const jobs = await this.repo.findAllEnabled();
|
|
30
30
|
for (const job of jobs) {
|
|
31
31
|
this.scheduler.addCronJob(
|