Ravi Srinivasan
2020-05-08 bf85d8ea7d7402eafeb5d46fa98622e6774a251f
Adding exchange app with tracing skeleton
55 files added
13915 ■■■■■ changed files
exchange-traced/.gitignore 1 ●●●● patch | view | raw | blame | history
exchange-traced/README.md 25 ●●●●● patch | view | raw | blame | history
exchange-traced/currencies/.gitignore 8 ●●●●● patch | view | raw | blame | history
exchange-traced/currencies/Dockerfile 15 ●●●●● patch | view | raw | blame | history
exchange-traced/currencies/requirements.txt 13 ●●●●● patch | view | raw | blame | history
exchange-traced/currencies/src/currencies.py 56 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/.gitignore 5 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/Dockerfile 20 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/README.md 20 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/pom.xml 119 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/src/main/java/com/redhat/restclient/CorsFilter.java 22 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/src/main/java/com/redhat/restclient/Currency.java 48 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/src/main/java/com/redhat/restclient/CurrencyResource.java 29 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/src/main/java/com/redhat/restclient/CurrencyService.java 20 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/src/main/java/com/redhat/restclient/ExchangeResource.java 73 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/src/main/java/com/redhat/restclient/ExchangeService.java 21 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/src/main/java/com/redhat/restclient/News.java 31 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/src/main/java/com/redhat/restclient/NewsResource.java 27 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/src/main/java/com/redhat/restclient/NewsService.java 19 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/src/main/resources/META-INF/resources/index.html 152 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/src/main/resources/application.properties 9 ●●●●● patch | view | raw | blame | history
exchange-traced/exchange/src/test/java/com/redhat/restclient/.gitkeep 1 ●●●● patch | view | raw | blame | history
exchange-traced/frontend/.gitignore 23 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/Dockerfile 18 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/README.md 85 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/package.json 40 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/public/favicon.ico patch | view | raw | blame | history
exchange-traced/frontend/public/index.html 43 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/public/logo192.png patch | view | raw | blame | history
exchange-traced/frontend/public/logo512.png patch | view | raw | blame | history
exchange-traced/frontend/public/manifest.json 25 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/public/robots.txt 3 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/App.css 21 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/App.js 40 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/Graph.js 112 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/HistoricalDataForm.js 154 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/Loading.js 27 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/MainStructure.js 49 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/NavList.js 35 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/NewsBoard.js 65 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/SingleCurrencyExchange.js 191 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/Welcome.js 36 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/index.js 13 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/serviceWorker.js 141 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/setupTests.js 5 ●●●●● patch | view | raw | blame | history
exchange-traced/frontend/src/training_black.png patch | view | raw | blame | history
exchange-traced/frontend/src/training_white.png patch | view | raw | blame | history
exchange-traced/frontend/yarn.lock 11398 ●●●●● patch | view | raw | blame | history
exchange-traced/history/.gitignore 23 ●●●●● patch | view | raw | blame | history
exchange-traced/history/Dockerfile 16 ●●●●● patch | view | raw | blame | history
exchange-traced/history/index.js 92 ●●●●● patch | view | raw | blame | history
exchange-traced/history/lib/constants.js 29 ●●●●● patch | view | raw | blame | history
exchange-traced/history/package-lock.json 477 ●●●●● patch | view | raw | blame | history
exchange-traced/history/package.json 16 ●●●●● patch | view | raw | blame | history
exchange-traced/history/test.json 4 ●●●● patch | view | raw | blame | history
exchange-traced/.gitignore
New file
@@ -0,0 +1 @@
.vscode
exchange-traced/README.md
New file
@@ -0,0 +1,25 @@
# Exchange application
This application serves as a test bench for different Service Mesh labs.
The `frontend` folder contains a React app to consume a basic backend.
The backend API gateway is in `exchange`, implemented as a Quarkus service. This service then consumes `currencies` and `history`, in Python and Node.js respectively.
Additionally, `exchange` also simulates a dependency on an external (outside of the cluster) news service. This service is implemented in `../python-flask-gossip` and should be deployed in an separate OCP project.
## Deployment
Before deploying the application, you need Service Mesh installed in a project called `istio-system`. Instructions [here](https://docs.openshift.com/container-platform/4.3/service_mesh/service_mesh_install/preparing-ossm-installation.html).
You can install the optional "external" news service, `python-flask-gossip`, deployed in its own project, and accessible via a route.
Now, process the template and create the resources, specifying the Istio ingress gateway route in _INGRESS_GW_ and the news external service route in _NEWS_ENDPOINT_.
```sh
oc process -o yaml -f kubefiles/exchange-app-template.yml \
    -p INGRESS_GW=exchange-exchange-app.apps.example.com \
    -p NEWS_ENDPOINT=news-gossip-app.apps.example.com | oc create -f -
```
> WARNING: Do not add a preceding 'http://' to the `INGRESS_GW` and `NEWS_ENDPOINT` variables. It should only be a FQDN hostname string.
exchange-traced/currencies/.gitignore
New file
@@ -0,0 +1,8 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/venv
__pycache__
# misc
.DS_Store
exchange-traced/currencies/Dockerfile
New file
@@ -0,0 +1,15 @@
FROM ubi8/python-36
ENV FLASK_APP="currencies.py" \
    JAEGER_AGENT_HOST="jaeger-agent.istio-system"
COPY src /app
COPY requirements.txt /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 5000
CMD [ "flask", "run", "--host=0.0.0.0"]
exchange-traced/currencies/requirements.txt
New file
@@ -0,0 +1,13 @@
click==7.1.1
Flask==1.1.2
Flask-Cors==3.0.8
itsdangerous==1.1.0
jaeger-client==4.3.0
Jinja2==2.11.2
MarkupSafe==1.1.1
opentracing==2.3.0
six==1.14.0
threadloop==1.0.2
thrift==0.13.0
tornado==6.0.4
Werkzeug==1.0.1
exchange-traced/currencies/src/currencies.py
New file
@@ -0,0 +1,56 @@
import logging
import opentracing as ot
from flask import Flask, jsonify, request, g
from flask_cors import CORS
from jaeger_client import Config
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
def init_jaeger_tracer():
    """
    Initializes a tracer
    Tracer is initialized inside a function to prevent deadlocks:
    https://github.com/jaegertracing/jaeger-client-python#initialization--configuration
    """
    # These configuration parameters can't be read from env variables
    # so we need to explicitly set them here
    config = Config(
        service_name='currencies',
        validate=True,
        config={
            'sampler': {'type': 'const', 'param': 1},
            'logging': True,
            'propagation': 'b3'
        }
    )
    return config.initialize_tracer()
tracer = init_jaeger_tracer()
app = Flask(__name__)
CORS(app)
@app.before_request
def start_span():
    headers_dict = {key: value for key, value in request.headers.items()}
    context = tracer.extract(ot.Format.HTTP_HEADERS, headers_dict)
    span_name = f'{request.method}:currencies'
    scope = tracer.start_active_span(span_name, child_of=context)
    scope.span.set_tag(ot.tags.HTTP_URL, request.url)
    scope.span.set_tag(ot.tags.HTTP_METHOD, request.method)
    g.scope = scope
@app.after_request
def close_span(response):
    g.scope.span.set_tag(ot.tags.HTTP_STATUS_CODE, response.status_code)
    g.scope.close()
    return response
@app.route('/')
def currenciesList():
    return jsonify('EUR', 'USD')
exchange-traced/exchange/.gitignore
New file
@@ -0,0 +1,5 @@
.classpath
.settings
.vscode
.project
target
exchange-traced/exchange/Dockerfile
New file
@@ -0,0 +1,20 @@
FROM ubi8:8.1
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV AB_ENABLED=jmx_exporter
# Be prepared for running in OpenShift too
RUN mkdir /deployments \
  && adduser -G root --no-create-home -u 1001 quarkus \
  && chown -R 1001 /deployments \
  && chmod -R "g+rwX" /deployments \
  && chown -R 1001:root /deployments
RUN yum -y install java-1.8.0-openjdk-devel
COPY target/*-runner.jar /deployments/app.jar
EXPOSE 8080 8778 9779
# run with user 1001
USER 1001
CMD ["java","-jar","/deployments/app.jar"]
exchange-traced/exchange/README.md
New file
@@ -0,0 +1,20 @@
# Exchange project
This project uses Quarkus, the Supersonic Subatomic Java Framework.
If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
## Packaging and running the application
The application is packageable using `mvn clean package`.
It produces the executable `exchange-1.0-SNAPSHOT-runner.jar` file in `/target` directory.
Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/lib` directory.
The application is now runnable using `java -jar target/exchange-1.0-SNAPSHOT-runner.jar`.
## Creating a native executable
A dockerfile was created for building a native executable.
Execute `podman build -t $quay_registry/exchange:$version .` to build a native executable.
exchange-traced/exchange/pom.xml
New file
@@ -0,0 +1,119 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.redhat</groupId>
  <artifactId>exchange</artifactId>
  <version>1.0-SNAPSHOT</version>
  <properties>
    <compiler-plugin.version>3.8.1</compiler-plugin.version>
    <maven.compiler.parameters>true</maven.compiler.parameters>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <quarkus-plugin.version>1.3.2.Final</quarkus-plugin.version>
    <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
    <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
    <quarkus.platform.version>1.3.2.Final</quarkus.platform.version>
    <surefire-plugin.version>2.22.1</surefire-plugin.version>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>${quarkus.platform.group-id}</groupId>
        <artifactId>${quarkus.platform.artifact-id}</artifactId>
        <version>${quarkus.platform.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-junit5</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>rest-assured</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-rest-client</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy-jackson</artifactId>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-maven-plugin</artifactId>
        <version>${quarkus-plugin.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>build</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${compiler-plugin.version}</version>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire-plugin.version}</version>
        <configuration>
          <systemProperties>
            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
          </systemProperties>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>native</id>
      <activation>
        <property>
          <name>native</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${surefire-plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
                <configuration>
                  <systemProperties>
                    <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                  </systemProperties>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <properties>
        <quarkus.package.type>native</quarkus.package.type>
      </properties>
    </profile>
  </profiles>
</project>
exchange-traced/exchange/src/main/java/com/redhat/restclient/CorsFilter.java
New file
@@ -0,0 +1,22 @@
package com.redhat.restclient;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.Provider;
import java.io.IOException;
@Provider
public class CorsFilter implements ContainerResponseFilter {
    @Override
    public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException {
        MultivaluedMap<String, Object> headers = containerResponseContext.getHeaders();
        headers.putSingle("Access-Control-Allow-Origin", "*");
        headers.putSingle("Access-Control-Allow-Credentials", "true");
        headers.putSingle("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
        headers.putSingle("Access-Control-Allow-Headers", "Access-Control-Allow-Origin, Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers");
    }
}
exchange-traced/exchange/src/main/java/com/redhat/restclient/Currency.java
New file
@@ -0,0 +1,48 @@
package com.redhat.restclient;
public class Currency {
    private String value;
    private String date;
    private String sign;
    private String name;
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
    public String getSign() {
        return sign;
    }
    public void setSign(String sign) {
        this.sign = sign;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Override
    public String toString() {
        return "Currency{" +
                "value='" + value + '\'' +
                ", date='" + date + '\'' +
                '}';
    }
}
exchange-traced/exchange/src/main/java/com/redhat/restclient/CurrencyResource.java
New file
@@ -0,0 +1,29 @@
package com.redhat.restclient;
import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.eclipse.microprofile.opentracing.Traced;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;
@Path("/currencies")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Traced
public class CurrencyResource {
    @Inject
    @RestClient
    CurrencyService currencies;
    @GET
    public List<String> getCurrencyNames() {
        return currencies.getCurrencyNames();
    }
}
exchange-traced/exchange/src/main/java/com/redhat/restclient/CurrencyService.java
New file
@@ -0,0 +1,20 @@
package com.redhat.restclient;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;
@Path("/")
@RegisterRestClient
public interface CurrencyService {
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    List<String> getCurrencyNames();
}
exchange-traced/exchange/src/main/java/com/redhat/restclient/ExchangeResource.java
New file
@@ -0,0 +1,73 @@
package com.redhat.restclient;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.microprofile.rest.client.inject.RestClient;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;
@Path("/exchangeRate")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class ExchangeResource {
    @Inject
    @RestClient
    ExchangeService historyService;
    @Inject
    @RestClient
    NewsService newsService;
    ObjectMapper mapper = new ObjectMapper();
    @GET
    @Path("/news")
    public List<News> getFinancialNews() {
        return newsService.getFinancialNews();
    }
    @POST
    @Path("/historicalData")
    public List<Currency> getHistoricalData(String body) {
        try {
            Thread.sleep(5000);
        }
        catch(InterruptedException ie) {
            ie.printStackTrace();
        }
        return historyService.getCurrencyExchangeRates(body);
    }
    @POST
    @Path("/singleCurrency")
    public Currency getExchangeRate(String body) {
        List<Currency> currencies = historyService.getCurrencyExchangeRates(body);
        Currency latestCurrency = currencies.get(0);
        try {
            String target = mapper.readTree(body).get("target").asText();
            if(target.equals("USD")) {
                latestCurrency.setSign("$");
            } else {
                latestCurrency.setSign("€");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return latestCurrency;
    }
    // A simple health check of the service, as well as
    // connectivity check between the service and other services
    @GET
    public String ping() {
        return "pong";
    }
}
exchange-traced/exchange/src/main/java/com/redhat/restclient/ExchangeService.java
New file
@@ -0,0 +1,21 @@
package com.redhat.restclient;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;
// Path on the service we're calling
@Path("/")
@RegisterRestClient
public interface ExchangeService {
    @POST
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    List<Currency> getCurrencyExchangeRates(String body);
}
exchange-traced/exchange/src/main/java/com/redhat/restclient/News.java
New file
@@ -0,0 +1,31 @@
package com.redhat.restclient;
public class News {
    private String id;
    private Integer timestamp;
    private String title;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public Integer getTimestamp() {
        return timestamp;
    }
    public void setTimestamp(Integer timestamp) {
        this.timestamp = timestamp;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
}
exchange-traced/exchange/src/main/java/com/redhat/restclient/NewsResource.java
New file
@@ -0,0 +1,27 @@
package com.redhat.restclient;
import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.eclipse.microprofile.opentracing.Traced;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;
@Path("/news")
@Produces(MediaType.APPLICATION_JSON)
@Traced
public class NewsResource {
    @Inject
    @RestClient
    NewsService news;
    @GET
    public List<News> getFinancialNews() {
        return news.getFinancialNews();
    }
}
exchange-traced/exchange/src/main/java/com/redhat/restclient/NewsService.java
New file
@@ -0,0 +1,19 @@
package com.redhat.restclient;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;
@Path("/")
@RegisterRestClient
public interface NewsService {
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    List<News> getFinancialNews();
}
exchange-traced/exchange/src/main/resources/META-INF/resources/index.html
New file
@@ -0,0 +1,152 @@
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>exchange - 1.0-SNAPSHOT</title>
    <style>
        h1, h2, h3, h4, h5, h6 {
            margin-bottom: 0.5rem;
            font-weight: 400;
            line-height: 1.5;
        }
        h1 {
            font-size: 2.5rem;
        }
        h2 {
            font-size: 2rem
        }
        h3 {
            font-size: 1.75rem
        }
        h4 {
            font-size: 1.5rem
        }
        h5 {
            font-size: 1.25rem
        }
        h6 {
            font-size: 1rem
        }
        .lead {
            font-weight: 300;
            font-size: 2rem;
        }
        .banner {
            font-size: 2.7rem;
            margin: 0;
            padding: 2rem 1rem;
            background-color: #00A1E2;
            color: white;
        }
        body {
            margin: 0;
            font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
        }
        code {
            font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
            font-size: 87.5%;
            color: #e83e8c;
            word-break: break-word;
        }
        .left-column {
            padding: .75rem;
            max-width: 75%;
            min-width: 55%;
        }
        .right-column {
            padding: .75rem;
            max-width: 25%;
        }
        .container {
            display: flex;
            width: 100%;
        }
        li {
            margin: 0.75rem;
        }
        .right-section {
            margin-left: 1rem;
            padding-left: 0.5rem;
        }
        .right-section h3 {
            padding-top: 0;
            font-weight: 200;
        }
        .right-section ul {
            border-left: 0.3rem solid #00A1E2;
            list-style-type: none;
            padding-left: 0;
        }
    </style>
</head>
<body>
<div class="banner lead">
    Your new Cloud-Native application is ready!
</div>
<div class="container">
    <div class="left-column">
        <p class="lead"> Congratulations, you have created a new Quarkus application.</p>
        <h2>Why do you see this?</h2>
        <p>This page is served by Quarkus. The source is in
            <code>src/main/resources/META-INF/resources/index.html</code>.</p>
        <h2>What can I do from here?</h2>
        <p>If not already done, run the application in <em>dev mode</em> using: <code>mvn compile quarkus:dev</code>.
        </p>
        <ul>
            <li>Add REST resources, Servlets, functions and other services in <code>src/main/java</code>.</li>
            <li>Your static assets are located in <code>src/main/resources/META-INF/resources</code>.</li>
            <li>Configure your application in <code>src/main/resources/application.properties</code>.
            </li>
        </ul>
        <h2>How do I get rid of this page?</h2>
        <p>Just delete the <code>src/main/resources/META-INF/resources/index.html</code> file.</p>
    </div>
    <div class="right-column">
        <div class="right-section">
            <h3>Application</h3>
            <ul>
                <li>GroupId: com.redhat</li>
                <li>ArtifactId: exchange</li>
                <li>Version: 1.0-SNAPSHOT</li>
                <li>Quarkus Version: 1.2.1.Final</li>
            </ul>
        </div>
        <div class="right-section">
            <h3>Next steps</h3>
            <ul>
                <li><a href="https://quarkus.io/guides/maven-tooling.html" target="_blank">Setup your IDE</a></li>
                <li><a href="https://quarkus.io/guides/getting-started.html" target="_blank">Getting started</a></li>
                <li><a href="https://quarkus.io" target="_blank">Quarkus Web Site</a></li>
            </ul>
        </div>
    </div>
</div>
</body>
</html>
exchange-traced/exchange/src/main/resources/application.properties
New file
@@ -0,0 +1,9 @@
# Configuration file
com.redhat.restclient.ExchangeService/mp-rest/url=http://history:8080
com.redhat.restclient.ExchangeService/mp-rest/scope=javax.inject.Singleton
com.redhat.restclient.CurrencyService/mp-rest/url=http://currency:5000
com.redhat.restclient.CurrencyService/mp-rest/scope=javax.inject.Singleton
com.redhat.restclient.NewsService/mp-rest/url=${NEWS_ENDPOINT}/news/finance
com.redhat.restclient.NewsService/mp-rest/scope=javax.inject.Singleton
quarkus.http.port=8080
quarkus.package.uber-jar=true
exchange-traced/exchange/src/test/java/com/redhat/restclient/.gitkeep
New file
@@ -0,0 +1 @@
exchange-traced/frontend/.gitignore
New file
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
exchange-traced/frontend/Dockerfile
New file
@@ -0,0 +1,18 @@
FROM ubi8/nodejs-12
# URL of the exchange app
# All env vars exposed to the React app must start with REACT_APP
ENV REACT_APP_GW_ENDPOINT=exchange-exchange-app.apps.ocp-d43.dev.nextcle.com
# Cache dependencies
COPY package.json .
RUN npm install
# Cache public files
COPY public ./public
COPY src ./src
EXPOSE 3000
CMD npm start
exchange-traced/frontend/README.md
New file
@@ -0,0 +1,85 @@
# Frontend Microservice
This is the frontend microservice that displays data from our exchange application.
The entry point is at `src/index.js` -> `src/app.js`.
The frontend currently works with the `history` shim microservice.
For testing, start run `history` accessible on `localhost:8080` and then start `frontend` (on any port).
## TODO Stretch Goals
* Finish Status dashboard
* Refactor into nicer directory structure
* Move to TypeScript
# Documentation
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `yarn start`
Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br />
You will also see any lint errors in the console.
### `yarn test`
Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `yarn build`
Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `yarn eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
### Analyzing the Bundle Size
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
### Making a Progressive Web App
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
### Advanced Configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
### Deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
### `yarn build` fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
exchange-traced/frontend/package.json
New file
@@ -0,0 +1,40 @@
{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "homepage": "/frontend",
  "dependencies": {
    "@patternfly/react-charts": "^5.3.5",
    "@patternfly/react-core": "^3.140.11",
    "@patternfly/react-table": "^2.28.10",
    "@patternfly/react-icons": "^3.15.12",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "react": "^16.13.0",
    "react-dom": "^16.13.0",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.4.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
exchange-traced/frontend/public/favicon.ico
exchange-traced/frontend/public/index.html
New file
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="DO328 application"
    />
    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.
      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>Exchange Application</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.
      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.
      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
  </body>
</html>
exchange-traced/frontend/public/logo192.png
exchange-traced/frontend/public/logo512.png
exchange-traced/frontend/public/manifest.json
New file
@@ -0,0 +1,25 @@
{
  "short_name": "React App",
  "name": "Create React App Sample",
  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "64x64 32x32 24x24 16x16",
      "type": "image/x-icon"
    },
    {
      "src": "logo192.png",
      "type": "image/png",
      "sizes": "192x192"
    },
    {
      "src": "logo512.png",
      "type": "image/png",
      "sizes": "512x512"
    }
  ],
  "start_url": ".",
  "display": "standalone",
  "theme_color": "#000000",
  "background_color": "#ffffff"
}
exchange-traced/frontend/public/robots.txt
New file
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
exchange-traced/frontend/src/App.css
New file
@@ -0,0 +1,21 @@
.centered {
    text-align: center;
}
.margin-separator {
    margin-top: 20px;
}
.text-container {
    text-align: center;
    font-size: 3em;
    max-width: 300px;
    border-bottom-style: solid;
    border-color: #2b9af3;
    word-wrap: break-word;
}
.currency-text {
    font-size: 0.6em;
    vertical-align: top;
}
exchange-traced/frontend/src/App.js
New file
@@ -0,0 +1,40 @@
import React, { Component } from 'react';
import Structure from './MainStructure'
import HistoricalDataForm from './HistoricalDataForm'
import WelcomePage from './Welcome'
import SingleCurrencyExchange from './SingleCurrencyExchange'
import NewsBoard from './NewsBoard'
import {
  BrowserRouter as Router,
  Switch,
  Route,
} from "react-router-dom";
class App extends Component {
  render() {
    return (
      <Router basename="/frontend">
        <Switch>
          <Structure>
            <Route path="/" exact >
              <WelcomePage />
            </Route>
            <Route path="/exchange" exact>
              <SingleCurrencyExchange />
            </Route>
            <Route path="/history" exact>
              <HistoricalDataForm />
            </Route>
            <Route path="/news" exact>
              <NewsBoard />
            </Route>
          </Structure>
        </Switch>
      </Router>
    )
  }
}
export default App;
exchange-traced/frontend/src/Graph.js
New file
@@ -0,0 +1,112 @@
import React from 'react';
import { Chart, ChartAxis, ChartGroup, ChartLine, ChartScatter, ChartThemeColor, ChartVoronoiContainer } from '@patternfly/react-charts';
export default class ScatterLineChart extends React.Component {
    constructor(props) {
        super(props);
        this.containerRef = React.createRef();
        this.state = {
            width: 0,
            series: "",
        };
        this.handleResize = () => {
            if (this.containerRef.current && this.containerRef.current.clientWidth) {
                this.setState({ width: this.containerRef.current.clientWidth });
            }
        };
    }
    componentDidMount() {
        this.handleResize();
        window.addEventListener('resize', this.handleResize);
    }
    componentWillUnmount() {
        window.removeEventListener('resize', this.handleResize);
    }
    render() {
        const { width } = this.state;
        var conv = []
        var maxYAxis = 0
        this.props.data.forEach(e => {
            var floatValue = parseFloat(e.value);
            if(floatValue > maxYAxis) {
                maxYAxis = floatValue
            }
            const date = new Date(e.date)
            const dateString = `${date.getDate()}/${date.getMonth() + 1}`
            conv.unshift({
                name: this.props.target,
                x: dateString,
                y: floatValue
            })
        });
        const series = [
            {
                datapoints: conv,
                legendItem: { name: 'Conversion' }
            }
        ];
        return (
            <div ref={this.containerRef}>
                <div style={{ height: '275px' }}>
                    <Chart
                        ariaDesc="Exchange rate for given currency"
                        ariaTitle="Exchange Rate Graph"
                        containerComponent={
                            <ChartVoronoiContainer
                                labels={({ datum }) => datum.childName.includes('line-') ? `${datum.name}: ${datum.y}` : null}
                                constrainToVisibleArea
                            />
                        }
                        legendData={series.map(s => s.legendItem)}
                        legendPosition="bottom-left"
                        height={275}
                        maxDomain={{ y: maxYAxis + 0.2 }}
                        minDomain={{ y: 0 }}
                        padding={{
                            bottom: 75, // Adjusted to accommodate legend
                            left: 50,
                            right: 50,
                            top: 50
                        }}
                        themeColor={ChartThemeColor.blue}
                        width={width}
                    >
                        <ChartAxis tickValues={[2, 3, 4]} />
                        <ChartAxis dependentAxis showGrid tickValues={[2, 5, 8]} />
                        <ChartGroup>
                            {series.map((s, idx) => {
                                return (
                                    <ChartScatter
                                        data={s.datapoints}
                                        key={'scatter-' + idx}
                                        name={'scatter-' + idx}
                                    />
                                );
                            })}
                        </ChartGroup>
                        <ChartGroup>
                            {series.map((s, idx) => {
                                return (
                                    <ChartLine
                                        key={'line-' + idx}
                                        name={'line-' + idx}
                                        data={s.datapoints}
                                    />
                                );
                            })}
                        </ChartGroup>
                    </Chart>
                </div>
            </div>
        );
    }
}
exchange-traced/frontend/src/HistoricalDataForm.js
New file
@@ -0,0 +1,154 @@
import React, { Component } from 'react';
import {
    Form,
    FormGroup,
    FormSelect,
    FormSelectOption,
    Button,
    TextContent,
    Text,
    Flex,
    FlexItem,
} from '@patternfly/react-core';
import Spinner from './Loading';
import RenderedChart from './Graph'
class CurrencyPicker extends Component {
    constructor(props) {
        super(props);
        this.state = {
            loading: false,
            currencies: [],
            src: 'Loading currencies',
            target: 'Loading currencies',
            exchangeData: '',
            requestExchangeData: false,
            inputValue: 1,
            inputValid: true,
        };
    }
    componentDidMount() {
        this.setState({
            loading: true
        })
        fetch(`http://${process.env.REACT_APP_GW_ENDPOINT}/currencies`)
            .then(currencies => currencies.json())
            .then(currencies => this.setState({
                currencies, src: currencies[0], target: currencies[1], loading: false
            }))
            .catch(err => console.log(err));
    }
    onChangeSrc = (src) => {
        this.setState({ src });
    };
    onChangeTarget = (target) => {
        this.setState({ target });
    };
    onChangeInput = (inputValue) => {
        const inputValid = this.inputValidation(inputValue);
        this.setState({ inputValue, inputValid });
    }
    inputValidation = (input) => {
        return input > 0
    }
    submit = (e) => {
        e.preventDefault();
        this.setState({ requestExchangeData: true })
        const payload = {
            source: this.state.src,
            target: this.state.target
        }
        fetch(`http://${process.env.REACT_APP_GW_ENDPOINT}/exchangeRate/historicalData`, {
            method: 'POST',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(payload)
        })
            .then(exchangeData => {
                exchangeData.json().then( json => {
                    this.setState({ exchangeData: json })
                })
            })
            .catch(err => console.log(err))
    };
    render() {
        const { exchangeData, requestExchangeData } = this.state;
        return (
            <React.Fragment>
                <TextContent>
                    <Text component="h1" className="centered">
                        <b>Historical Currency Data</b>
                    </Text>
                </TextContent>
                <Form onSubmit={this.submit} >
                    <Flex>
                        <FlexItem>
                            <FormGroup
                                isInline={true}
                                label="Source currency"
                                fieldId="source_group"
                            >
                                <FormSelect
                                    value={this.state.src}
                                    onChange={this.onChangeSrc}
                                    id="src"
                                    aria-label="FormSelect Input"
                                >
                                    {this.state.loading
                                        ? <FormSelectOption isDisabled={true} label="Loading currencies" />
                                        : this.state.currencies.map((curr, index) => (
                                            <FormSelectOption key={index} value={curr} label={curr} />
                                        ))
                                    }
                                </FormSelect>
                            </FormGroup>
                        </FlexItem>
                        <FlexItem>
                            <FormGroup
                                label="Target currency"
                                isInline={true}
                                fieldId="target_group"
                            >
                                <FormSelect
                                    value={this.state.target}
                                    onChange={this.onChangeTarget}
                                    id="target"
                                    aria-label="FormSelect Input"
                                >
                                    {this.state.loading
                                        ? <FormSelectOption isDisabled={true} label="Loading currencies" />
                                        : this.state.currencies.map((curr, index) => (
                                            <FormSelectOption key={index} value={curr} label={curr} />
                                        ))
                                    }
                                </FormSelect>
                            </FormGroup>
                        </FlexItem>
                    </Flex>
                    <span>
                        <Button isDisabled={this.state.loading || this.state.src === this.state.target} type="submit" variant="primary">Submit</Button>
                    </span>
                </Form>
                {requestExchangeData && exchangeData && <RenderedChart data={exchangeData} target={this.state.target} amount={this.state.amount} />}
                {requestExchangeData && !exchangeData && <Spinner />}
            </React.Fragment>
        )
    }
};
export default CurrencyPicker;
exchange-traced/frontend/src/Loading.js
New file
@@ -0,0 +1,27 @@
import React from 'react';
import {
  Title,
  EmptyState,
  EmptyStateIcon,
} from '@patternfly/react-core';
const EmptyStateSpinner = () => {
  const Spinner = () => (
    <span className="pf-c-spinner" role="progressbar" aria-valuetext="Loading...">
      <span className="pf-c-spinner__clipper" />
      <span className="pf-c-spinner__lead-ball" />
      <span className="pf-c-spinner__tail-ball" />
    </span>
  )
  return (
    <EmptyState>
      <EmptyStateIcon variant="container" component={Spinner} />
      <Title size="lg">
        Loading
      </Title>
    </EmptyState>
  );
}
export default EmptyStateSpinner;
exchange-traced/frontend/src/MainStructure.js
New file
@@ -0,0 +1,49 @@
import React from 'react';
import { Brand, Page, PageHeader, PageSidebar, PageSection } from '@patternfly/react-core';
import imgBrand from './training_white.png'
import NavList from './NavList'
class VerticalPage extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      isNavOpen: true,
    };
    this.onNavToggle = () => {
      this.setState({
        isNavOpen: !this.state.isNavOpen
      });
    };
  }
  render() {
    const { isNavOpen } = this.state;
    const logoProps = {
      href: '/frontend'
    };
    const Header = (
      <PageHeader
        logo={<Brand src={imgBrand} alt="Patternfly Logo" />}
        logoProps={logoProps}
        showNavToggle
        isNavOpen={isNavOpen}
        onNavToggle={this.onNavToggle}
        style={{ borderTop: "2px solid #c00" }}
      />
    );
    const Sidebar = <PageSidebar nav={<NavList/>} isNavOpen={isNavOpen} theme="dark" />;
    return (
      <Page header={Header} sidebar={Sidebar} style={{minHeight: 800}}>
        <PageSection >
          {this.props.children}
        </PageSection>
      </Page>
    );
  }
}
export default VerticalPage;
exchange-traced/frontend/src/NavList.js
New file
@@ -0,0 +1,35 @@
import React from 'react';
import {
    Nav,
    NavItem,
    NavList,
} from '@patternfly/react-core';
import { Link} from "react-router-dom";
class NavDefaultList extends React.Component {
    render() {
        return (
            <Nav onSelect={this.onSelect} theme="dark">
                <NavList>
                    <NavItem id="home" isActive={window.location.pathname.endsWith("/")}>
                        <Link to="/">Home</Link>
                    </NavItem>
                    <NavItem id="historical_Data" isActive={window.location.pathname.endsWith("/history")}>
                        <Link to="/history" >Historical Data</Link>
                    </NavItem>
                    <NavItem id="exchange" isActive={window.location.pathname.endsWith("/exchange")}>
                        <Link to="/exchange" >Exchange</Link>
                    </NavItem>
                    <NavItem id="news" isActive={window.location.pathname.endsWith("/news")}>
                        <Link to="/news" >News</Link>
                    </NavItem>
                </NavList>
            </Nav>
        );
    }
}
export default NavDefaultList;
exchange-traced/frontend/src/NewsBoard.js
New file
@@ -0,0 +1,65 @@
import React, { Component } from 'react';
import { Table, TableHeader, TableBody } from '@patternfly/react-table';
import { EmptyState, EmptyStateIcon, EmptyStateBody, EmptyStateVariant, Bullseye, Title } from '@patternfly/react-core';
import { ErrorCircleOIcon } from '@patternfly/react-icons'
class NewsBoard extends Component {
    normalize(data) {
        return data.map(function (element) {
            return {
                cells: [element.timestamp, element.title]
            }
        });
    }
    componentDidMount() {
        fetch(`http://${process.env.REACT_APP_GW_ENDPOINT}/news`)
            .then(res => res.json())
            .then((data) => {
                this.setState({ rows: this.normalize(data) });
            })
            .catch(console.log)
    }
    constructor(props) {
        super(props);
        this.state = {
            columns: ['Timestamp', 'Story'],
            rows: [{
                heightAuto: true,
                cells: [
                    {
                        props: { colSpan: 2 },
                        title: (
                            <Bullseye>
                                <EmptyState variant={EmptyStateVariant.small}>
                                    <EmptyStateIcon icon={ErrorCircleOIcon} />
                                    <Title headingLevel="h2" size="lg">
                                        No results found
                                    </Title>
                                    <EmptyStateBody>
                                        Unable to get news from external feed.
                                    </EmptyStateBody>
                                </EmptyState>
                            </Bullseye>
                        )
                    },
                ]
            }]
        }
    }
    render() {
        const { columns, rows } = this.state;
        return (
            <Table caption="Latest News" rows={rows} cells={columns}>
            <TableHeader />
            <TableBody />
            </Table>
        )
    }
}
export default NewsBoard;
exchange-traced/frontend/src/SingleCurrencyExchange.js
New file
@@ -0,0 +1,191 @@
import React, { Component } from 'react';
import {
    Form,
    FormGroup,
    FormSelect,
    FormSelectOption,
    Button,
    TextContent,
    Text,
    TextInput,
    TextVariants,
    Flex,
    FlexItem,
} from '@patternfly/react-core';
import Spinner from './Loading';
class CurrencyPicker extends Component {
    constructor(props) {
        super(props);
        this.state = {
            loading: false,
            currencies: [],
            src: 'Loading currencies',
            target: 'Loading currencies',
            exchangeData: '',
            requestExchangeData: false,
            inputValue: 1,
            inputValid: true,
        };
    }
    componentDidMount() {
        this.setState({
            loading: true
        })
        fetch(`http://${process.env.REACT_APP_GW_ENDPOINT}/currencies`)
            .then(currencies => currencies.json())
            .then(currencies => this.setState({
                currencies, src: currencies[0], target: currencies[1], loading: false
            }))
            .catch(err => console.log(err));
    }
    onChangeSrc = (src) => {
        this.setState({ src, requestExchangeData: false });
    };
    onChangeTarget = (target) => {
        this.setState({ target, requestExchangeData: false });
    };
    onChangeInput = (inputValue) => {
        const inputValid = this.inputValidation(inputValue);
        this.setState({ inputValue, inputValid });
    }
    inputValidation = (input) => {
        return input > 0
    }
    submit = (e) => {
        e.preventDefault();
        this.setState({ requestExchangeData: true })
        const payload = {
            source: this.state.src,
            target: this.state.target
        }
        fetch(`http://${process.env.REACT_APP_GW_ENDPOINT}/exchangeRate/singleCurrency`, {
            method: 'POST',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(payload)
        })
        .then(exchangeData => exchangeData.json().then(exchangeData => this.setState({exchangeData})))
        .catch(err => console.log(err))
    };
    render() {
        const { exchangeData, requestExchangeData } = this.state;
        return (
            <React.Fragment>
                <TextContent>
                    <Text component="h1" className="centered">
                        <b>Single Currency Exchange</b>
                    </Text>
                </TextContent>
                <Form onSubmit={this.submit} >
                    <Flex>
                        <FlexItem>
                            <FormGroup
                                isInline={true}
                                label="Amount"
                                fieldId="amount_group"
                            >
                                <TextInput
                                    value={this.state.inputValue}
                                    name="amount"
                                    type="number"
                                    onChange={this.onChangeInput}
                                    isValid={this.state.inputValid}
                                    aria-label="amount from input" />
                            </FormGroup>
                        </FlexItem>
                        <FlexItem>
                            <FormGroup
                                isInline={true}
                                label="Source currency"
                                fieldId="source_group"
                            >
                                <FormSelect
                                    value={this.state.src}
                                    onChange={this.onChangeSrc}
                                    id="src"
                                    aria-label="FormSelect Input"
                                >
                                    {this.state.loading
                                        ? <FormSelectOption isDisabled={true} label="Loading currencies" />
                                        : this.state.currencies.map((curr, index) => (
                                            <FormSelectOption key={index} value={curr} label={curr} />
                                        ))
                                    }
                                </FormSelect>
                            </FormGroup>
                        </FlexItem>
                        <FlexItem>
                            <FormGroup
                                label="Target currency"
                                isInline={true}
                                fieldId="target_group"
                            >
                                <FormSelect
                                    value={this.state.target}
                                    onChange={this.onChangeTarget}
                                    id="target"
                                    aria-label="FormSelect Input"
                                >
                                    {this.state.loading
                                        ? <FormSelectOption isDisabled={true} label="Loading currencies" />
                                        : this.state.currencies.map((curr, index) => (
                                            <FormSelectOption key={index} value={curr} label={curr} />
                                        ))
                                    }
                                </FormSelect>
                            </FormGroup>
                        </FlexItem>
                    </Flex>
                    <span>
                        <Button isDisabled={this.isLoadingOrCurrenciesEqual()} type="submit" variant="primary">Submit</Button>
                    </span>
                </Form>
                {this.displayConversion() &&
                    <div>
                        <TextContent className="margin-separator">
                            <Text component={TextVariants.p} className="text-container">
                                <span className="currency-text">
                                    {exchangeData.sign}
                                </span>
                                {exchangeData.value * this.state.inputValue}
                            </Text>
                        </TextContent>
                    </div>
                }
                {requestExchangeData && !exchangeData && <Spinner />}
            </React.Fragment>
        )
    }
    displayConversion() {
        const {requestExchangeData, exchangeData, src, target, inputValue} = this.state;
        return requestExchangeData && exchangeData &&
            (src !== target) &&
            this.inputValidation(inputValue);
    }
    isLoadingOrCurrenciesEqual() {
        const {loading, src, target, inputValue} = this.state;
        return loading || (src === target) || (!this.inputValidation(inputValue));
    }
};
export default CurrencyPicker;
exchange-traced/frontend/src/Welcome.js
New file
@@ -0,0 +1,36 @@
import React, { Component } from 'react';
import rhtLogo from './training_black.png'
import { TextContent, Text } from '@patternfly/react-core'
export default class WelcomePage extends Component {
    render() {
        return (
            <TextContent>
                <Text component="h1" className="centered">
                    <b>Welcome to the currency exchange application of DO328!</b>
                </Text>
                <div className="centered">
                    <img src={rhtLogo} alt="Red Hat Training Logo" />
                </div>
                <Text component="p">
                    Please choose one of the two links on the left:
                </Text>
                <ul>
                    <li>Historical data for seeing currency's exchange rate in time</li>
                    <li>Exchange for seeing how much money is your amount worth in a different currency</li>
                </ul>
                <Text component="p">
                    For detailed info about the structure of this application, see the
                    <Text component="a" href="https://github.com/RedHatTraining/DO328-apps/" >
                        DO328-apps
                    </Text> repository.
                </Text>
                <Text component="p">
                    You can ask questions or file issues at <Text component="a" src="https://github.com/RedHatTraining/DO328-apps/issues"> here</Text>.
                </Text>
            </TextContent>
        )
    }
}
exchange-traced/frontend/src/index.js
New file
@@ -0,0 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom';
import '@patternfly/react-core/dist/styles/base.css';
import './App.css'
import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
exchange-traced/frontend/src/serviceWorker.js
New file
@@ -0,0 +1,141 @@
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
  window.location.hostname === 'localhost' ||
    // [::1] is the IPv6 localhost address.
    window.location.hostname === '[::1]' ||
    // 127.0.0.0/8 are considered localhost for IPv4.
    window.location.hostname.match(
      /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
    )
);
export function register(config) {
  if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
    // The URL constructor is available in all browsers that support SW.
    const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
    if (publicUrl.origin !== window.location.origin) {
      // Our service worker won't work if PUBLIC_URL is on a different origin
      // from what our page is served on. This might happen if a CDN is used to
      // serve assets; see https://github.com/facebook/create-react-app/issues/2374
      return;
    }
    window.addEventListener('load', () => {
      const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
      if (isLocalhost) {
        // This is running on localhost. Let's check if a service worker still exists or not.
        checkValidServiceWorker(swUrl, config);
        // Add some additional logging to localhost, pointing developers to the
        // service worker/PWA documentation.
        navigator.serviceWorker.ready.then(() => {
          console.log(
            'This web app is being served cache-first by a service ' +
              'worker. To learn more, visit https://bit.ly/CRA-PWA'
          );
        });
      } else {
        // Is not localhost. Just register service worker
        registerValidSW(swUrl, config);
      }
    });
  }
}
function registerValidSW(swUrl, config) {
  navigator.serviceWorker
    .register(swUrl)
    .then(registration => {
      registration.onupdatefound = () => {
        const installingWorker = registration.installing;
        if (installingWorker == null) {
          return;
        }
        installingWorker.onstatechange = () => {
          if (installingWorker.state === 'installed') {
            if (navigator.serviceWorker.controller) {
              // At this point, the updated precached content has been fetched,
              // but the previous service worker will still serve the older
              // content until all client tabs are closed.
              console.log(
                'New content is available and will be used when all ' +
                  'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
              );
              // Execute callback
              if (config && config.onUpdate) {
                config.onUpdate(registration);
              }
            } else {
              // At this point, everything has been precached.
              // It's the perfect time to display a
              // "Content is cached for offline use." message.
              console.log('Content is cached for offline use.');
              // Execute callback
              if (config && config.onSuccess) {
                config.onSuccess(registration);
              }
            }
          }
        };
      };
    })
    .catch(error => {
      console.error('Error during service worker registration:', error);
    });
}
function checkValidServiceWorker(swUrl, config) {
  // Check if the service worker can be found. If it can't reload the page.
  fetch(swUrl, {
    headers: { 'Service-Worker': 'script' }
  })
    .then(response => {
      // Ensure service worker exists, and that we really are getting a JS file.
      const contentType = response.headers.get('content-type');
      if (
        response.status === 404 ||
        (contentType != null && contentType.indexOf('javascript') === -1)
      ) {
        // No service worker found. Probably a different app. Reload the page.
        navigator.serviceWorker.ready.then(registration => {
          registration.unregister().then(() => {
            window.location.reload();
          });
        });
      } else {
        // Service worker found. Proceed as normal.
        registerValidSW(swUrl, config);
      }
    })
    .catch(() => {
      console.log(
        'No internet connection found. App is running in offline mode.'
      );
    });
}
export function unregister() {
  if ('serviceWorker' in navigator) {
    navigator.serviceWorker.ready
      .then(registration => {
        registration.unregister();
      })
      .catch(error => {
        console.error(error.message);
      });
  }
}
exchange-traced/frontend/src/setupTests.js
New file
@@ -0,0 +1,5 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom/extend-expect';
exchange-traced/frontend/src/training_black.png
exchange-traced/frontend/src/training_white.png
exchange-traced/frontend/yarn.lock
New file
Diff too large
exchange-traced/history/.gitignore
New file
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
exchange-traced/history/Dockerfile
New file
@@ -0,0 +1,16 @@
FROM ubi8/nodejs-12
ENV JAEGER_SERVICE_NAME=history \
    JAEGER_SAMPLER_TYPE=const \
    JAEGER_SAMPLER_PARAM=1 \
    JAEGER_REPORTER_LOG_SPANS=true \
    JAEGER_ENDPOINT=http://jaeger-collector.istio-system.svc:14268/api/traces
COPY package.json .
RUN npm install
COPY lib ./lib
COPY index.js .
CMD node index.js
exchange-traced/history/index.js
New file
@@ -0,0 +1,92 @@
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const _const = require('./lib/constants');
const Jaeger = require('jaeger-client');
const Opentracing = require('opentracing');
const app = express();
const tracer = createTracer();
app.use(bodyParser.json());
app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
});
app.use(function(req, res, next) {
    const context = tracer.extract(Opentracing.FORMAT_HTTP_HEADERS, req.headers);
    const span = tracer.startSpan(`${req.method}:history`, { childOf: context });
    span.setTag(Opentracing.Tags.HTTP_URL, req.url);
    span.setTag(Opentracing.Tags.HTTP_METHOD, req.method);
    function afterResponse() {
        res.removeListener("finish", afterResponse);
        res.removeListener("close", afterResponse);
        span.setTag(Opentracing.Tags.HTTP_STATUS_CODE, res.statusCode);
        span.finish();
    }
    res.on("finish", afterResponse);
    res.on("close", afterResponse);
    next();
});
const postData = (req, res) => {
    const src = req.body.source;
    const target = req.body.target;
    const data = _const[src + "_TO_" + target];
    console.log(`Serving request: ${JSON.stringify(req.body)}`)
    if(!!data === false) {
        res.send(JSON.stringify({state: "Unknown currency conversion"})).status(500);
        return;
    }
    const dataWithDate = [];
    data.forEach( (e, i) => {
        var elementWithDate = {...e}
        var date = new Date();
        date.setDate(date.getDate() - i);
        elementWithDate["date"] = date;
        dataWithDate.push(elementWithDate);
    });
    res.setHeader('Content-Type', 'application/json');
    res.json(dataWithDate).status(200);
}
app.post('/', postData);
app.listen(_const.PORT, () => {
    console.log(
        "  App is running at http://localhost:%d",
        _const.PORT,
    );
    console.log("  Press CTRL-C to stop\n");
});
function createTracer() {
    // Config object is empty as settings are passed as environment variables
    const config = {};
    const options = { logger: console };
    const tracer = Jaeger.initTracerFromEnv(config, options);
    // Use B3 Propagation Specification to be able to read trace headers
    const codec = new Jaeger.ZipkinB3TextMapCodec({ urlEncoding: true });
    tracer.registerInjector(Opentracing.FORMAT_HTTP_HEADERS, codec);
    tracer.registerExtractor(Opentracing.FORMAT_HTTP_HEADERS, codec);
    return tracer;
}
exchange-traced/history/lib/constants.js
New file
@@ -0,0 +1,29 @@
'use strict';
const PORT = process.env.PORT || 8080;
const USD_TO_EUR = [
    {"value": 0.90},
    {"value": 0.91},
    {"value": 0.92},
    {"value": 0.93},
    {"value": 0.92},
    {"value": 0.91},
    {"value": 0.95},
];
const EUR_TO_USD = [
    {"value": 1.11},
    {"value": 1.1},
    {"value": 1.09},
    {"value": 1.08},
    {"value": 1.09},
    {"value": 1.1},
    {"value": 1.05},
];
module.exports = {
    PORT,
    EUR_TO_USD,
    USD_TO_EUR
};
exchange-traced/history/package-lock.json
New file
@@ -0,0 +1,477 @@
{
  "name": "history",
  "version": "1.0.0",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {
    "accepts": {
      "version": "1.3.7",
      "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
      "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
      "requires": {
        "mime-types": "~2.1.24",
        "negotiator": "0.6.2"
      }
    },
    "ansi-color": {
      "version": "0.2.1",
      "resolved": "https://registry.npmjs.org/ansi-color/-/ansi-color-0.2.1.tgz",
      "integrity": "sha1-PnXAN0dSF1RO12Oo21cJ+prlv5o="
    },
    "array-flatten": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
      "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
    },
    "body-parser": {
      "version": "1.19.0",
      "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
      "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
      "requires": {
        "bytes": "3.1.0",
        "content-type": "~1.0.4",
        "debug": "2.6.9",
        "depd": "~1.1.2",
        "http-errors": "1.7.2",
        "iconv-lite": "0.4.24",
        "on-finished": "~2.3.0",
        "qs": "6.7.0",
        "raw-body": "2.4.0",
        "type-is": "~1.6.17"
      }
    },
    "bufrw": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/bufrw/-/bufrw-1.3.0.tgz",
      "integrity": "sha512-jzQnSbdJqhIltU9O5KUiTtljP9ccw2u5ix59McQy4pV2xGhVLhRZIndY8GIrgh5HjXa6+QJ9AQhOd2QWQizJFQ==",
      "requires": {
        "ansi-color": "^0.2.1",
        "error": "^7.0.0",
        "hexer": "^1.5.0",
        "xtend": "^4.0.0"
      }
    },
    "bytes": {
      "version": "3.1.0",
      "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
      "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
    },
    "content-disposition": {
      "version": "0.5.3",
      "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
      "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
      "requires": {
        "safe-buffer": "5.1.2"
      }
    },
    "content-type": {
      "version": "1.0.4",
      "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
      "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
    },
    "cookie": {
      "version": "0.4.0",
      "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
      "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg=="
    },
    "cookie-signature": {
      "version": "1.0.6",
      "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
      "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
    },
    "debug": {
      "version": "2.6.9",
      "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
      "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
      "requires": {
        "ms": "2.0.0"
      }
    },
    "depd": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
      "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
    },
    "destroy": {
      "version": "1.0.4",
      "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
      "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
    },
    "ee-first": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
      "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
    },
    "encodeurl": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
      "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
    },
    "error": {
      "version": "7.0.2",
      "resolved": "https://registry.npmjs.org/error/-/error-7.0.2.tgz",
      "integrity": "sha1-pfdf/02ZJhJt2sDqXcOOaJFTywI=",
      "requires": {
        "string-template": "~0.2.1",
        "xtend": "~4.0.0"
      }
    },
    "escape-html": {
      "version": "1.0.3",
      "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
      "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
    },
    "etag": {
      "version": "1.8.1",
      "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
      "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
    },
    "express": {
      "version": "4.17.1",
      "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
      "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
      "requires": {
        "accepts": "~1.3.7",
        "array-flatten": "1.1.1",
        "body-parser": "1.19.0",
        "content-disposition": "0.5.3",
        "content-type": "~1.0.4",
        "cookie": "0.4.0",
        "cookie-signature": "1.0.6",
        "debug": "2.6.9",
        "depd": "~1.1.2",
        "encodeurl": "~1.0.2",
        "escape-html": "~1.0.3",
        "etag": "~1.8.1",
        "finalhandler": "~1.1.2",
        "fresh": "0.5.2",
        "merge-descriptors": "1.0.1",
        "methods": "~1.1.2",
        "on-finished": "~2.3.0",
        "parseurl": "~1.3.3",
        "path-to-regexp": "0.1.7",
        "proxy-addr": "~2.0.5",
        "qs": "6.7.0",
        "range-parser": "~1.2.1",
        "safe-buffer": "5.1.2",
        "send": "0.17.1",
        "serve-static": "1.14.1",
        "setprototypeof": "1.1.1",
        "statuses": "~1.5.0",
        "type-is": "~1.6.18",
        "utils-merge": "1.0.1",
        "vary": "~1.1.2"
      }
    },
    "finalhandler": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
      "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==",
      "requires": {
        "debug": "2.6.9",
        "encodeurl": "~1.0.2",
        "escape-html": "~1.0.3",
        "on-finished": "~2.3.0",
        "parseurl": "~1.3.3",
        "statuses": "~1.5.0",
        "unpipe": "~1.0.0"
      }
    },
    "forwarded": {
      "version": "0.1.2",
      "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
      "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
    },
    "fresh": {
      "version": "0.5.2",
      "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
      "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
    },
    "hexer": {
      "version": "1.5.0",
      "resolved": "https://registry.npmjs.org/hexer/-/hexer-1.5.0.tgz",
      "integrity": "sha1-uGzoCFmOip0YksVx887dhvyfBlM=",
      "requires": {
        "ansi-color": "^0.2.1",
        "minimist": "^1.1.0",
        "process": "^0.10.0",
        "xtend": "^4.0.0"
      }
    },
    "http-errors": {
      "version": "1.7.2",
      "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
      "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
      "requires": {
        "depd": "~1.1.2",
        "inherits": "2.0.3",
        "setprototypeof": "1.1.1",
        "statuses": ">= 1.5.0 < 2",
        "toidentifier": "1.0.0"
      }
    },
    "iconv-lite": {
      "version": "0.4.24",
      "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
      "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
      "requires": {
        "safer-buffer": ">= 2.1.2 < 3"
      }
    },
    "inherits": {
      "version": "2.0.3",
      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
      "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
    },
    "ipaddr.js": {
      "version": "1.9.1",
      "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
      "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="
    },
    "jaeger-client": {
      "version": "3.18.0",
      "resolved": "https://registry.npmjs.org/jaeger-client/-/jaeger-client-3.18.0.tgz",
      "integrity": "sha512-xZ9WvZDWLkZFq7SObpLwu1asMCKCgBRNcDxxGSvK+ZQ7OZyJC5xPlU+rJa4+s/P6autPBVwHpqMGbOERFxWuuA==",
      "requires": {
        "node-int64": "^0.4.0",
        "opentracing": "^0.14.4",
        "thriftrw": "^3.5.0",
        "uuid": "^3.2.1",
        "xorshift": "^0.2.0"
      }
    },
    "long": {
      "version": "2.4.0",
      "resolved": "https://registry.npmjs.org/long/-/long-2.4.0.tgz",
      "integrity": "sha1-n6GAux2VAM3CnEFWdmoZleH0Uk8="
    },
    "media-typer": {
      "version": "0.3.0",
      "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
      "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
    },
    "merge-descriptors": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
      "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
    },
    "methods": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
      "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
    },
    "mime": {
      "version": "1.6.0",
      "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
      "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
    },
    "mime-db": {
      "version": "1.43.0",
      "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz",
      "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ=="
    },
    "mime-types": {
      "version": "2.1.26",
      "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz",
      "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==",
      "requires": {
        "mime-db": "1.43.0"
      }
    },
    "minimist": {
      "version": "1.2.5",
      "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
      "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
    },
    "ms": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
      "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
    },
    "negotiator": {
      "version": "0.6.2",
      "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
      "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
    },
    "node-int64": {
      "version": "0.4.0",
      "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
      "integrity": "sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs="
    },
    "on-finished": {
      "version": "2.3.0",
      "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
      "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
      "requires": {
        "ee-first": "1.1.1"
      }
    },
    "opentracing": {
      "version": "0.14.4",
      "resolved": "https://registry.npmjs.org/opentracing/-/opentracing-0.14.4.tgz",
      "integrity": "sha512-nNnZDkUNExBwEpb7LZaeMeQgvrlO8l4bgY/LvGNZCR0xG/dGWqHqjKrAmR5GUoYo0FIz38kxasvA1aevxWs2CA=="
    },
    "parseurl": {
      "version": "1.3.3",
      "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
      "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
    },
    "path-to-regexp": {
      "version": "0.1.7",
      "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
      "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
    },
    "process": {
      "version": "0.10.1",
      "resolved": "https://registry.npmjs.org/process/-/process-0.10.1.tgz",
      "integrity": "sha1-hCRXzFHP7XLcd1r+6vuMYDQ3JyU="
    },
    "proxy-addr": {
      "version": "2.0.6",
      "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz",
      "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==",
      "requires": {
        "forwarded": "~0.1.2",
        "ipaddr.js": "1.9.1"
      }
    },
    "qs": {
      "version": "6.7.0",
      "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
      "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
    },
    "range-parser": {
      "version": "1.2.1",
      "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
      "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
    },
    "raw-body": {
      "version": "2.4.0",
      "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
      "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==",
      "requires": {
        "bytes": "3.1.0",
        "http-errors": "1.7.2",
        "iconv-lite": "0.4.24",
        "unpipe": "1.0.0"
      }
    },
    "safe-buffer": {
      "version": "5.1.2",
      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
      "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
    },
    "safer-buffer": {
      "version": "2.1.2",
      "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
      "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
    },
    "send": {
      "version": "0.17.1",
      "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
      "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==",
      "requires": {
        "debug": "2.6.9",
        "depd": "~1.1.2",
        "destroy": "~1.0.4",
        "encodeurl": "~1.0.2",
        "escape-html": "~1.0.3",
        "etag": "~1.8.1",
        "fresh": "0.5.2",
        "http-errors": "~1.7.2",
        "mime": "1.6.0",
        "ms": "2.1.1",
        "on-finished": "~2.3.0",
        "range-parser": "~1.2.1",
        "statuses": "~1.5.0"
      },
      "dependencies": {
        "ms": {
          "version": "2.1.1",
          "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
          "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
        }
      }
    },
    "serve-static": {
      "version": "1.14.1",
      "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
      "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==",
      "requires": {
        "encodeurl": "~1.0.2",
        "escape-html": "~1.0.3",
        "parseurl": "~1.3.3",
        "send": "0.17.1"
      }
    },
    "setprototypeof": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
      "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
    },
    "statuses": {
      "version": "1.5.0",
      "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
      "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
    },
    "string-template": {
      "version": "0.2.1",
      "resolved": "https://registry.npmjs.org/string-template/-/string-template-0.2.1.tgz",
      "integrity": "sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0="
    },
    "thriftrw": {
      "version": "3.12.0",
      "resolved": "https://registry.npmjs.org/thriftrw/-/thriftrw-3.12.0.tgz",
      "integrity": "sha512-4YZvR4DPEI41n4Opwr4jmrLGG4hndxr7387kzRFIIzxHQjarPusH4lGXrugvgb7TtPrfZVTpZCVe44/xUxowEw==",
      "requires": {
        "bufrw": "^1.3.0",
        "error": "7.0.2",
        "long": "^2.4.0"
      }
    },
    "toidentifier": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
      "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
    },
    "type-is": {
      "version": "1.6.18",
      "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
      "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
      "requires": {
        "media-typer": "0.3.0",
        "mime-types": "~2.1.24"
      }
    },
    "unpipe": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
      "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
    },
    "utils-merge": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
      "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
    },
    "uuid": {
      "version": "3.4.0",
      "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
      "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
    },
    "vary": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
      "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
    },
    "xorshift": {
      "version": "0.2.1",
      "resolved": "https://registry.npmjs.org/xorshift/-/xorshift-0.2.1.tgz",
      "integrity": "sha1-/NgiZ+k1HBPw+5xzMH8lMx0pxjo="
    },
    "xtend": {
      "version": "4.0.2",
      "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
      "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="
    }
  }
}
exchange-traced/history/package.json
New file
@@ -0,0 +1,16 @@
{
  "name": "history",
  "version": "1.0.0",
  "description": "A backend data service that returns historical data of currency exchange",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Marek Czernek <mczernek@redhat.com>",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.1",
    "jaeger-client": "^3.18.0",
    "opentracing": "^0.14.4"
  }
}
exchange-traced/history/test.json
New file
@@ -0,0 +1,4 @@
{
  "source": "USD",
  "target": "EUR"
}