Skip to content

Timeboxer Implementation #14

Open
Open
@cobyyoung

Description

Timeouts are a useful stability pattern, however many high-level APIs omit the ability to set a timeout.

It would be nice if JRugged could provide a solution that allows existing services to be timeboxed.

If the wrapped service takes longer than a predefined timeLimit, the wrapper would throw some sort TimeoutException.

Also, after a timeLimit has been exceed, there should be some (optional) mechanism that attempts to cancel the wrapped service call (perhaps via sending an Interrupt, or a more explicit cancel() method defined by a JRugged Cancellable.cancel() interface).

It would be very nice to include some documentation that illustrates an example of how a Timeboxer could be used to wrap HttpClient calls, such that HttpRequests are nicely aborted after the timeLimit is exceeded.

The wrapper probably needs to expose mechanisms to control the threading model used to execute the Futures that the wrapper service will use internally. Perhaps this is as simple as allowing a custom ExecutorService to be injected into the wrapper.

An optional, but potentially useful, feature could be to allow several services to be simultaneously wrapped in the same timebox. For example: i have a composite service that assembles data from multiple different backends, if any of them haven't finished by the end of the timeLimit, i want to grab the results from the services that did finish and cancel the calls that weren't fast enough.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions