Compare commits

...

3 Commits

Author SHA1 Message Date
c5b79c95ca README 2020-10-15 18:23:22 +02:00
6655736a69 Prosty sequential proxy 2020-10-11 13:51:18 +02:00
5e23a97b1a initial commit 2020-10-11 13:36:32 +02:00
6 changed files with 134 additions and 0 deletions

View File

@ -5,3 +5,19 @@ Poszczególne etapy pracy i poznawania krakend w osobnych brancz'ach.
Całość oparta do docker. Całość oparta do docker.
- etap1 (podstawka) - etap1 (podstawka)
Proste zmokowane api oraz krakend config-watcher (restertujący usługę po zmianie pliku konfiguracyjnego). Fajny patent wykorzystujący [Reflex](https://github.com/cespare/reflex).
Sekwencyjne proxy w KrakenD:
```mermaid
sequenceDiagram
Użytkownik->>KrakenD: /sequential/{id}
KrakenD->>Backend: /users/{id}.json
Backend-->>KrakenD: response_0
KrakenD->>Backend: /projects/{response_0.user_id}.json
Backend-->>KrakenD: response_1
KrakenD-->>KrakenD: merge response[]
KrakenD->>+Użytkownik: Response
```

View File

@ -0,0 +1,4 @@
{
"owner": 1,
"name": "Simple project"
}

4
api-mocks/users/1.json Normal file
View File

@ -0,0 +1,4 @@
{
"id": 1,
"username": "test"
}

4
api-mocks/users/2.json Normal file
View File

@ -0,0 +1,4 @@
{
"id": 2,
"username": "test2"
}

28
docker-compose.yml Normal file
View File

@ -0,0 +1,28 @@
version: "3.8"
services:
jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686"
- "14268:14268"
api:
image: paramah/lwan
volumes:
- ./api-mocks:/opt/lwan/wwwroot
ports:
- "8000:8080"
kraken:
image: devopsfaith/krakend:config-watcher
volumes:
- ./krakend:/etc/krakend
ports:
- "1234:1234"
- "8080:8080"
- "8091:8091"
depends_on:
- api
- jaeger

78
krakend/krakend.json Normal file
View File

@ -0,0 +1,78 @@
{
"version": 2,
"timeout": "3000ms",
"cache_ttl": "300s",
"host": [
"http://api:8080"
],
"extra_config": {
"github_com/devopsfaith/krakend-metrics": {
"listen_address": ":8091"
},
"github_com/devopsfaith/krakend-gologging": {
"level": "DEBUG",
"prefix": "[KRAKEND]",
"syslog": false,
"stdout": true
},
"github_com/devopsfaith/krakend-opencensus": {
"sample_rate": 100,
"reporting_period": 1,
"exporters": {
"jaeger": {
"endpoint": "http://jaeger:14268",
"service_name": "krakend"
}
}
},
"github_com/devopsfaith/krakend-cors": {
"allow_origins": [
"http://localhost:8000"
],
"allow_methods": [
"POST",
"GET"
],
"allow_headers": [
"Origin",
"Authorization",
"Content-Type"
],
"expose_headers": [
"Content-Length"
],
"max_age": "12h"
}
},
"endpoints":[
{
"endpoint": "/sequential/{id}",
"backend": [
{
"url_pattern": "/users/{id}.json",
"whitelist": [
"id",
"username"
],
"extra_config": {},
"encoding": "json",
"blacklist": [
"id"
]
},
{
"url_pattern": "/projects/{resp0_id}.json",
"whitelist": [
"name"
],
"group": "projects"
}
],
"extra_config": {
"github.com/devopsfaith/krakend/proxy": {
"sequential": true
}
}
}
]
}