Reactive type-safe Scala driver for Apache Cassandra/Datastax Enterprise
To stay up-to-date with our latest releases and news, follow us on Twitter: @outworkers.
If you use phantom, please consider adding your company to our list of adopters. Phantom is and will always be open source, but the more adopters our projects have, the more people from our company will actively work to make them better.
This is a table of the available modules for the various Scala versions. Not all modules are available for all versions just yet, and this is because certain dependencies have yet to be published for Scala 2.12.
Module name | Scala 2.10.x | Scala 2.11.x | Scala 2.12.0 |
---|---|---|---|
phantom-connectors | yes | yes | yes |
phantom-dsl | yes | yes | yes |
phantom-jdk8 | yes | yes | yes |
phantom-sbt | yes | no | no |
phantom-example | yes | yes | no |
phantom-thrift | yes | yes | no |
phantom-finagle | yes | yes | no |
phantom-streams | yes | yes | no |
We publish phantom in 2 formats, stable releases and bleeding edge.
-
The stable release is always available on Maven Central and will be indicated by the badge at the top of this readme. The Maven Central badge is pointing at the latest version
-
Intermediary releases are available through our managed Bintray repository available at
https://dl.bintray.com/outworkers/oss-releases/
. The latest version available on our Bintray repository is indicated by the Bintray badge at the top of this readme.
To compare phantom to similar tools in the Scala/Cassandra category, you can read more here.
The latest versions are available here. The badges automatically update when a new version is released.
As a word of introduction, this guide is brand new and there may be certain elements we have currently left out. Phantom has an immense adopter base which includes many of you using the library in ways which we do not know of. 2.0.0 completely replaces fundemental aspects of the framework to provide superior performance and reliability, and we have tested back and forth to ensure the smoothest possible transition, but please feel free to report any issues via GitHub and we will fix them straight away.
- The OSS version of phantom has as of 2.0.0 returned to the Apache V2 license and the license is here to stay.
- All packages and dependencies are now available under the
com.outworkers
organisation instead ofcom.websudos
. As part of long term re-branding efforts, we have finally felt it's time to make sure the change is consistent throughout. - There is a new and now completely optional Bintray resolver,
Resolver.bintrayRepo("outworkers", "oss-releases")
, that gives you free access to the latest cuts of our open source releases before they hit Maven Central. We assume no liability for your usage of latest cuts, but we welcome feedback and we do our best to have elaborate CI processes in place. - Manually defining a
fromRow
inside aCassandraTable
is no longer required if your column types match your case class types. EnumColumn
is now relying entirely onPrimitive.macroImpl
, which means you will not need to pass in the enumeration as an argument toEnumColumn
anymore. This meansobject enum extends EnumColumn(this, enum: MyEnum)
is now simplyobject enum extends EnumColumn[MyEnum#Value](this)
- All dependencies are now being published to Maven Central. This includes outworkers util and outworkers diesel, projects which have in their own right been completely open sourced under Apache V2 and made public on GitHub.
- All dependencies on
scala-reflect
have been completely removed. - A new, macro based mechanism now performs the same auto-discovery task that reflection used to, thanks to
macro-compat
. - Index modifiers no longer require a type parameter,
PartitionKey
,PrimaryKey
,ClusteringOrder
andIndex
don't require the column type passed anymore. KeySpaceDef
has been renamed to the more appropiateCassandraConnector
.CassandraConnector
now natively supports specifying a keyspace creation query.TimeWindowCompactionStrategy
is now natively supported in the CREATE/ALTER dsl.- Collections can now be used as part of a primary or partition key.
- Tuples are now natively supported as valid types via
TupleColumn
. phantom-reactivestreams
is now simply calledphantom-streams
.Database.autocreate
andDatabase.autotruncate
are now no longer accessible. Usecreate
,createAsync
,truncate
andtruncateAsync
instead.Database
now requires an f-bounded type argument:class MyDb(override val connector: CassandraConnection) extends Database[MyDb](connector)
.- Automated Cassandra pagination via paging states has been moved to a new method called
paginateRecord
. UsingfetchRecord
with aPagingState
is no longer possible. This is done to distinguish the underlying consumer mechanism of parsing and fetching records from Cassandra. com.outworkers.phantom.dsl.context
should be used instead ofscala.concurrent.ExecutionContext.Implicits.global
.
With the rapidly evolving requirements, Cassandra 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.
Feedback and contributions are welcome, and we are happy to prioritise any crucial features Phantom may currently be lacking.
- Revert all Outworkers projects and all their dependencies to the Apache V2 License.
- Publish
outworkers-util
and all sub modules to Maven Central. - Publish
outworkers-diesel
and all sub modules to Maven Central. - Remove all non standard resolvers from Phantom, all dependencies should build from JCenter and Maven Central by default with no custom resolvers required.
- Change all package names and resolvers to reflect our business name change from
Websudos
toOutworkers
. - 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.
- Replace the Scala reflection library with a macro that can figure out what the contents of a table are.
- Generate the name of a table using macros.
- Generate the primary key of a table using macros.
- Enforce primary key restrictions on a table using a macro.
- Generate the
fromRow
method ofCassandraTable
using a macro if thecase class
fields andtable
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 arbitrary 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.
- 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 andPagingState
not being set on anyResultSet
. - 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%
- Native support for multi-tenanted environments via cached sessions.
- Case sensitive CQL.
- Materialized views.
- SASI index support
- Support for
PER PARTITION LIMIT
inSelectQuery
. - Support for
GROUP BY
inSelectQuery
.
- Add support for Scala 2.12 in the
util
library, remove all dependencies that don't comply. - 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-example
- Add support for Scala 2.12 in
phantom-streams
- Add support for Scala 2.12 in
phantom-thrift
- Add support for Scala 2.12 in
phantom-finagle
- Offer a complete migration guide for transitioning to Phantom 2.0.0. Guide here.
- 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.
For ease of use and far better management of documentation, we have decided to export the README.md
to a proper
Wiki page, now available here.
The following are the current resources available for learning phantom, outside of tests which are very useful in highlighting all the possible features in phantom and how to use them.
This is a list of resources to help you learn phantom and Cassandra:
- Datastax Introduction to Cassandra.
- The official Scala API docs for phantom
- The main Wiki
- The StackOverflow phantom-dsl tag, which we always monitor!
- Anything tagged phantom on our blog is a phantom tutorial: phantom tutorials
- A series on Cassandra: Getting rid of the SQL mentality
- A series on Cassandra: Indexes and keys
- A series on Cassandra: Advanced features
- A series on phantom: Getting started with phantom
- The Play! Phantom Activator template
- Thiago's Cassandra + Phantom demo repository
We love Cassandra to bits and use it in every bit of our stack. phantom makes it super trivial for Scala users to embrace Cassandra.
Cassandra is highly scalable and it is by far the most powerful database technology available, open source or otherwise.
Phantom is built on top of the Datastax Java Driver, which does most of the heavy lifting.
We are very happy to help implement missing features in phantom, answer questions about phantom, and occasionally help you out with Cassandra questions! Please use GitHub for any issues or bug reports.
The following are just some of the biggest phantom adopters, though the full list is far more comprehensive.
- Starbucks Corporation
- Microsoft
- CreditSuisse
- ING
- UBS
- Wincor Nixdorf
- Paddy Power
- Strava
- Mobli
- Pellucid Analytics
- Equens
- outworkers
- VictorOps
- Socrata
- Sphonic
- Anomaly42
- Tecsisa
- Tuplejump
- FiloDB - the fast analytics database built on Cassandra and Spark
- Chartboost
Phantom is distributed under the Apache V2 License.
-
Outworkers, Limited
is the copyright holder. -
You can use phantom in commercial products or otherwise.
-
We strongly appreciate and encourage contributions.
-
All paid for features are published and sold separately as
phantom-pro
, everything that is currently available for free will remain so forever.
If you would like our help with any new content or initiatives, we'd love to hear about it!
Phantom was developed at outworkers as an in-house project. All Cassandra integration at outworkers goes through phantom, and nowadays it's safe to say most Scala/Cassandra users in the world rely on phantom.
- Flavian Alexandru (@alexflav23) - maintainer
- Bartosz Jankiewicz (@bjankie1)
- Benjamin Edwards (@benjumanji)
- Kevin Wright (@kevinwright)
- Eugene Zhulenev (@ezhulenev)
- Michal Matloka (@mmatloka)
- Thiago Pereira (@thiagoandrade6)
- Juan José Vázquez (@juanjovazquez)
- Viktor Taranenko (@viktortnk)
- Stephen Samuel (@sksamuel)
- Evan Chan (@evanfchan)
- Jens Halm (@jenshalm)
- Donovan Levinson (@levinson)
Special thanks to Viktor Taranenko from WhiskLabs, who gave us the original idea.
Copyright © 2013 - 2017 outworkers.
Contributions are most welcome! Use GitHub for issues and pull requests and we will happily help out in any way we can!