doc: more work on _brainstorming.rst
Co-authored-by: Hector Hurtado <hector.hurtado@bbva.com>
This commit is contained in:
@@ -47,13 +47,13 @@ User Journey
|
|||||||
database server is a critical machine we don't want to grant SSH
|
database server is a critical machine we don't want to grant SSH
|
||||||
access to lowly developers. The script is very fast because the
|
access to lowly developers. The script is very fast because the
|
||||||
database is small (for now).
|
database is small (for now).
|
||||||
- Solution: Instead of launching the script via SSH shell we can
|
- pre-Kapow! solution: Launching the script via SSH shell.
|
||||||
provide an HTTP endpoint to perform the task.
|
|
||||||
```
|
```
|
||||||
ssh user@server
|
ssh user@server
|
||||||
$ ./backup_db.sh
|
$ ./backup_db.sh
|
||||||
```
|
```
|
||||||
- Final Kapow!:
|
- Kapow!-enabled solution: Provide an HTTP endpoint that when accessed
|
||||||
|
triggers the run of the backup script.
|
||||||
```
|
```
|
||||||
curl -X PUT http://server:8080/db/backup
|
curl -X PUT http://server:8080/db/backup
|
||||||
```
|
```
|
||||||
@@ -65,9 +65,12 @@ User Journey
|
|||||||
|
|
||||||
- User Learns: Execute local commands and output it results to the HTTP body.
|
- User Learns: Execute local commands and output it results to the HTTP body.
|
||||||
- Kapow! Concepts: `kapow set /response/body`
|
- Kapow! Concepts: `kapow set /response/body`
|
||||||
- Problem/Motivation:
|
- Problem/Motivation: The backup script produces a log on /tmp/backup_db.log.
|
||||||
- Solution:
|
We want to share this log over HTTP to give users feedback about the backup
|
||||||
- Final Kapow!:
|
process result.
|
||||||
|
- pre-Kapow! solution: SSH into the host + cat /tmp/backup_db.log.
|
||||||
|
- Kapow!-enabled solution: Provide an endpoint that returns the contents of
|
||||||
|
/tmp/backup_db.log.
|
||||||
```
|
```
|
||||||
cat /var/log/backup_db.log | kapow set /response/body
|
cat /var/log/backup_db.log | kapow set /response/body
|
||||||
```
|
```
|
||||||
@@ -77,9 +80,15 @@ User Journey
|
|||||||
- User Learns: Get a parameter from the user and use it to select the
|
- User Learns: Get a parameter from the user and use it to select the
|
||||||
script.
|
script.
|
||||||
- Kapow! Concepts: `kapow get /request/params`
|
- Kapow! Concepts: `kapow get /request/params`
|
||||||
- Problem/Motivation:
|
- Problem/Motivation: /tmp/backup_db.log keeps growing. It's about 100MB now.
|
||||||
- Solution:
|
The users are fed up already. We need a way to be more selective in the data
|
||||||
- Final Kapow!:
|
we dump.
|
||||||
|
- pre-Kapow! solution: SSH into the host, and then find a way to extract the
|
||||||
|
required data from the log file. It would entitle using some combination of
|
||||||
|
grep, tail, etc. Or we could provide a bespoke shell script to accomplish
|
||||||
|
this task.
|
||||||
|
|
||||||
|
- Kapow!-enabled solution:
|
||||||
```
|
```
|
||||||
LINES="$(kapow get /request/params/lines)"
|
LINES="$(kapow get /request/params/lines)"
|
||||||
FILTER="$(kapow get /request/params/filter)"
|
FILTER="$(kapow get /request/params/filter)"
|
||||||
@@ -93,8 +102,8 @@ User Journey
|
|||||||
- User Learns: Compose complex HTTP responses with more than one local command.
|
- User Learns: Compose complex HTTP responses with more than one local command.
|
||||||
- Kapow! Concepts: HEREDOC and subshells
|
- Kapow! Concepts: HEREDOC and subshells
|
||||||
- Problem/Motivation:
|
- Problem/Motivation:
|
||||||
- Solution:
|
- pre-Kapow! solution:
|
||||||
- Final Kapow!:
|
- Kapow!-enabled solution:
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
echo Memory:
|
echo Memory:
|
||||||
@@ -113,8 +122,8 @@ User Journey
|
|||||||
- User Learns: Format a complex HTTP response with JSON format to feed the corporate dashboard.
|
- User Learns: Format a complex HTTP response with JSON format to feed the corporate dashboard.
|
||||||
- Kapow! Concepts: backtick interpolation and `kapow set /response/headers`
|
- Kapow! Concepts: backtick interpolation and `kapow set /response/headers`
|
||||||
- Problem/Motivation:
|
- Problem/Motivation:
|
||||||
- Solution:
|
- pre-Kapow! solution:
|
||||||
- Final Kapow!:
|
- Kapow!-enabled solution:
|
||||||
``` DON'T HANDWRITE JSON
|
``` DON'T HANDWRITE JSON
|
||||||
echo "{memory: `free -m`, ...uups..}' | kapow set /response/body
|
echo "{memory: `free -m`, ...uups..}' | kapow set /response/body
|
||||||
```
|
```
|
||||||
@@ -138,4 +147,3 @@ Ideas
|
|||||||
|
|
||||||
Add this to serve the webpage that uses the implemented HTTP API
|
Add this to serve the webpage that uses the implemented HTTP API
|
||||||
kapow route add / -c 'kapow set /resonse/headers/Content-Type text/html ; curl --output - http:// | kapow set /response/body'
|
kapow route add / -c 'kapow set /resonse/headers/Content-Type text/html ; curl --output - http:// | kapow set /response/body'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user