Ravina Core
Components to ease the development of reliable services.
GitHub Repository
Dependencies
- java.net.http
- systems.comodal.json_iterator
Configuration
Configuration parsers are provided for each component for the purpose of allowing users to configure the service.
Primitives
Time
Durations/windows/delays are ISO-8601 duration formatted
PnDTnHnMn.nS
. The PT
prefix may be omitted.
Backoff
Backoff strategy in response to I/O errors.
Backoff Configuration
- type: single, linear, fibonacci, exponential
- initialRetryDelay
- maxRetryDelay
Backoff Usage
Request Capacity Monitor
Tracks request capacity available to a resource. Intended to be used with Calls to potentially wait until capacity is available before making a request to avoid rate-limiting issues. Capacity is reduced in a weighted fashion per call, and also potentially when response errors are observed.
Capacity Configuration
- maxCapacity: Maximum requests that can be made within resetDuration
- resetDuration: maxCapacity is added over the course of this duration.
- minCapacityDuration: Maximum time before capacity should recover to zero, given that no additional failures happen.
- maxGroupedErrorResponses:
- maxGroupedErrorExpiration:
- tooManyErrorsBackoffDuration:
- serverErrorBackOffDuration: Reduce capacity if remove server errors are observed.
- rateLimitedBackOffDuration: Reduce capacity if rate limit errors are observed.
Capacity Construction
Load Balancer
Somewhat opinionated generic load balancers intended to be used with Calls.
Error Count Backoff
Skips items proportional to how many errors it has. How many times an item is skipped is tracked so that it can move back up the queue to be re-tried.
Sorted
Sorts by error count and then sample call time. Must be driven with requests using nextNoSkip
to sample request
performance.
Single
Wrapper around a single item.
Load Balancer Configuration
- defaultCapacity
- defaultBackoff
- endpoints: Array of remote resources.
- url
- capacity: Overrides defaultCapacity
- backoff: Overrides defaultBackoff
Load Balancer Construction
Remote Call
Facilitates retrying remote calls, using backoff strategies to delay between failures.
If the backoff strategy returns a negative number or the error count exceeds the max retries for the call context, the exception is re-thrown wrapped in a RuntimeException.
Composed
Simple retry logic, does not track any corresponding request capacity for the given resource.
Greedy
Records the consumption of request capacity, but does not wait until available.
Courteous
Waits until the resource has enough capacity, up until maxTryClaim
attempts,
after which it will either give up and return null or force the call.
Remote Call Usage
WebHook Client
Generic client to POST JSON messages.