Rename event fulfill to resolve
This commit is contained in:
@@ -179,7 +179,7 @@ export class EventQueue<G extends string, T extends Record<string, EventTypeOpti
|
||||
try {
|
||||
Value.Assert(cfg.schemas.payload, event.payload);
|
||||
await cfg.processor(event.payload, (state) => this.Events.setState(event.id, state), event.id);
|
||||
await this.Events.fulfill(event.id);
|
||||
await this.Events.resolve(event.id);
|
||||
}
|
||||
catch (err) {
|
||||
await this.Events.setLastError(event.id, err);
|
||||
|
||||
@@ -11,7 +11,7 @@ export const EventStatusSchema = t.Union([
|
||||
t.Literal("available"),
|
||||
t.Literal("processing"),
|
||||
t.Literal("failed"),
|
||||
t.Literal("fulfilled"),
|
||||
t.Literal("resolved"),
|
||||
]);
|
||||
export type EventStatus = Static<typeof EventStatusSchema>;
|
||||
|
||||
@@ -37,7 +37,7 @@ export class EventsService {
|
||||
return "available";
|
||||
};
|
||||
if (!event.ended_at) return "processing";
|
||||
return event.has_failed ? "failed" : "fulfilled";
|
||||
return event.has_failed ? "failed" : "resolved";
|
||||
}
|
||||
|
||||
async get(id: string, trx?: Transaction<DB>) {
|
||||
@@ -76,7 +76,7 @@ export class EventsService {
|
||||
.where("ended_at", "is not", null)
|
||||
.where("has_failed", "is", true)
|
||||
)
|
||||
.$if(opt.filter?.status === "fulfilled", (qb) => qb
|
||||
.$if(opt.filter?.status === "resolved", (qb) => qb
|
||||
.where("started_at", "is not", null)
|
||||
.where("ended_at", "is not", null)
|
||||
.where("has_failed", "is", false)
|
||||
@@ -115,7 +115,7 @@ export class EventsService {
|
||||
.execute();
|
||||
}
|
||||
|
||||
async fulfill(id: string, trx?: Transaction<DB>): Promise<void> {
|
||||
async resolve(id: string, trx?: Transaction<DB>): Promise<void> {
|
||||
await (trx ?? db).updateTable("events")
|
||||
.set({ state: null, ended_at: new Date(), last_error: null })
|
||||
.where("id", "=", id)
|
||||
|
||||
Reference in New Issue
Block a user