Skip to content

Commit 958b4c0

Browse files
authored
Bugfix/spline 979 swagger (#985)
* spline #979 Swagger: durationNs should be number, not object * spline #979 Swagger: durationNs should be number, not object
1 parent 6ddb1f6 commit 958b4c0

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

producer-model-mapper/src/main/scala/za/co/absa/spline/producer/modelmapper/v1/ModelMapperV1.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ object ModelMapperV1 extends ModelMapper {
8080
// But realistically speaking I don't believe there are many enough non-Spline v1 agents out there,
8181
// for the risk of misinterpreting the "durationNs" property in extras to be practically possible.
8282
// So I'm going to make a shortcut here for sake of performance and simplicity.
83-
val durationNs = event.extra.get(FieldNamesV1.EventExtraInfo.DurationNs).
84-
flatMap(PartialFunction.condOpt(_) {
85-
case num: Long => num
86-
case str: String if str.forall(_.isDigit) => str.toLong
87-
})
83+
val durationNs: Option[ExecutionEvent.DurationNs] = {
84+
event.extra.get(FieldNamesV1.EventExtraInfo.DurationNs).
85+
flatMap(PartialFunction.condOpt(_) {
86+
case num: Long => num
87+
case str: String if str.forall(_.isDigit) => str.toLong
88+
})
89+
}
8890

8991
ExecutionEvent(
9092
planId = event.planId,

producer-model/src/main/scala/za/co/absa/spline/producer/model/v1_1/ExecutionEvent.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,21 @@
1616

1717
package za.co.absa.spline.producer.model.v1_1
1818

19+
import za.co.absa.spline.producer.model.v1_1.ExecutionEvent._
20+
1921
import java.util.UUID
22+
import scala.language.implicitConversions
2023

2124
case class ExecutionEvent(
2225
planId: UUID,
2326
timestamp: Long,
24-
durationNs: Option[Long],
27+
durationNs: Option[DurationNs],
2528
error: Option[Any] = None,
2629
extra: Map[String, Any] = Map.empty
2730
)
31+
32+
object ExecutionEvent {
33+
type DurationNs = java.lang.Long
34+
35+
implicit def optJavaLong2OptScalaLong(opt: Option[java.lang.Long]): Option[Long] = opt.map(identity(_))
36+
}

producer-rest-core/src/main/scala/za/co/absa/spline/producer/rest/controller/ExecutionEventsController.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ExecutionEventsController @Autowired()(
5151
// Time (milliseconds since Epoch) when the execution finished
5252
timestamp: <number>,
5353
// [Optional] Duration (in nanoseconds) of the execution
54-
duration: <number>,
54+
durationNs: <number>,
5555
// [Optional] Additional info about the error (in case there was an error during the execution)
5656
error: {...},
5757
// [Optional] Any other extra information related to the given execution event

producer-services/src/main/scala/za/co/absa/spline/producer/service/repo/ExecutionProducerRepositoryImpl.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.springframework.stereotype.Repository
2323
import za.co.absa.spline.persistence.model._
2424
import za.co.absa.spline.persistence.tx.{ArangoTx, InsertQuery, TxBuilder}
2525
import za.co.absa.spline.persistence.{ArangoImplicits, Persister}
26+
import za.co.absa.spline.producer.model.v1_1.ExecutionEvent._
2627
import za.co.absa.spline.producer.model.{v1_1 => apiModel}
2728
import za.co.absa.spline.producer.service.InconsistentEntityException
2829
import za.co.absa.spline.producer.service.model.{ExecutionEventKeyCreator, ExecutionPlanPersistentModel, ExecutionPlanPersistentModelBuilder}

0 commit comments

Comments
 (0)