Skip to content

Commit

Permalink
Move makeId to Executor
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Feb 28, 2024
1 parent e789994 commit f672cb5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/src/main/scala/Executor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ object Executor:
val (newState, io) = task.clearAssignedKey match
case None =>
state - workId -> Logger[IO].warn(
s"Give up move due to invalid move $response of key $key for $task"
s"Give up move due to invalid move $response of $key for $task"
)
case Some(updated) => state.updated(task.id, updated) -> IO.unit
newState -> io *> failure(task, key)
Expand Down Expand Up @@ -92,11 +92,13 @@ object Executor:
)

def fromRequest(req: Lila.Request): IO[Work.Task] =
(IO(Work.makeId), IO.realTimeInstant).mapN: (id, now) =>
(makeId, IO.realTimeInstant).mapN: (id, now) =>
Work.Task(
id = id,
request = req,
tries = 0,
acquired = None,
createdAt = now
)

def makeId: IO[WorkId] = IO(WorkId(scala.util.Random.alphanumeric.take(8).mkString))
2 changes: 0 additions & 2 deletions app/src/main/scala/Work.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,3 @@ object Work:
)
override def toString =
s"id:$id game:${request.id} variant:${request.variant.key} level:${request.level} tries:$tries created:$createdAt acquired:$acquired move: ${request.moves}"

def makeId = WorkId(scala.util.Random.alphanumeric.take(8).mkString)

0 comments on commit f672cb5

Please sign in to comment.