Skip to content

Commit

Permalink
oJobHTTPd: adding shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaguiar committed Sep 6, 2023
1 parent df391d7 commit ec4914f
Show file tree
Hide file tree
Showing 5 changed files with 605 additions and 312 deletions.
10 changes: 5 additions & 5 deletions .package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ name: oJob-common
main: ''
mainJob: ''
license: Apache 2.0
version: '20230808'
version: '20230905'
dependencies:
openaf: '>=20211229'
files:
Expand Down Expand Up @@ -69,7 +69,7 @@ files:
- ojob.yaml
filesHash:
LICENSE: 92170cdc034b2ff819323ff670d3b7266c8bffcd
README.md: a7c4a425db48751c13711424d7fcd2e6072a4d61
README.md: 3708132ddf4013713ab3a741d1e6a52d68544e65
oJobBasics.yaml: 3178f72c3826bd9514cbd5c15bc3399821191f3c
oJobCh.yaml: 4290a3d5dc035a6d7b6659aeb0e370d0bb55be58
oJobDebug.yaml: bfb5debec954e3b524ae4ce103d6ea8e780448e9
Expand All @@ -78,7 +78,7 @@ filesHash:
oJobEmail.yaml: c1d8d2873046d239c1d8a1063660af8c1ea499a6
oJobGIT.yaml: f1a2b6a2544935989c01edc4fadeed8693e515eb
oJobHBS.yaml: ab15b0efd31f95ee770c77dace146035e0781661
oJobHTTPd.yaml: 9b27f59cd7b649088cf0ebf9248b7959b72bf931
oJobHTTPd.yaml: ae3562c91a4a9243d3af47f43eb3a426ef040272
oJobIO.yaml: 8108313099abf9d1115a3d428b68a203b8d5c2e2
oJobManager.yaml: 5ad9ecf276bbee8b6503d0e3b40b007f2724507d
oJobNet.yaml: 4413085d38724249587f6a790d7e1952a4d9c138
Expand All @@ -93,5 +93,5 @@ filesHash:
oJobWatchDog.yaml: d1dbeab36784bd6722daa27e572425c84ebbc36b
oJobXLS.yaml: 00def6b195d7487989d7aa2c774b584a0e0b01a0
oJobs.yaml: 83d8406c43b4a5325686467ed80911a9c1e26d49
ojob.json: e1211f5b51a270f2ed45767b3b955ccde7206005
ojob.yaml: e7c31e9403794ab9aa2113cdeb872106b536530e
ojob.json: 2087d27cc80ac5de5c40e36911262bd0ddf4cecb
ojob.yaml: 4805d8bb45216752ace66c069d2c991caf67b25d
68 changes: 67 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Check the documentation for some of them:
| [oJobSQL](#ojobsql) | Query or execute SQL to a JDBC database. |
| [oJobES](#ojobes) | Logging to ElasticSearch |
| [oJobNet](#ojobnet) | Testing network connectivity |
| [oJobHTTPd](#ojobhttpd) | Building a simple HTTP(s) server |
| [oJob](#ojob) | Building a simple HTTP(s) server |
| [oJobRest](#ojobrest) | Building a simple REST server |
| [oJobOPack](#ojobopack) | Simplified OPack creation |
| [oJobRAID](#ojobraid) | Simplified RAID AF operation execution. |
Expand Down Expand Up @@ -806,3 +806,69 @@ jobs:
todo:
- nAttrMon watchdog
````

---

## Shortcuts examples:

### oJobHTTPd.yaml

```yaml
todo:
# Starts the server
- (httpdStart ): &PORT 12345
# Setups the default answer, /healthz, /livez and /metrics
- (httpdDefault): *PORT
((uri )): /
- (httpdHealthz): *PORT
- (httpdMetrics): *PORT
((prefix )): mytest
# Allows browsing of files
- (httpdFileBrowse): *PORT
((uri )): /browse
((path )): .
# Allows for the upload of files
- (httpdUpload): *PORT
((uri )): /upload
((path )): .
# Adds a custom metric
- (httpdAddMetric): global-counter
((fn )): |
// Sets an atomic counter if one does not exist and returns a counter increment
if (isUnDef(global.counter)) global.counter = $atomic()
return global.counter.inc()
# /test calls the 'test' job
- (httpdService): *PORT
((uri )): /test
((execURI )): |
// Shows all request components for debug
cprint(request)
// Returns the result of calling the job 'test' passing the request and expecting an ANSWER to be returned
return ow.server.httpd.reply($job("test", request).ANSWER)
jobs:
# ---------------------------------
# Job test is written in shell code
- name: test
lang: shell
exec: |
# Sets ANSWER in shell script
ANSWER="Echo from the shell (a: {{params.a}})"
# return ANSWER
# Includes the http server functionality
include:
- oJobHTTPd.yaml
# Makes sures it runs forever and oJob-common is included
ojob:
daemon: true
opacks:
oJob-common
```
Loading

0 comments on commit ec4914f

Please sign in to comment.