Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ class Triggers(
if (jobHistoryModel.addOneTimeJobIfNotExists(jobKey, id)) {
// Single run trigger has its id passed to the scheduler via the job-data-map. The WorkerJobListener will
// use that id to update the existing record in job_history table
val jobDataMap = jobHistoryModel.createJobDataMapForOneTimeJob(id)
// Piezo-admin expects job-data-map values for triggers to be stored as strings
val jobDataMap = jobHistoryModel.createJobDataMapForOneTimeJob(id.toString)
scheduler.triggerJob(jobKey, jobDataMap)
}
Ok
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class JobHistoryModel(getConnection: () => Connection) {
final def getOneTimeJobIdFromDataMap(jobDataMap: JobDataMap): Option[String] = Option(
jobDataMap.getString(jobDataMapOneTimeJobKey),
)
final def createJobDataMapForOneTimeJob(id: Long): JobDataMap = new JobDataMap(
final def createJobDataMapForOneTimeJob(id: String): JobDataMap = new JobDataMap(
java.util.Map.of(jobDataMapOneTimeJobKey, id),
)

Expand Down
8 changes: 6 additions & 2 deletions worker/src/test/scala/com/lucidchart/piezo/ModelTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ class ModelTest extends Specification with BeforeAll with AfterAll {
/**
* Run a body with a connection provider available
*/
private def withConnectionProvider[T](failoverEveryConnection: Boolean = false)(body: (() => java.sql.Connection) => T): T = {
private def withConnectionProvider[T](
failoverEveryConnection: Boolean = false,
)(body: (() => java.sql.Connection) => T): T = {
val provider = new PiezoConnectionProvider(
dbUrl,
"com.mysql.cj.jdbc.Driver",
Expand Down Expand Up @@ -109,7 +111,9 @@ class ModelTest extends Specification with BeforeAll with AfterAll {
jobHistoryModel.getJob(jobKey).toSet mustEqual Set.empty
}

"work correctly with a failover for every connection to the database" in withConnectionProvider(failoverEveryConnection=true) { getConnection =>
"work correctly with a failover for every connection to the database" in withConnectionProvider(
failoverEveryConnection = true,
) { getConnection =>
val jobHistoryModel = new JobHistoryModel(getConnection)
val jobKey = new JobKey("blahc", "blahc")
val triggerKey = new TriggerKey("blahtnc", "blahtgc")
Expand Down