Home

Awesome

Serverless Functions Go πŸ’œ

build-and-test golangci-lint

Scaleway Serverless Functions Go is a framework which simplify Scaleway Serverless Functions local development. It brings features to debug your function locally and provides input/output data format of Scaleway Serverless Functions.

This library helps you to write functions but for deployment refer to the documentation.

Get started with Scaleway Functions (we support multiple languages :rocket:):

Testing frameworks for Scaleway Serverless Functions in other languages can be found here:

βš™οΈ Quickstart

To get this package:

 go get github.com/scaleway/serverless-functions-go

Add in cmd/main.go the following code:

import "github.com/scaleway/serverless-functions-go/local"

func main() {
	// Replace "Handle" with your function handler name if necessary
	local.ServeHandler(Handle, local.WithPort(8080))
}

For more information on how to use the framework check theΒ  usage section.

πŸš€ Features

This repository aims to provide a better experience on: local testing, utils, documentation

🏑 Local testing

What this package does:

What this package does not:

πŸ”¬ Advanced usage

To run the function locally you need to add an entry point to serve your function.

This entrypoint should be put in a directory not required by your handler, e.g. cmd/main.go.

In your run/main.go add the following code to invoke your function :

package main

import (
  // "localfunc" is the module name located in your go.mod. To generate a go.mod with localfunc as name you
  // can use the following command : go mod init localfunc
  // Or you can replace "localfunc" with your own module name.
	localfunc "github.com/scaleway/serverless-functions-go/examples/handler"
	"github.com/scaleway/serverless-functions-go/local"
)

func main() {
	// Replace "Handle" with your function handler name if necessary
	local.ServeHandler(localfunc.Handle, local.WithPort(8080))
}

This file will expose your handler on a local web server allowing you to test your function.

Some information will be added to requests for example specific headers. For local development, additional header values are hardcoded to make it easy to differentiate them. In production, you will be able to observe headers with exploitable data.

Local testing part of this framework does not aim to simulate 100% production but it aims to make it easier to work with functions locally.

Cli

To run the server locally: go run cmd/main.go

VS Code

Open cmd/main.go and open the "Run and Debug" pannel to execute or debug your function there is no special configuration to add to VSCode.

Goland

The IDE will generate a run configuration for you, open cmd/main.go and run the main.

❓ FAQ

Why do I need an additional package to call my function?

Your Function Handler can be served by a simple HTTP server but Serverless Ecosystem involves a lot of different layers that will change changes the headers, input and output of your function. This package aims to simulate everything your request will go through to help you debug your application properly. This library is not mandatory to use Scaleway Serverless Functions.

How my function will be deployed

To deploy your function please refer to our official documentation.

Do I need to deploy my function differently?

No. This framework does not affect deployment nor performance.

πŸ›οΈ Architecture

To make development and understanding of this repository we tried to keep the path of the request natural.

πŸ›Ÿ Help & support

πŸŽ“ Contributing

Additionally we love to share things with the community and we want to expose receipts to the public. That's why we make our framework publicly available to help the community!

Do not hesitate to raise issues and pull requests we will have a look at them.

If you are looking for a way to contribute please read CONTRIBUTING.md.

πŸ“­ Reach Us

We love feedback. Feel free to: