An overview of Golang support in Scale Functions
HTTP Signature
,
which provides an interface for handling HTTP requests and responses. To learn more about the HTTP Signature
and the
interfaces it provides, you can check out the HTTP Signature Reference. Learn more about Signatures in the Signatures Overview.
Compiling these Functions requires the appropriate toolchain to be installed on your machine.
1.18
.0.27.0
.Run
method on the Scale Runtime with your request//go:embed
directive, after it has been
exported using the scale fn export
command (see Exporting Scale Functions).
Instance
method on it to get a new runtime instance.
The Context
method of the Instance
can then be used to set the request body, and the Run
method can be used to
run the Scale Function (or Functions).
r.Instance
method above. In actually, it is possible to pass in
one or multiple native golang functions (with the signature (ctx *signature.Context) (*signature.Context, error)
) to be run
as part of the Scale Function chain.The Instance
method will automatically pass the result of the previous function to the next one (and pass the
responses back up through the chain).If you’re not using a native handler (or handlers) at the end of the chain, you can don’t need to pass anything
into the r.Instance
method.Instance
can be reused multiple times, but it’s not thread-safe. If you need to run
multiple instances of a Scale Function concurrently, you’ll need to create a new Instance
for each one.
Instances are heavily optimized and will recycle themselves automatically when they’re no longer in use. This means that
creating instances are very cheap and you can create as many as you need as often as you need.
Instance
method itself is thread-safe and can be called concurrently.Clear()
on the runtime itself: