This repo contains code that can be reused in other Ermes components.
This library exposes a logger that can be used in other Ermes components. It is based on zerolog.
This library exposes some common models that can be used in other Ermes components.
This library exposes some common utility functions that can be used in other Ermes components.
This library exposes some common cache implementations, based on golang-lru.
This library allows to create a pool of WASM runtimes which can execute WASM binaries. The WASM binaries can export two type of functions:
- Authentication function: it receives a token (string) and returns a user identifier (string)
- Regular function: it receives the http request body (map string, string) and the Ermes Context, and returns an http code and a response body
To execute regular function, this library also expose some Host Functions that can be used in the WASM runtime. The host function performs GET and SET operations on the redis data store and HTTP requests to the Central repository.
This repo also contains a test that starts a Testcontainer with Redis and a WASM pool. It then executes an auth function and a function that performs operation on some collections.
It is recommended to use the provided Docker Compose or DevContainer, which already satisfies all the requirements.
An example of usage can be found in the Central Repo.
You can easily run test in a container by executing
docker compose -f .devcontainer/docker-compose.yml upIn alternative, you can use GoLand with a Docker Compose as a run target, or the DevContainer, with a supported IDE (e.g. GoLand, VSCode).
Running locally should be possible, but requires additional configuration.
This configuration allow to execute GoLand on the host machine, and uses the container only to build and run the project.
- Open the project with GoLand.
- Start the docker-compose by pressing the play button in the
docker-compose.ymlfile - GoLand will a run configuration
Test WASM Poolthat build and run/debug the project in a new container
The first time you need to set up the run target:
- Click on
Test WASM Pooland selectEdit configurations - In the
Run onmenù, selectCreate new target>Docker compose - Select as configuration file the file
.devcontainer/docker-compose.yml - Select the
goservice and insert the project nameermes-wasm-pool - Click
nexttwo times - In the
Additional Settingsection, inProject sources directorywrite/workspaces/ermes-wasm-pool - Click
build - Click
Manage targetsand rename the new target asCompose
NB: When using the Test WASM Pool configuration, GoLand will leave some orphan container, just delete them manually.
This configuration runs the IDE inside the DevContainer. This requires more resources than the previous one, but it works out-of-the-box, without any additional configuration.
- Start Docker
- Open GoLand
- Open this project (or clone the repo if not already done)
- A popup should ask to reopen the project in the container, click
reopen
At this point to not use the Test WASM Pool configuration, but just run the test functions
You can also start the container by navigating to the devcontainer.json file
and use the Services tab to manage existing containers.
- Start Docker
- Open the project in VSCode
- A popup should ask to reopen the project in the container, click 'Reopen'