Skip to content

Commit

Permalink
Reformat with scalafmt 3.7.14
Browse files Browse the repository at this point in the history
Executed command: scalafmt --non-interactive
  • Loading branch information
scala-steward committed Sep 11, 2023
1 parent 3aceac0 commit 05c4987
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/main/scala/rozklad/api/MaintenanceService.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package rozklad.api


trait MaintenanceService[F[_]] {

def remove(id: Id[ScheduledTask]): F[RemovedScheduledTask]
Expand Down
16 changes: 8 additions & 8 deletions src/main/scala/rozklad/api/ScheduledTaskService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ trait ScheduledTaskService[F[_]] {
case class TaskIsNotInExpectedStatusException(id: Id[ScheduledTask]) extends RuntimeException(s"Task ${id} is not in acquired state")

case class ScheduledTaskLog(
id: Id[ScheduledTaskLog],
taskId: Id[ScheduledTask],
status: Status,
createdAt: Instant,
failedReason: Option[FailedReason],
payload: JsValue,
triggerAt: Option[Instant])
id: Id[ScheduledTaskLog],
taskId: Id[ScheduledTask],
status: Status,
createdAt: Instant,
failedReason: Option[FailedReason],
payload: JsValue,
triggerAt: Option[Instant])

object ScheduledTaskLog {
def from(task: ScheduledTask): ScheduledTaskLog = {
Expand All @@ -43,4 +43,4 @@ object ScheduledTaskLog {
Some(triggerAt)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@ class DoobieScheduledTaskRepository(table: String) extends ScheduledTaskReposito
query.query[ScheduledTask].to[List]
}

}
}
3 changes: 2 additions & 1 deletion src/main/scala/rozklad/db/DoobieTaskScheduler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class DoobieTaskScheduler[F[_]](
xa: Transactor[F],
observer: Observer[F],
scheduledTaskRepository: ScheduledTaskRepository = new DoobieScheduledTaskRepository(DefaultScheduledTasksTableName),
scheduledTaskLogsRepository: ScheduledTaskLogRepository = new DoobieScheduledTaskLogRepository(DefaultScheduledTasksLogsTableName))(implicit ME: MonadCancel[F, Throwable])
scheduledTaskLogsRepository: ScheduledTaskLogRepository = new DoobieScheduledTaskLogRepository(DefaultScheduledTasksLogsTableName))(
implicit ME: MonadCancel[F, Throwable])
extends TaskScheduler[F] {

override def schedule(id: Id[ScheduledTask], triggerAt: Instant, scheduledAt: Instant, payload: JsValue): F[ScheduledTask] = {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/rozklad/db/ScheduledTaskLogRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ trait ScheduledTaskLogRepository {
def insert(tasks: List[ScheduledTask]): doobie.ConnectionIO[Unit]
def select(id: Id[ScheduledTask]): doobie.ConnectionIO[List[ScheduledTaskLog]]
def delete(id: Id[ScheduledTask]): doobie.ConnectionIO[List[ScheduledTaskLog]]
}
}
3 changes: 1 addition & 2 deletions src/main/scala/rozklad/db/ScheduledTaskRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ trait ScheduledTaskRepository {
updatedPayload: Option[JsValue]): doobie.ConnectionIO[List[ScheduledTask]]
}


case class InsertDuplicate() extends RuntimeException
case class InsertDuplicate() extends RuntimeException
15 changes: 5 additions & 10 deletions src/test/scala/rozklad/impl/ExecutorServiceServiceTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import scala.reflect.ClassTag
class ExecutorServiceServiceTest extends AnyFlatSpec with ScheduledTaskLogMatchers with MockFactory {

"ExecutorService" should "report failing" in new ctx {
self =>
val e = new RuntimeException("test")
self => val e = new RuntimeException("test")
(tasks.acquireBatch _).expects(*, *).returning(IO.raiseError(e)).once()
val es = createExecutor
eventually {
Expand Down Expand Up @@ -49,8 +48,7 @@ class ExecutorServiceServiceTest extends AnyFlatSpec with ScheduledTaskLogMatche
}

it should "report successful execution" in new ctx {
s =>
(tasks.acquireBatch _).expects(*, *).returning(IO(List(task)))
s => (tasks.acquireBatch _).expects(*, *).returning(IO(List(task)))
(executor.execute _).expects(*).returning(IO(ScheduledTaskOutcome.Succeeded.empty))
(tasks.succeeded _).expects(*, *, *).returning(IO(task))

Expand All @@ -65,8 +63,7 @@ class ExecutorServiceServiceTest extends AnyFlatSpec with ScheduledTaskLogMatche
}

it should "report failed execution" in new ctx {
self =>
(tasks.acquireBatch _).expects(*, *).returning(IO(List(task)))
self => (tasks.acquireBatch _).expects(*, *).returning(IO(List(task)))
val reason: FailedReason.Exception.type = FailedReason.Exception
val payload: JsObject = Json.obj("Hui" -> "no")
(executor.execute _).expects(*).returning(IO(ScheduledTaskOutcome.Failed(Option(reason), Some(payload))))
Expand All @@ -85,8 +82,7 @@ class ExecutorServiceServiceTest extends AnyFlatSpec with ScheduledTaskLogMatche
}

it should "report errored execution" in new ctx {
self =>
(tasks.acquireBatch _).expects(*, *).returning(IO(List(task)))
self => (tasks.acquireBatch _).expects(*, *).returning(IO(List(task)))
(tasks.failed _).expects(*, *, *, *).returning(IO(task))
val e = new RuntimeException("error")
(executor.execute _).expects(*).returning(IO.raiseError(e))
Expand Down Expand Up @@ -114,8 +110,7 @@ class ExecutorServiceServiceTest extends AnyFlatSpec with ScheduledTaskLogMatche
}

it should "propagate error during handling execution result" in new ctx {
s =>
val ex = new RuntimeException("dsfsdf")
s => val ex = new RuntimeException("dsfsdf")

(tasks.acquireBatch _).expects(*, *).returning(IO(List(task)))
(executor.execute _).expects(*).returning(IO(ScheduledTaskOutcome.Succeeded.empty))
Expand Down

0 comments on commit 05c4987

Please sign in to comment.