Skip to content

Adazza/scanamo-scrooge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScanamoScrooge Maven Central Build Status

Like Scanamo for interacting with DynamoDB and use Scrooge for working with Thrift? Then you'll love ScanamoScrooge!

ScanamoScrooge provides automatic derivation of DynamoFormat type classes for Scrooge generated classes based on Thrift struct and enum types.

Installation

Add scanamo-scrooge as a dependency to your build.sbt:

libraryDependencies ++= Seq(
  "com.gu" %% "scanamo-scrooge" % "0.1.3"
)

Usage

To bring DynamoFormats for Scrooge generated classes into scope, simply

import com.gu.scanamo.scrooge.ScroogeDynamoFormat._

While, there is normally no need to explicitly reference DynamoFormat, the following is an example of how it serialises classes based on the ChangeRecord thrift definition.

scala> import com.gu.scanamo._
scala> import com.gu.scanamo.scrooge.ScroogeDynamoFormat._
scala> import com.gu.contentatom.thrift._
scala> import cats.syntax.either._

scala> val changeRecord = ChangeRecord(1L, Some(User("email", Some("f"), None)))
scala> DynamoFormat[ChangeRecord].write(changeRecord)
res0: com.amazonaws.services.dynamodbv2.model.AttributeValue = {M: {date={N: 1,}, user={M: {email={S: email,}, firstName={S: f,}, lastName=null},}},}

scala> DynamoFormat[ChangeRecord].read(DynamoFormat[ChangeRecord].write(changeRecord))
res1: Either[error.DynamoReadError, ChangeRecord] = Right(ChangeRecord(1,Some(User(email,Some(f),None))))

About

Automatic DynamoDB serialisation of Scroge generated classes

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 100.0%