Skip to content

mchinaloy/cl-ea-price-kotlin

Repository files navigation

cl-ea-price-kotlin

A Chainlink compatible External Adapter that supports a REST API and AWS Lambda Handler.

This adapter interfaces with the CryptoCompare data source.

This is a Gradle project built using OpenJDK 15 with Micronaut.

Building the application

  1. Build the JAR:
./gradlew clean build

Run with Docker

  1. Create the Docker image:
docker build -t cl-ea-price-kotlin .
  1. Get your image ID:
docker images
  1. Start the Docker container:
docker run -p 7080:7080 <image_id> 

Run without Docker

  1. To start the application, run the main class:
Main.kt

Sending requests

  1. Send requests as follows:
POST: http://localhost:7080
Headers: Content-Type application/json
Body:
{
    "id": 123,
    "data": {
        "from": "ETH",
        "to": "CAD"
    }
}

Response:

{
    "jobRunId": 123,
    "data": "{\"CAD\":3325.15}"
}

Running the tests

  1. Run the tests using:
./gradlew clean build

Caching (Recommended)

A cache is enabled by default. The adapter does not support an API key (this may be added in a future release).

  1. A Caffeine cache is enabled by default.
  2. It supports the following configuration options in the application.yml:
micronaut.caches.prices.initial-capacity
micronaut.caches.prices.maximum-size
micronaut.caches.prices.maximum-weight
micronaut.caches.prices.expire-after-write
micronaut.caches.prices.expire-after-access

For more information on each property, take a look at the documentation.

Logging

  1. The project uses Logback, which can be configured in:
/src/resources/logback.xml
  1. To enable DEBUG logs, update:
<root level="info">

To:

<root level="debug">