compute-sdk-go

module
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2023 License: Apache-2.0, BSD-3-Clause

README

compute-sdk-go

Experimental Go SDK for building Compute@Edge applications with TinyGo.

Quick Start

The Fastly Developer Hub has a great Quick Start guide for Go.

Alternatively, you can take a look at the Go Starter Kit.

You'll also want to take a look at our Recommended Packages section, as this can help with the sharp edges of the SDK, like JSON support.

Installation

First, install TinyGo by following the TinyGo Quick install guide.

Then, you can install compute-sdk-go in your project by running:

go get github.com/fastly/compute-sdk-go

Examples

Examples can be found in the examples directory.

The Fastly Developer Hub has a collection of common use cases in VCL ported to TinyGo which also acts as a great set of introductory examples of using TinyGo on Compute@Edge.

API Reference

The API reference documentation can be found on pkg.go.dev/github.com/fastly/compute-sdk-go.

Testing

Tests that rely on a Compute@Edge runtime can utilize Viceroy, our local development tool.

First, you'll need to install Viceroy and ensure the viceroy command is available in your path.

Next, you'll need to create a TinyGo target that knows to run Viceroy. You can copy the compute-at-edge.json file from this repository for this purpose. (In the future, we will include this in the Go starter kits.)

Write your tests as ordinary Go tests. You can use Compute@Edge APIs in your tests, although be aware that not all platform functionality is available in Viceroy. You can look at the integration_tests directory for examples.

Finally, run your tests:

tinygo test -target=compute-at-edge.json ./...

You can try it out and make sure your local Viceroy environment is set up correctly by running the integration tests in this repository:

tinygo test -target=compute-at-edge.json ./integration_tests/...

Logging

Logging can be done using a Fastly Compute@Edge Log Endpoint (example), or by using normal stdout like:

fmt.Printf("request received: %s\n", r.URL.String())

TinyGo is still a new project, which has yet to get a version 1.0.0. Therefore, the project is incomplete, but in its current state can still handle a lot of tasks on Compute@Edge. However, some languages features of Go are still missing.

To help with your adoption of compute-sdk-go, here are some recommended packages to help with some of the current missing language features:

JSON Parsing

TinyGo's reflect support (which is needed by encoding/json among other things) is still new. While most use cases should work, for performance or other compatibility reasons you might need to consider a third-party JSON package if the standard library doesn't meet your needs.

Changelog

The changelog can be found here.

Security

If you find any security issues, see the Fastly Security Reporting Page or send an email to: security@fastly.com

Note that communications related to security issues in Fastly-maintained OSS as described here are distinct from Fastly security advisories.

License

Apache-2.0 WITH LLVM-exception

Directories

Path Synopsis
_app_template
_examples
corecache command
geodata command
hello-world command
http-adapter command
kvstore command
limits command
logging-and-env command
middlewares command
print-request command
proxy-request command
secret-store command
set-cookie command
simplecache command
stream-response command
with-timeout command
cache
core
Package core provides the Fastly Core Cache API.
Package core provides the Fastly Core Cache API.
simple
Package simple provides the Simple Cache API, a simplified interface to inserting and retrieving entries from Fastly's cache.
Package simple provides the Simple Cache API, a simplified interface to inserting and retrieving entries from Fastly's cache.
Package configstore provides a read-only interface to config stores.
Package configstore provides a read-only interface to config stores.
Package edgedict provides a read-only interface to edge dictionaries.
Package edgedict provides a read-only interface to edge dictionaries.
Package fsthttp provides HTTP functionality for Fastly's Compute@Edge environment.
Package fsthttp provides HTTP functionality for Fastly's Compute@Edge environment.
Package geo provides access to the geographic data for IP addresses.
Package geo provides access to the geographic data for IP addresses.
internal
abi/fastly
Package fastly provides access to the Compute@Edge hostcall ABI.
Package fastly provides access to the Compute@Edge hostcall ABI.
abi/prim
Package prim contains primitive types used in Wasm ABI functions.
Package prim contains primitive types used in Wasm ABI functions.
abi/wasi
Package wasi provides access to Wasi features independent of Compute@Edge.
Package wasi provides access to Wasi features independent of Compute@Edge.
Package kvstore provides access to Fastly KV stores.
Package kvstore provides access to Fastly KV stores.
Deprecated: Use the kvstore package instead.
Deprecated: Use the kvstore package instead.
Package purge provides cache purging operations for Fastly Compute@Edge.
Package purge provides cache purging operations for Fastly Compute@Edge.
Package rtlog provides an interface to real-time logging endpoints.
Package rtlog provides an interface to real-time logging endpoints.
Package secretstore provides a read-only interface to Fastly Compute@Edge Secret Stores.
Package secretstore provides a read-only interface to Fastly Compute@Edge Secret Stores.
x
Package x contains temporary and/or experimental sub-packages.
Package x contains temporary and/or experimental sub-packages.
fstctx
Package fstctx provides alternatives to context.WithTimeout and context.WithDeadline.
Package fstctx provides alternatives to context.WithTimeout and context.WithDeadline.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL