diff --git a/docs/running-tarmac/configuration.md b/docs/running-tarmac/configuration.md index 214693e..2e6a233 100644 --- a/docs/running-tarmac/configuration.md +++ b/docs/running-tarmac/configuration.md @@ -26,6 +26,7 @@ When using Environment Variables, all configurations are prefixed with `APP_`. T | `APP_IGNORE_CLIENT_CERT` | `ignore_client_cert` | `string` | When defined will disable Client Cert validation for m-TLS authentication | | `APP_WASM_FUNCTION` | `wasm_function` | `string` | Path and Filename of the WASM Function to execute \(Default: `/functions/tarmac.wasm`\) | | `APP_WASM_FUNCTION_CONFIG` | `wasm_function_config` | `string` | Path to Service configuration for multi-function services \(Default: `/functions/tarmac.json`\) | +| `APP_WASM_POOL_SIZE` | `wasm_pool_size` | `int` | Number of WASM function instances to create \(Default: `100`\). Only applicable when `wasm_function` is used. | | `APP_ENABLE_PPROF` | `enable_pprof` | `bool` | Enable PProf Collection HTTP end-points | | `APP_ENABLE_KVSTORE` | `enable_kvstore` | `bool` | Enable the KV Store | | `APP_KVSTORE_TYPE` | `kvstore_type` | `string` | Select KV Store to use (Options: `redis`, `cassandra`, `boltdb`, `in-memory`, `internal`)| diff --git a/docs/wasm-functions/multi-function-services.md b/docs/wasm-functions/multi-function-services.md index 475b514..485948f 100644 --- a/docs/wasm-functions/multi-function-services.md +++ b/docs/wasm-functions/multi-function-services.md @@ -17,7 +17,8 @@ The `tarmac.json` file has a simple structure that consists of a single object w "name": "my-service", "functions": { "function1": { - "filepath": "/path/to/function1.wasm" + "filepath": "/path/to/function1.wasm", + "pool_size": 10 }, "function2": { "filepath": "/path/to/function2.wasm" @@ -61,7 +62,7 @@ The functions object contains one or more key-value pairs, with each key represe Each function object should include the following properties: - `filepath`: The file path to the .wasm file containing the function code (required). -- `configuration`: An optional object containing configuration data for the function. +- `pool_size`: The number of instances of the function to create (optional). Defaults to 100. #### Routes diff --git a/pkg/app/app.go b/pkg/app/app.go index ac8f9a5..c20bb47 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -575,7 +575,7 @@ func (srv *Server) Run() error { err = srv.engine.LoadModule(engine.ModuleConfig{ Name: "default", Filepath: srv.cfg.GetString("wasm_function"), - PoolSize: srv.cfg.GetInt("wasm_pool_size"), + PoolSize: srv.cfg.GetInt("wasm_pool_size"), }) if err != nil { return fmt.Errorf("could not load default function path for wasm_function (%s) - %s", srv.cfg.GetString("wasm_function"), err) @@ -600,7 +600,7 @@ func (srv *Server) Run() error { err := srv.engine.LoadModule(engine.ModuleConfig{ Name: fName, Filepath: fCfg.Filepath, - PoolSize: fCfg.PoolSize, + PoolSize: fCfg.PoolSize, }) if err != nil { return fmt.Errorf("could not load function %s from path %s - %s", fName, fCfg.Filepath, err) diff --git a/pkg/app/server_test.go b/pkg/app/server_test.go index 448b129..b96cf0b 100644 --- a/pkg/app/server_test.go +++ b/pkg/app/server_test.go @@ -179,7 +179,7 @@ func TestFullService(t *testing.T) { defer srv.Stop() // Wait for Server to start - time.Sleep(10 * time.Second) + time.Sleep(30 * time.Second) // Call /logger with POST t.Run("Do a Post on /logger", func(t *testing.T) { @@ -236,6 +236,7 @@ func TestFullService(t *testing.T) { t.Errorf("Unexpected http status code when making request %d", r.StatusCode) } }) + }) } } diff --git a/pkg/config/config.go b/pkg/config/config.go index b418d19..be20cee 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -40,8 +40,8 @@ type Function struct { // Filepath to the WASM function Filepath string `json:"filepath"` - // PoolSize defines the number of instances of the function to create - PoolSize int `json:"pool_size"` + // PoolSize defines the number of instances of the function to create + PoolSize int `json:"pool_size"` } // Route defines available routes for the service. diff --git a/testdata/tarmac.json b/testdata/tarmac.json index b3354d6..6a223fc 100644 --- a/testdata/tarmac.json +++ b/testdata/tarmac.json @@ -7,16 +7,19 @@ "filepath": "/testdata/default/tarmac.wasm" }, "kv": { - "filepath": "/testdata/kv/tarmac.wasm" + "filepath": "/testdata/kv/tarmac.wasm", + "pool_size": 1000 }, "logger": { "filepath": "/testdata/logger/tarmac.wasm" }, "sql": { - "filepath": "/testdata/sql/tarmac.wasm" + "filepath": "/testdata/sql/tarmac.wasm", + "pool_size": 10 }, "func": { - "filepath": "/testdata/function/tarmac.wasm" + "filepath": "/testdata/function/tarmac.wasm", + "pool_size": 1 } }, "routes": [