GithubHelp home page GithubHelp logo

Comments (3)

comcast-jonm avatar comcast-jonm commented on June 2, 2024

So you are suggesting something like these additional methods?

public interface Sirius {
  ...
  Future<SiriusResult> <T> enqueuePut(String key, byte[] body, T localData);
}

interface RequestHandler {
  ...
  SiriusResult <T> handlePut(String key, byte[] body, T localData);
}

Possibly the <T> parameters would want to get moved up onto the interfaces so that we could statically check that the RequestHandler can handle the same types of localData that were being enqueued.

from sirius.

smuir avatar smuir commented on June 2, 2024

Yes, exactly like that. I like your suggestion about pushing up the types, as one of the motivations is to give stronger static type checking between enqueue and handle than just reducing everything to Object/AnyRef as in the SiriusResult type.

from sirius.

smuir avatar smuir commented on June 2, 2024

I hacked up a prototype of this interface that build on the Sirius1Dot2 stuff. Essentially it creates new interfaces for the RequestHandler and Sirius instance that are parametrized by two types T and U, and a factory method that is parametrized similarly. The prototypes for enqueuePut and handlePut are as follows (with other interface methods being analogous):

enqueuePut(key: String, body: Array[Byte], tag: T): Future[U]

handlePut(key: String, body: Array[Byte]: tag: Option[T]): U

These are intentionally as general as possible, allowing users to pass in, say, Option as the return type (U). The handler is passed SomeT when receiving a locally-enqueued Put, and None when receiving either a remotely-enqueued Put or during recovery from the WAL. Exceptions in the handler are passed back using the standard Java Future interface, i.e., by throwing an ExecutionException in handlePut, with the thrown exception as the cause value.

The prototype includes sufficient implementation glue to make this all work transparently with the existing interfaces, and satisfy all existing unit tests. It includes the Promise-based workaround I described in Issue #6 for return values not currently being propagated correctly, but I came to the conclusion that that is not a good long-term solution and we should just fix #6.

from sirius.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.