Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add longRunningId to SchedulingContext #421

Merged
merged 1 commit into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/it/scala/com/criteo/cuttle/TestScheduling.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ trait TestScheduling {
val toJson: Json = Json.Null
val log: ConnectionIO[String] = "id".pure[ConnectionIO]
def compareTo(other: SchedulingContext) = 0
override def longRunningId(): String = toString
}

case class TestScheduling(config: Unit = ()) extends Scheduling {
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/scala/com/criteo/cuttle/Scheduling.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ trait SchedulingContext {
/** Compare to another context. In the current design only context of the same types will be
* compared to each other because a workflow/project is defined for a single [[Scheduling]] type. */
def compareTo(other: SchedulingContext): Int

/** An id to identify a context after a reboot of the application */
def longRunningId(): String
}

/** Utilities for [[SchedulingContext]] */
Expand Down
1 change: 1 addition & 0 deletions core/src/test/scala/com/criteo/cuttle/TestScheduling.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ trait TestScheduling {
val toJson: Json = Json.Null
val log: ConnectionIO[String] = "id".pure[ConnectionIO]
def compareTo(other: SchedulingContext) = 0
override def longRunningId(): String = toString
}

case class TestScheduling(config: Unit = ()) extends Scheduling {
Expand Down
2 changes: 2 additions & 0 deletions cron/src/main/scala/com/criteo/cuttle/cron/CronModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ case class CronContext(instant: Instant)(retryNum: Int) extends SchedulingContex
}

override def asJson: Json = CronContext.encoder(this)

override def longRunningId(): String = toString
}

case object CronContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ object HelloCustomScheduling {
case LoopContext(otherIteration) =>
iteration - otherIteration
}

override def longRunningId(): String = toString
}

// This our scheduling definition and configuration. For example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ case class TimeSeriesContext(start: Instant,
thisBackfillPriority.compareTo(otherBackfillPriority)
}
}

override def longRunningId(): String = {
(start, end, backfill).toString
}
}

object TimeSeriesContext {
Expand Down