Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion opentelemetry/config/krakend/krakend.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@
"input_query_strings": ["*"],
"backend": [
{ "url_pattern": "/customer.json" },
{ "url_pattern": "/sales.json" }
{ "url_pattern": "/sales.json" },
{
"host": ["http://localhost:8080"],
"url_pattern": "/__debug"
}
]
},
{
Expand Down
26 changes: 26 additions & 0 deletions workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Workflows example

This example simulates a backend for frontend example for a streaming
platforme like could be NerdFilms, or Rainforest Top Video.


## Endpoints

### `/home_dashboard`

Is modeled as the initial screen that a customer would watch.

The request can specify the `customer` and optionally the `profile`.
If the profile is not provided, it would request the default profile for
a given customer in a sequential workflow.

We have three backends to request in parallel:

- header
- customized content
- footer

**Customized content** is a workflow, because if `profile` is not provided we want
to have sequential call that first fetches the default profile. Once we are
sure we have `profile` available, we can call another workflow that will
execute the fetch of customized content from different backends.
62 changes: 62 additions & 0 deletions workflows/config/fakehttpapi/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"port": 8088,
"endpoints": [
{
"method": "GET",
"path_pattern": "/timeouter/",
"behaviour": [
{
"name": "delayer",
"config": {
"delay_millis_distribution": [
{"key": 0, "val": 0.0},
{"key": 600000, "val": 0.0},
{"key": 900000, "val": 100.0}
],
"seed": 1
}
}
],
"content": {
"source": "directory",
"config": {
"dir": "/etc/reqstatsrv/config/data",
"dunder_querystrings": true,
"attempt_extensions": [
"json"
]
}
}
},
{
"method": "GET",
"path_pattern": "/regular/",
"behaviour": [],
"content": {
"source": "directory",
"config": {
"dir": "/etc/reqstatsrv/config/data",
"dunder_querystrings": true,
"attempt_extensions": [
"json"
]
}
}
},
{
"method": "GET",
"path_pattern": "/",
"behaviour": [],
"content": {
"source": "directory",
"config": {
"dir": "/etc/reqstatsrv/config/data",
"dunder_querystrings": true,
"attempt_extensions": [
"json"
]
}
}
}
]
}
6 changes: 6 additions & 0 deletions workflows/config/fakehttpapi/data/customer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"customer_id": "1",
"customer": {
"name": "Bard SingSong"
}
}
6 changes: 6 additions & 0 deletions workflows/config/fakehttpapi/data/default_profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"profile": {
"name": "Bart Sink Son",
"profile_id": "xx"
}
}
22 changes: 22 additions & 0 deletions workflows/config/fakehttpapi/data/footer_promoted_movies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"movies": [
{
"title": "WarGames",
"genre": "Thriller",
"cast": [
"Matthew Broderick",
"Ally Sheedy"
],
"year": 1983
},
{
"title": "Tron",
"genre": "Action",
"cast": [
"Jeff Bridges",
"Brucxe Boxleitner"
],
"year": 1982
}
]
}
22 changes: 22 additions & 0 deletions workflows/config/fakehttpapi/data/header_banner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"movies": [
{
"title": "Sinners",
"genre": "Horror",
"cast": [
"Michael B. Jordan",
"Miles Caton"
],
"year": 2025
},
{
"title": "The Report",
"genre": "Drama",
"cast": [
"Adam Driver",
"Annette Benning"
],
"year": 2019
}
]
}
24 changes: 24 additions & 0 deletions workflows/config/fakehttpapi/data/pprofile_recommended_movies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"movies": [
{
"title": "Double Impact",
"genre": "Action",
"cast": [
"Jean-Claude Van Damme",
"Alonna Shaw",
"Bolo Yeung"
],
"year": 1991
},
{
"title": "Kickboxer",
"genre": "Action",
"cast": [
"Jean-Claude Van Damme",
"Dennis Alexio",
"Rochelle Ashana"
],
"year": 1989
}
]
}
10 changes: 10 additions & 0 deletions workflows/config/fakehttpapi/data/profile_recommended_actors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"actors": [
{
"name": "Jet Lee"
},
{
"name": "Zhang Ziyi"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"movies": [
{
"title": "XX",
"genre": "Action",
"cast": [
"Jean-Claude Van Damme",
"Alonna Shaw",
"Bolo Yeung"
],
"year": 1991
},
{
"title": "XX",
"genre": "Action",
"cast": [
"Jean-Claude Van Damme",
"Dennis Alexio",
"Rochelle Ashana"
],
"year": 1989
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"movies": [
{
"title": "Double Impact",
"genre": "Action",
"cast": [
"Jean-Claude Van Damme",
"Alonna Shaw",
"Bolo Yeung"
],
"year": 1991
},
{
"title": "Kickboxer",
"genre": "Action",
"cast": [
"Jean-Claude Van Damme",
"Dennis Alexio",
"Rochelle Ashana"
],
"year": 1989
}
]
}
21 changes: 21 additions & 0 deletions workflows/config/fakehttpapi/data/recently_added.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"movies": [
{
"title": "The Fantastic Four: First Steps",
"genre": "Action",
"cast": [
"Pedro Pascal",
"Vanessa Kirby"
],
"year": 2025
},
{
"title": "Billy Joel: And So It Goes",
"genre": "Documentary",
"cast": [
"Billy Joel"
],
"year": 2025
}
]
}
6 changes: 6 additions & 0 deletions workflows/config/fakehttpapi/data/sales.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sales": {
"lemonade": 23,
"cookies": 2
}
}
113 changes: 113 additions & 0 deletions workflows/config/krakend/krakend.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"$schema": "https://www.krakend.io/schema/v3.json",
"version": 3,
"name": "My first API Gateway - KrakenD",
"port": 8080,
"host": [
"http://fakeapi:8088"
],
"echo_endpoint": true,
"debug_endpoint": true,
"endpoints": [
{
"endpoint": "/home_dashboard",
"input_headers": [
"*"
],
"input_query_strings": [
"customer",
"profile"
],
"backend": [
{
"url_pattern": "/__workflow/customized_dashboard/",
"group": "custom_content",
"extra_config": {
"workflow": {
"endpoint": "/__workflow_impl/customized_dashboard/",
"input_query_strings": [
"customer",
"profile"
],
"ignore_errors": true,
"extra_config": {
"proxy": {
"sequential": true,
"sequential_propagated_params": [
"resp0_profile"
]
}
},
"backend": [
{
"host": [
"http://localhost:8080"
],
"url_pattern": "/__debug/workflow/"
},
{
"url_pattern": "/__workflow/find_profile_id",
"extra_config": {
"workflow": {
"endpoint": "/__workflow_impl/find_profile_id",
"encoding": "no-op",
"ignore_errors": true,
"backend": [
{
"url_pattern": "/default_profile",
"extra_config": {
"validation/cel": [
{
"check_expr": "('profile' in req_querystring) == false || size(req_querystring.profile) == 0 || size(req_querystring.profile[0]) == 0"
}
]
}
},
{
"host": [
"http://localhost:8080"
],
"url_pattern": "/__debug/profile_from_query_param/",
"extra_config": {
"modifier/response-body-generator": {
"content_type": "application/json",
"debug": true,
"path": "./profile_id.tmpl"
}
}
}
]
}
}
},
{
"url_pattern": "/__workflow/for_profile_content/{resp0_profile.profile_id}",
"group": "recommended",
"extra_config": {
"workflow": {
"endpoint": "/__workflow_impl/for_profile_content/{resp0_profile.profile_id}",
"backend": [
{
"host": [
"http://localhost:8080"
],
"url_pattern": "/__debug/{resp0_profile.profile_id}"
},
{
"url_pattern": "/profile_recommended_movies?q={resp0_profile.profile_id}"
},
{
"url_pattern": "/profile_recommended_actors"
}
]
}
}
}
]
}
}
}
]
}
]
}
7 changes: 7 additions & 0 deletions workflows/config/krakend/profile_id.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
{{ if .req_querystring.profile }}
"profile": {
"profile_id": "{{index .req_querystring.profile 0}}"
}
{{ end }}
}
Loading