-
Notifications
You must be signed in to change notification settings - Fork 1
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
#188: new Flow service in API v2 #195
Changes from 14 commits
86397c2
dab8751
9678071
1fea27b
61f8f47
c1c10ce
a8c8ead
95b4ba6
520cba8
f840e5a
09249cb
4bf50a1
163de13
5b21021
dcac162
9e0731b
c2a672e
f6d3400
52f3c29
54b8017
71ee83d
4805305
52972c3
e219d3f
bddf570
1ce658b
0676967
d0ca3ae
b7310f7
e346077
3c53a89
464752a
92065f6
d6fe29d
8d777f6
8e8b565
38ca1bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2021 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.atum.model.dto | ||
|
||
case class CheckpointQueryDTO( | ||
partitioning: PartitioningDTO, | ||
limit: Option[Int], | ||
checkpointName: Option[String] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2021 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.atum.server.api.controller | ||
|
||
import za.co.absa.atum.model.dto.{CheckpointQueryDTO, CheckpointDTO} | ||
import za.co.absa.atum.server.model.ErrorResponse | ||
import zio.IO | ||
import zio.macros.accessible | ||
|
||
@accessible | ||
trait FlowController { | ||
def getFlowCheckpoints(checkpointQueryDTO: CheckpointQueryDTO): IO[ErrorResponse, Seq[CheckpointDTO]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed we don't have any documentation in our traits for Controllers/Services/Repositories. I am wondering whether it would be useful to introduce it .... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know. I find it quite useless, since all this is I think quite obvious, naming and implementation wise. If you disagree let's initiate the conversation about it on our Curation tech meeting / chat though :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's bring this topic up on one of upcoming team meetings then. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2021 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.atum.server.api.controller | ||
|
||
import za.co.absa.atum.model.dto.{CheckpointQueryDTO, CheckpointDTO} | ||
import za.co.absa.atum.server.api.service.FlowService | ||
import za.co.absa.atum.server.model.ErrorResponse | ||
import zio._ | ||
|
||
class FlowControllerImpl(flowService: FlowService) | ||
extends FlowController with BaseController { | ||
|
||
override def getFlowCheckpoints(checkpointQueryDTO: CheckpointQueryDTO): IO[ErrorResponse, Seq[CheckpointDTO]] = { | ||
serviceCall[Seq[CheckpointDTO], Seq[CheckpointDTO]]( | ||
flowService.getFlowCheckpoints(checkpointQueryDTO), | ||
r => r | ||
TebaleloS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
} | ||
|
||
} | ||
|
||
object FlowControllerImpl { | ||
val layer: URLayer[FlowService, FlowController] = ZLayer { | ||
for { | ||
flowService <- ZIO.service[FlowService] | ||
} yield new FlowControllerImpl(flowService) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,12 @@ package za.co.absa.atum.server.api.database | |
|
||
import cats.Show | ||
import cats.data.NonEmptyList | ||
|
||
import doobie.{Get, Put} | ||
import doobie.postgres.implicits._ | ||
|
||
import doobie.{Get, Put} | ||
import io.circe.{Decoder, Encoder} | ||
import org.postgresql.jdbc.PgArray | ||
import org.postgresql.util.PGobject | ||
import za.co.absa.atum.model.dto.MeasureResultDTO | ||
|
||
import scala.util.{Failure, Success, Try} | ||
|
||
|
@@ -155,7 +155,29 @@ object DoobieImplicits { | |
} | ||
) | ||
} | ||
} | ||
|
||
implicit val encodeResultValueType: Encoder[MeasureResultDTO.ResultValueType] = Encoder.encodeString.contramap { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the motivation to place json related encoders/decoders alongside doobie implicits? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I understand the question, those JSON related SerDe code was already there & I needed those MeasureResult DTOs to be serialized/deserialized as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DoobieImplicits object is there for defining Put/Get/Read/Write instances for Doobie. Then we have PlayJsonImplicits for Reads/Writes/Format type classes for Play Json. And what you have defined is actually related to Circe. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aaah. Yes, I'm sorry I understand now. I'll move them to I know that I could move them directly to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's customary to place them in companion objects. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved into companion object of a given DTO, thanks for the recommendation |
||
case MeasureResultDTO.ResultValueType.String => "String" | ||
case MeasureResultDTO.ResultValueType.Long => "Long" | ||
case MeasureResultDTO.ResultValueType.BigDecimal => "BigDecimal" | ||
case MeasureResultDTO.ResultValueType.Double => "Double" | ||
} | ||
|
||
implicit val decodeResultValueType: Decoder[MeasureResultDTO.ResultValueType] = Decoder.decodeString.emap { | ||
case "String" => Right(MeasureResultDTO.ResultValueType.String) | ||
case "Long" => Right(MeasureResultDTO.ResultValueType.Long) | ||
case "BigDecimal" => Right(MeasureResultDTO.ResultValueType.BigDecimal) | ||
case "Double" => Right(MeasureResultDTO.ResultValueType.Double) | ||
case other => Left(s"Cannot decode $other as ResultValueType") | ||
} | ||
|
||
implicit val encodeTypedValue: Encoder[MeasureResultDTO.TypedValue] = | ||
Encoder.forProduct2("value", "valueType")(tv => (tv.value, tv.valueType)) | ||
|
||
implicit val decodeTypedValue: Decoder[MeasureResultDTO.TypedValue] = | ||
Decoder.forProduct2("value", "valueType")(MeasureResultDTO.TypedValue.apply) | ||
|
||
implicit val decodeMeasureResultDTO: Decoder[MeasureResultDTO] = | ||
Decoder.forProduct2("mainValue", "supportValues")(MeasureResultDTO.apply) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2021 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.atum.server.api.database.flows | ||
|
||
import za.co.absa.fadb.DBSchema | ||
import za.co.absa.fadb.naming.implementations.SnakeCaseNaming.Implicits._ | ||
|
||
object Flows extends DBSchema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these v2 endpoint paths should follow this naming convention (kebab-case) 'get-flow-checkpoints'. Of course it's a topic for a team discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Once your envelope PR and FOrgiveness' PR will be merged to master, thus propagated here, I'll change it