diff --git a/project/img/pipeline.png b/project/img/pipeline.png new file mode 100644 index 0000000..a9e589a Binary files /dev/null and b/project/img/pipeline.png differ diff --git a/project/schemi.drawio b/project/schemi.drawio index 4555b7b..9a6fd0f 100644 --- a/project/schemi.drawio +++ b/project/schemi.drawio @@ -1,103 +1,249 @@ - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/readme.md b/readme.md index 9b48a46..d3ee871 100644 --- a/readme.md +++ b/readme.md @@ -44,3 +44,115 @@ tasks: version: 1.0.0 # Component version ... ``` +#### Task files + +I file con il codice all'interno della cartella `task` devono seguire il formato + +```go +package main + +import ( + +) + +func exec_task(arg string) string{ + + ... your code ... + + return response // must me string +} +``` + +### Generazione del codice + +Il parser utilizza il campo `type` del workflow per selezionare il corretto template fra quelli implementati (per ora) +- producer -- produzione di dati e scrittura di essi in un topic NATS +- processor -- lettura di dati da un topic, processamento dei dati e scrittura su un altro topic +- dbsync -- lettura di dati da un topic e scrittura su un DB (Postgres) + +Viene sostituito il file delle task con quello del template, i campi del file `workflow` vengono utilizzati per compilare il file `wadm.yaml`. + +### Build componente WASM + +Viene utilizzato il Dockerfile del template per buildare il componente WASM e pusharlo al registry configurato utilizzando il nome e la versione specificati nel `workflow.yaml` + + +## Deploy componenti WASM su Wasmcloud + +In fase di deployment vengono utilizzati i file `wadm.yaml` compilati in precedenza per effettuare il deployment dell'applicazione, eccone un esempio + +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: go-data-stream + annotations: + description: 'Data stream processing using NATS topic in Golang (TinyGo), using the WebAssembly Component Model and WebAssembly Interfaces Types (WIT)' + wasmcloud.dev/authors: Lorenzo Venerandi + wasmcloud.dev/source-url: https://gitea.rebus.ninja/lore/wasm-nats-stream-client.git/wadm.yaml + wasmcloud.dev/readme-md-url: https://gitea.rebus.ninja/lore/wasm-nats-stream-client.git/README.md + wasmcloud.dev/homepage: https://gitea.rebus.ninja/lore/wasm-nats-stream-client.git + wasmcloud.dev/categories: | + stream-processing,nats-client,tinygo,golang +spec: + components: + - name: go_stream_processor + type: component + properties: + image: gitea.rebus.ninja/lore/wasm-nats-stream-client:1.0.3 + id: stream + config: + - name: nats-topic + properties: + dest-topic: wasmcloud.echo.reply + traits: + - type: spreadscaler + properties: + instances: 1 + spread: + - name: cloud + weight: 100 + requirements: + host-type: cloud + - name: edge + weight: 0 + requirements: + host-type: edge + - type: link + properties: + target: nats + namespace: wasmcloud + package: messaging + interfaces: [consumer] + - name: nats + type: capability + properties: + image: ghcr.io/wasmcloud/messaging-nats:0.23.1 + traits: + - type: link + properties: + target: go_stream_processor + namespace: wasmcloud + package: messaging + interfaces: [handler] + source_config: + - name: simple-subscription + properties: + subscriptions: streaming + - type: spreadscaler + properties: + instances: 1 + spread: + - name: cloud + weight: 100 + requirements: + host-type: cloud + - name: edge + weight: 0 + requirements: + host-type: edge +``` +Il target del deployment viene selezionato tramite il campo `spreadscaler`, che indirizza i componenti nell'host con il tag corrispondente. + +### Pipeline scheme +![pipeline](project/img/pipeline.png) \ No newline at end of file