Skip to content

Commit b92632d

Browse files
authored
ensure ClusterCron's can be resumed if re-added (#5775)
1 parent 69e1389 commit b92632d

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

.changeset/plenty-islands-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect/cluster": patch
3+
---
4+
5+
ensure ClusterCron's can be resumed if re-added

packages/cluster/src/ClusterCron.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@ export const make = <E, R>(options: {
6666
const InitialRun = Singleton.make(
6767
`ClusterCron/${options.name}`,
6868
Effect.gen(function*() {
69-
const client = (yield* CronEntity.client)("initial")
7069
const now = yield* DateTime.now
71-
const next = Cron.next(options.cron, now)
72-
yield* client.run({
73-
dateTime: DateTime.unsafeFromDate(next)
74-
}, { discard: true })
70+
const next = DateTime.unsafeFromDate(Cron.next(options.cron, now))
71+
const entityId = options.calculateNextRunFromPrevious ? "initial" : DateTime.formatIso(next)
72+
const client = (yield* CronEntity.client)(entityId)
73+
yield* client.run({ dateTime: next }, { discard: true })
7574
}),
7675
{ shardGroup: options.shardGroup }
7776
)

0 commit comments

Comments
 (0)