Last active
December 7, 2019 01:58
-
-
Save ShahOdin/210f7760b0e1e1db129b9bf2804441f5 to your computer and use it in GitHub Desktop.
storing successes and failures over time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cats.data.{Ior, NonEmptyList, NonEmptySet} | |
import io.circe.Json | |
object demo2 { | |
type TimeStamp = Long | |
type Identifier = Long //unique identifier, ie: ccid + streaming-platform perhaps? | |
type Reason = String | |
//Having two tables, storing only validated data in the Success table, and storing unavailability reasons in the other table. | |
//the difficulty is in gluing the two together, both at the data store level as well | |
//as at the code leve. (can be very easy at the code level with IOR) | |
case class DataEntry(id: Identifier, timeStamp: TimeStamp, payLoad: Json, complete: Boolean) | |
case class ValidationFailures(id: Identifier, timeStamp: TimeStamp, sources: NonEmptySet[Identifier], reasons: NonEmptyList[Reason]) | |
def getData1(id: Identifier): Ior[ValidationFailures, DataEntry] = ??? | |
//storing everything in one table. slightly harder to model in postgres. advantage is we always get consistent data. | |
// maybe the formatting is harder to model | |
sealed trait Availability | |
object Availability { | |
case object Availabile extends Availability | |
case class UnAvailable(sources: NonEmptySet[Identifier], reasons: NonEmptyList[Reason]) | |
} | |
case class DataEntry2(id: Identifier, payload: Json, timeStamp: TimeStamp, availability: Availability) | |
def getData2(id: Identifier): DataEntry2 = ??? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment