frees-io / freestyle-cassandra

Freestyle Cassandra
http://frees.io/
Apache License 2.0
17 stars 4 forks source link

Add method asFree for Unit Cassandra Ops #107

Closed fedefernandez closed 7 years ago

fedefernandez commented 7 years ago

This ticket depends on #98

We need to split the InterpolatorOps class for supporting a different kind set of operations depending on the statement type. The current code should be applied only to SelectStatement:

-- final class InterpolatorOps(tuple: (String, List[SerializableValueBy[Int]])) {
++ final class InterpolatorSelectOps(tuple: (String, SelectStatement, List[SerializableValueBy[Int]])) {

And then create new classes for the INSERT, DELETE and UPDATE operations with two operations, asFree and attempt, instead of asResultSet and attemptResultSet, potentially reusing the same logic:

  final class InterpolatorDeleteOps(tuple: (String, DeleteStatement, List[SerializableValueBy[Int]])) {

    def asFree[M[_]](consistencyLevel: Option[ConsistencyLevel] = None)(
        implicit API: SessionAPI[M]): FreeS[M, Unit] = ???

    def attempt[M[_]](consistencyLevel: Option[ConsistencyLevel] = None)(
        implicit API: SessionAPI[SessionAPI.Op],
        S: Session,
        AC: AsyncContext[M],
        E: MonadError[M, Throwable]): M[Unit] = ???
  }

  final class InterpolatorInsertOps(tuple: (String, InsertStatement, List[SerializableValueBy[Int]])) {
    def asFree[M[_]](consistencyLevel: Option[ConsistencyLevel] = None)(
        implicit API: SessionAPI[M]): FreeS[M, Unit] = ???

    def attempt[M[_]](consistencyLevel: Option[ConsistencyLevel] = None)(
        implicit API: SessionAPI[SessionAPI.Op],
        S: Session,
        AC: AsyncContext[M],
        E: MonadError[M, Throwable]): M[Unit] = ???
  }

  final class InterpolatorUpdateOps(tuple: (String, UpdateStatement, List[SerializableValueBy[Int]])) {
    def asFree[M[_]](consistencyLevel: Option[ConsistencyLevel] = None)(
        implicit API: SessionAPI[M]): FreeS[M, Unit] = ???

    def attempt[M[_]](consistencyLevel: Option[ConsistencyLevel] = None)(
        implicit API: SessionAPI[SessionAPI.Op],
        S: Session,
        AC: AsyncContext[M],
        E: MonadError[M, Throwable]): M[Unit] = ???
  }

Also, add the new cases on the test InterpolatorImplicitSpec: https://github.com/frees-io/freestyle-cassandra/blob/4bd76315aab0684417036a5911577cc3be0cd537/core/src/test/scala/query/interpolator/InterpolatorImplicitSpec.scala#L58-L170