Skip to content

Commit

Permalink
refactor: use .repeat() instead of .schedule() consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
updraft0 committed Jun 28, 2024
1 parent 20e3254 commit 2e5e70d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object MapPermissionTracker:
// reload permissions every interval
_ <- inHub
.publish(InternalMessage.RefreshAll)
.schedule(Schedule.once.andThen(Schedule.fixed(PermissionReloadInterval)))
.repeat(Schedule.fixed(PermissionReloadInterval))
.forkScoped
// process messages
inQ <- inHub.subscribe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ object MapEntity extends ReactiveEntity[MapEnv, MapId, MapState, Identified[MapR
state,
Chunk(removeConnections(deletedConnections)) ++
systemIdsToRefresh.map(sId => reloadSystemSnapshot(mapId, sId))
).when(deletedConnections.nonEmpty).someOrElse(state -> Chunk.empty)
).when(expiredConnections.nonEmpty).someOrElse(state -> Chunk.empty)
yield res

private inline def loadSingleSystem(mapId: MapId, systemId: SystemId) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ object MapSession:
_ <- chan.send(ChannelEvent.Read(WebSocketFrame.Ping)).schedule(Schedule.fixed(PingInterval)).ignore.forkDaemon
// listen for server status
_ <- sendServerStatus(ourQ)
.schedule(Schedule.once.andThen(Schedule.fixed(ServerStatusInterval)))
.repeat(Schedule.fixed(ServerStatusInterval))
.ignore
.forkDaemon
// join on the remaining loops
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ object CharacterAffiliationTracker:
private val EsiMaxCharacterPerBatch = 64

def apply(): ZIO[Scope & Env, Nothing, Unit] =
(refreshAll
.tapError(ex => ZIO.logErrorCause("Failed to refresh character affiliations", Cause.fail(ex))) @@
Log.BackgroundOperation("affiliationTracker")).ignoreLogged
.repeat(Schedule.duration(5.seconds).andThen(Schedule.fixed(PollInterval)))
.forkScoped
.unit
val refresh = refreshAll
.tapError(ex => ZIO.logErrorCause("Failed to refresh character affiliations", Cause.fail(ex)))
.ignoreLogged @@ Log.BackgroundOperation("affiliationTracker")

refresh.delay(5.seconds).forkScoped *> refresh.repeat(Schedule.fixed(PollInterval)).forkScoped.unit

private def refreshAll: ZIO[Env, Throwable, Unit] =
ZIO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ object CharacterAuthTracker:
// start the refresh timer
_ <- refreshPending(esi, state, hub).repeat(Schedule.fixed(PollInterval)).forkScoped
// start the snapshot timer
_ <- sendSnapshot(state, hub).delay(10.seconds).forkScoped
_ <- sendSnapshot(state, hub)
.repeat(Schedule.duration(10.seconds).andThen(Schedule.fixed(SnapshotInterval)))
.repeat(Schedule.fixed(SnapshotInterval))
.forkScoped
yield new CharacterAuthTracker:
override def newLogin(auth: CharacterAuth): UIO[Unit] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ object LocationTracker:
_ <- refreshLocations(esi, state, responseHub, c.maxParallel)
.timeout(c.interval)
.ignoreLogged
.schedule(Schedule.fixed(c.interval))
.repeat(Schedule.fixed(c.interval))
.forkScoped
yield new LocationTracker:
override def inbound: Enqueue[LocationTrackingRequest] = inQ
Expand Down

0 comments on commit 2e5e70d

Please sign in to comment.