Skip to content

Latest commit

 

History

History
75 lines (44 loc) · 2.62 KB

File metadata and controls

75 lines (44 loc) · 2.62 KB

⏮️ Back to main README.md

AssemblyScript Examples

Build

Initial Setup

Having pulled down the repo: git clone git@github.com:G-Core/FastEdge-examples.git

First enter the assemblyscript directory, followed by installing all the node_modules.

cd FastEdge-examples/assemblyscript &&
npm install

Building an example

e.g.

npm run build:geoBlock

Note: See package.json for other build scripts.

This will take the /geoBlock example and build the wasm into the ./build/geoBlock folder named as such: geoBlock.wasm

Running an example

Having built the binary of any of these examples you can safely load them within the Client Portal and test as you please.

Alternatively read here about using envoy locally. Please Note: Envoy is NOT a direct replacement!!

Proxy-Wasm API

At present not all proxy-wasm functionality is complete. This is still under construction.

Our @gcoredev/proxy-wasm-sdk-as does provide some helper functions:

Logging

As we do not yet have a complete proxy_log implementation, we are temporarily providing this functionality via a wasi-shim to std-out.

This means instead of importing the default Log function from @gcoredev/proxy-wasm-sdk-as/assembly please use the FastEdge version from @gcoredev/proxy-wasm-sdk-as/assembly/fastedge

It uses the same signature, so in the future only the import will need updating. See the JWT Example for usage.

By default only LogLevelValues.info messages and above will be logged. If you need Debug and/or Trace logging you can set the log level using:

setLogLevel(LogLevelValues.debug)

Environment Variables

Getting environment variables is as easy as importing the getEnvVar() from @gcoredev/proxy-wasm-sdk-as/assembly/fastedge

See the GeoBlock example for usage. If it does not find a matching envVar it returns an empty string.

Secret Variables

Getting secrets is as easy as importing the getSecretVar() from @gcoredev/proxy-wasm-sdk-as/assembly/fastedge

See the JWT example for usage. If it does not find a matching secret it returns an empty string.

secrets and slots explained