Skip to content

Commit

Permalink
Adding the ability to map records lazily and paginate them (#572)
Browse files Browse the repository at this point in the history
* Adding the ability to map records lazily and paginate them

* Fixing compilation errors.

* Adding logging configuration

* Fixed type on provider instance variable (#581)

* TravisCI: Bumping version to match CI definition [ci skip]

* Adding a 2.0 roadmap description [ci skip]

* Adding more details about 2.0.0 release [ci skip]

* Add support for Jdk8 LocalDateTime (#593)

* TravisCI: Bumping version to match CI definition [ci skip]

* Updating version to correct setup of 1.29.5 [ci skip] (#594)

* Adding missing comment

* Removing snapshot resolver

* Reverting macro changeset accidentally leaked (#596)

* Removing macros, re-adding correct dep, removing custom resolver.

* Small adjustments

* Fixing the 2 broken tests.

* Fixing generators

* Fixing compilation error

* Adding table name variabe to prevent issues

* Adding an error handler.

* Adding a dual variant test

* Adding more safe guards

* Using macro type comparison symbol instead of equality checking

* Removing redundant conversions

* Fixing indenation [ci skip]
  • Loading branch information
alexflav23 authored Dec 13, 2016
1 parent 683c035 commit 4e5a3e1
Show file tree
Hide file tree
Showing 19 changed files with 374 additions and 111 deletions.
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,73 @@ Intermediary releases of phantom 2.0.x are already available via `Resolver.bintr
- [ ] Add a documentation website on the main page.
- [ ] Create a navigator that allows viewing the documentation at a particular point in time.

### Roadmap to Phantom 2.0.0

With the rapidly evolving requirements, Cassansdra releases, and competition, it was only natural we kept Phantom up to scratch. In line with a lot of user feedback, the priorities of 2.0.0 were:

- Go back to the flexible licensing model everyone knows and loves(especially your legal department). No one wants to go through corporate litigation and licensing compliance to a `build.sbt` dependency, and if you've ever worked in a bank we all know it's not happening.

- Phantom was a really fun time saving introduction years ago when it was first introduced, but since then Scala has evolved to a point where many features of more esoteric components, such as the macro API, have reached a degree of stability that we can now exploit to our great advantage: **boilerplate elimitation**.

- From type parameters to keys, table class cake patterns, having to define `fromRow`, and a whole lot of other boilerplatey items, we have eliminated them one by one, reducing the amount of code you need to type to make it all work. The future looks even brighter, as we plan on fully eliminating the mapping DSL very shortly in favour of even more lightweight techniques.

Phantom's next major release is slowly approaching completion, and if you would like to know more about what's to come and about what we have in store for you next, have a look at the below list. Feedback and contributions are welcome, and we are happy to prioritise any crucial features Phantom may currently be lacking.

If the boxes are checked it means this is already complete on the gigantic [2.0.0 pull request](https://github.com/outworkers/phantom/pull/576). This is initial "in progres" [migration guide](https://github.com/outworkers/phantom/tree/feature/2.0.0#200-migration-guide) to Phantom 2.0.0 that should give you some more detail into the changes made.

Intermediary releases of phantom 2.0.x are already available via `Resolver.bintrayRepo("outworkers", "oss-releases")` and the latest version is [![Bintray](https://api.bintray.com/packages/outworkers/oss-releases/phantom-dsl/images/download.svg) ](https://bintray.com/outworkers/oss-releases/phantom-dsl/_latestVersion).

#### Licensing and distribution

- [x] Revert all Outworkers projects and all their dependencies to the Apache V2 License.
- [x] Publish `outworkers-util` and all sub modules to Maven Central.
- [x] Publish `outworkers-diesel` and all sub modules to Maven Central.
- [x] Remove all non standard resolvers from Phantom, all dependencies should build from JCenter and Maven Central by default with no custom resolvers required.
- [x] Change all package names and resolvers to reflect our business name change from `Websudos` to `Outworkers`.
- [x] Create a `1.30.x` release that allows users to transition to a no custom resolver version of Phantom 1.0.x even before 2.0.0 is stable.

#### Macro API to replace runtime features

- [x] Replace the Scala reflection library with a macro that can figure out what the contents of a table are.
- [x] Generate the name of a table using macros.
- [x] Generate the primary key of a table using macros.
- [x] Enforce primary key restrictions on a table using a macro.
- [x] Generate the `fromRow` method of `CassandraTable` using a macro if the `case class` fields and `table` columns are matched.
- [ ] Enforce a same ordering restriction for case class fields and table columns to avoid generating invalid methods with the macro.
- [ ] Generate the `fromRow` if the fields match, they are in abitrary order, but there are no duplicate types.
- [ ] Allow arbitrary inheritance and usage patterns for Cassandra tables, and resolve inheritance resolutions with macros to correctly identify desired table structures.

#### Tech debt

- [ ] Correctly implement Cassandra pagination using iterators, currently setting a `fetchSize` on a query does not correctly propagate or consume the resulting iterator, which leads to API inconsistencies and `PagingState` not being set on any `ResultSet`.
- [ ] Add a build matrix that will test phantom against multiple versions of Cassandra in Travis for Scala 2.11, with support for all major releases of Cassandra.
- [ ] Bump code coverage up to 100%

#### Features

- [ ] Native support for multi-tenanted environments via cached sessions.
- [ ] Case sensitive CQL.
- [ ] Materialized views.
- [ ] SASI index support
- [ ] Support for `PER PARTITION LIMIT` in `SelectQuery`.
- [ ] Support for `GROUP BY` in `SelectQuery`.

#### Scala 2.12 support

- [ ] Add support for Scala 2.12 in the `util` library, remove all dependencies that don't comply.
- [x] Add support for Scala 2.12 in the `diesel-engine`.
- [ ] Add support for Scala 2.12 in `phantom-dsl`
- [ ] Add support for Scala 2.12 in `phantom-connectors`
- [ ] Add support for Scala 2.12 in `phantom-reactivestreams`
- [ ] Add support for Scala 2.12 in `phantom-finagle`

#### Documentatiom

- [ ] Offer a complete migration guide for transitioning to Phantom 2.0.0. [Guide here](https://github.com/outworkers/phantom/tree/feature/2.0.0#200-migration-guide).
- [ ] Move documentation back to the docs folder.
- [ ] Add a documentation website on the main page.
- [ ] Create a navigator that allows viewing the documentation at a particular point in time.

<a id="learning-phantom">Tutorials on phantom and Cassandra</a>
======================================================================

Expand Down
29 changes: 8 additions & 21 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ import com.twitter.sbt._

lazy val Versions = new {
val logback = "1.1.7"
val util = "0.23.1"
val util = "0.25.0"
val json4s = "3.3.0"
val datastax = "3.1.0"
val scalatest = "2.2.4"
val shapeless = "2.2.5"
val shapeless = "2.3.2"
val thrift = "0.8.0"
val finagle = "6.37.0"
val twitterUtil = "6.34.0"
val scalameter = "0.6"
val diesel = "0.4.1"
val diesel = "0.5.0"
val scalacheck = "1.13.0"
val slf4j = "1.7.21"
val reactivestreams = "1.0.0"
Expand All @@ -45,7 +46,7 @@ lazy val Versions = new {

val lift: String => String = {
s => CrossVersion.partialVersion(s) match {
case Some((major, minor)) if minor >= 11 => "3.0-RC3"
case Some((major, minor)) if minor >= 11 => "3.0"
case _ => "3.0-M1"
}
}
Expand Down Expand Up @@ -79,16 +80,8 @@ lazy val Versions = new {
}
}
}

val defaultConcurrency = 4

val scalaMacroDependencies: String => Seq[ModuleID] = {
s => CrossVersion.partialVersion(s) match {
case Some((major, minor)) if minor >= 11 => Seq.empty
case _ => Seq(compilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full))
}
}

val PerformanceTest = config("perf").extend(Test)
lazy val performanceFilter: String => Boolean = _.endsWith("PerformanceTest")

Expand All @@ -102,8 +95,7 @@ val sharedSettings: Seq[Def.Setting[_]] = Defaults.coreDefaultSettings ++ Seq(
"Twitter Repository" at "http://maven.twttr.com",
Resolver.typesafeRepo("releases"),
Resolver.sonatypeRepo("releases"),
Resolver.jcenterRepo,
Resolver.bintrayRepo("outworkers", "oss-releases")
Resolver.jcenterRepo
),
scalacOptions ++= Seq(
"-language:experimental.macros",
Expand Down Expand Up @@ -182,17 +174,12 @@ lazy val phantomDsl = (project in file("phantom-dsl")).configs(
concurrentRestrictions in Test := Seq(
Tags.limit(Tags.ForkedTestGroup, defaultConcurrency)
),
unmanagedSourceDirectories in Compile ++= Seq(
(sourceDirectory in Compile).value / ("scala-2." + {
CrossVersion.partialVersion(scalaBinaryVersion.value) match {
case Some((major, minor)) => minor
}
})),
libraryDependencies ++= Seq(
"org.typelevel" %% "macro-compat" % "1.1.1",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
compilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full),
"com.outworkers" %% "diesel-engine" % Versions.diesel,
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"com.outworkers" %% "diesel-reflection" % Versions.diesel,
"com.chuusai" %% "shapeless" % Versions.shapeless,
"joda-time" % "joda-time" % "2.9.4",
"org.joda" % "joda-convert" % "1.8.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ class KeySpaceBuilder(clusterBuilder: ClusterBuilder) {
* @return A new cluster builder, with the heartbeat interval set to 0(disabled).
*/
def noHeartbeat(): KeySpaceBuilder = {
new KeySpaceBuilder(clusterBuilder andThen(_.withPoolingOptions(
new PoolingOptions().setHeartbeatIntervalSeconds(0))
)
new KeySpaceBuilder(clusterBuilder andThen (
_.withPoolingOptions(new PoolingOptions().setHeartbeatIntervalSeconds(0)))
)
}

Expand All @@ -56,7 +55,8 @@ class KeySpaceBuilder(clusterBuilder: ClusterBuilder) {
def keySpace(
name: String,
autoinit: Boolean = true,
query: Option[(Session, KeySpace) => String] = None
query: Option[(Session, KeySpace) => String] = None,
errorHandler: Throwable => Throwable = identity
): CassandraConnection = {
new CassandraConnection(name, clusterBuilder, autoinit, query)
}
Expand All @@ -74,6 +74,4 @@ class KeySpaceBuilder(clusterBuilder: ClusterBuilder) {
query: (Session, KeySpace) => String
): CassandraConnection = {
new CassandraConnection(name, clusterBuilder, true, Some(query))
}

}
}}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ trait SessionAugmenter {
protocolVersion.compareTo(pv) > 0
}

def v3orNewer : Boolean = isNewerThan(ProtocolVersion.V2)
def v3orNewer: Boolean = isNewerThan(ProtocolVersion.V2)

def protocolConsistency: Boolean = isNewerThan(ProtocolVersion.V1)

def v4orNewer : Boolean = isNewerThan(ProtocolVersion.V3)
def v4orNewer: Boolean = isNewerThan(ProtocolVersion.V3)
}

trait SessionAugmenterImplicits {
Expand Down
Loading

0 comments on commit 4e5a3e1

Please sign in to comment.