Skip to main content
Version: 0.9.x

Remedy Plugins

Remedy plugins make up for a significant part of Lunar's magic: they allow users to solve API consumption problems with a few lines of configuration.

How It Works

A remedy policy can be defined globally, or on a per-endpoint basis. When a new request arrives at Lunar, it first goes through the process of finding and applying relevant remedy policies. The result of this step might:

  • yield a Lunar-generated response, in which case the original API provider will not be called, or
  • modify the request/response before it goes out to the original API provider or right after it returns from it, or
  • do nothing, and simply forward the call to the original API provider

Similarly to requests, all responses pass through that engine before being returned back to callers. This is key in order for Lunar to work properly. Take the Response-Based Throttling remedy plugin for example: it needs to cache the initial throttled response in order to work properly.

Identifying Responses Generated by Lunar

In case Lunar generated the response for a certain transaction, the x-lunar-generated-response: true header will be added to that response.

Available Remedy Plugins

Lunar offers several remedy plugins that you can use in order to easily solve API consumption problems.

  1. Smart Caching allows to cache responses from API provider for similar requests.
  2. Retry allows to define a retry policy for failed requests
  3. Authentication Mechanism allows to modify login requests to API provider.
  4. API Account Orchestration allows switching auth tokens for requests in a seamless manner. This plugin shines when the struggle to avoid hitting quota can be solved by making calls to a different account registered with the API provider.
  5. Strategy-Based Throttling is similar to Response-Based Throttling, but acts according to a configured quota rather than on dynamic responses' data.
  6. Response-Based Throttling helps in reducing the cooldown period callers must endure after reaching the rate limit set by the API provider, based on headers metadata in responses from the latter.
  7. Concurrency-Based Throttling is similar to Response-Based Throttling, but acts according to a configured max_concurrent_requests rather than on dynamic responses' data.
  8. Strategy-Based Queue This plugin allows delaying requests according to a defined strategy in order to avoid hitting rate limit, including a prioritization mechanism between groups of requests.

Remedy Chaining

In case more than one remedy policy was found, the result of their application will be combined. Read more about remedy chaining here.

Click me for guidance 😀