Skip to content
Automatic DynamoDB serialisation of Scroge generated classes
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project
src
.gitignore
.travis.yml
README.md
build.sbt
version.sbt

README.md

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(
  "org" %% "scanamo-scrooge" % "0.1.3"
)

Usage

To bring DynamoFormats for Scrooge generated classes into scope, simply

import org.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 org.scanamo._
scala> import org.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: true,}},}},}

scala> DynamoFormat[ChangeRecord].read(DynamoFormat[ChangeRecord].write(changeRecord))
res1: Either[error.DynamoReadError, ChangeRecord] = Right(ChangeRecord(1,Some(User(email,Some(f),None))))
You can’t perform that action at this time.