function command is used to interact with Scale Functions locally. fn is an alias for function.
New
To create a new Scale Function, run the following command:The
scale new command is an alias for scale function new. You can use either command to login to the Scale API.--language flag:
go- Gorust- Rustts- TypeScript/JavaScript
We are actively working on adding support for more languages. If you would like to see a specific language supported, please let
us know by joining the
#scale channel in our Discord.Build
Thebuild subcommand is used to build a Scale Function using the toolchain for the Scale Function’s source language. It can be
run from the root of the Scale Function’s directory:
--directory flag can be used to specify the directory of the Scale Function:
--name, --org, and --tag flags can be used to specify the name, organization, and tag of the Scale Function at build time:
--cargo, --go, and --tinygo flags can be used to specify the path to the cargo, go, and tinygo executables.
List
Thelist subcommand is used to list all the compiled Scale Functions available in the local Scale Function cache.
--cache-directory flag:
Run
You can run your compiled scale functions locally using therun subcommand. This command will start a local HTTP server that will
execute the Scale Function when it receives an HTTP request.
--listen flag can be used to specify the address and port that the local HTTP server should listen on (by default it will listen on :8080)
It is also possible to provide multiple Scale Functions to the run subcommand. If you do, the local HTTP server will execute the
Scale Functions in a chain, and will only execute the next function in the chain if the previous function calls .Next().
Remember that the
--cache-directory configuration flag can be used to specify the directory of the Scale Function cache.run command will attempt to look for it in the Scale Registry (if the CLI is authenticated).
Export
Theexport subcommand is used to export a Scale Function from the local Scale Function cache to a local .scale file.
It’s helpful in situations where you want to distribute a Scale Function without using the Scale Registry, or
if you want to embed it inside your Runtime or Application.
<path> directory as a .scale file. The --output flag can be used to override
the name of the exported .scale file:
--raw flag can be used to export the raw WebAssembly .wasm binary instead of the .scale file: