Uploaded image for project: 'S2Graph'
  1. S2Graph
  2. S2GRAPH-82

Merge DeferCache and FutureCache.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Done
    • Major
    • Resolution: Done
    • 0.1.0
    • 0.1.0
    • None
    • None

    Description

      Currently, under org.apache.s2graph.core.utils package, DeferCache and FutureCache has exactly same behavior except for their Types on Value to store.

      It would be better if we can merge these two class. The problem is that there is no common interface between asynchbase's Deferr and scala's Future.

      I was talk with daewon and here is what we are suggesting, use type class.

      trait CanDefer[A, M[_], C[_]] {
        def promise: M[A]
      
        def future(defer: M[A]): C[A]
      
        def success(defer: M[A], value: A): Unit
      
        def onSuccess[U](defer: C[A])(pf: PartialFunction[A, U])(implicit ec: ExecutionContext)
      }
      

      and change DeferCache interface as follow.

      * M[_] : container type that will be stored in local cache. ex) Promise, Defer.
      * C[_]: container type that will be returned to client of this class. Ex) Future, Defer.
      * A: actual element type that will be stored in M[_]  and C[_].
      
      class DeferCache[A, M[_], C[_]](config: Config)(implicit ec: ExecutionContext, canDefer: CanDefer[A, M, C])
      

      First, define some type class CanDefer that has all common interfaces used in current DeferCache/FutureCache implementation.

      Secondly, provide implicit value for both of Defer and Future.

      Third, change implimentation to use common type class.

      This is what we have sofar, but any better idea would be appreciated.

      Attachments

        Issue Links

          Activity

            People

              daewon Daewon Jeong
              steamshon Do Yung Yoon
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 168h
                  168h
                  Remaining:
                  Remaining Estimate - 168h
                  168h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified