serverless

package module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 18 Imported by: 9 modules, 9 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Serverless

This project provides Serverless runtimes for use with Knative.

Runtimes

  • Go
Go

The Go runtime reserves the following HTTP paths:

  • /metrics for Prometheus Metrics (if enabled)

Usage:

package main

import (
	"gitlab.com/autokubeops/serverless"
	"net/http"
)

func main() {
	serverless.NewBuilder(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		// put your application logic here
		_, _ = w.Write([]byte("OK"))
	})).
		WithPrometheus(). // enable prometheus metrics (optional)
		Run()
}
GRPC

The Go runtime supports dual HTTP/gRPC servers. It can be configured by calling the WithGRPC function when building the serverless function.

Example:

package main

import (
	"gitlab.com/autokubeops/serverless"
	"google.golang.org/grpc"
	"net/http"
)

func main() {
	// todo register your gRPC servers
	srv := grpc.NewServer()
	serverless.NewBuilder(http.NotFoundHandler()).
		WithGRPC(srv).
		Run()
}

Documentation

Index

Constants

View Source
const (
	HeaderContentType = "Content-Type"
	ApplicationGRPC   = "application/grpc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder added in v0.2.0

type Builder struct {
	// contains filtered or unexported fields
}

func NewBuilder added in v0.2.0

func NewBuilder(handler http.Handler) *Builder

func (*Builder) Run added in v0.2.0

func (b *Builder) Run()

func (*Builder) WithGRPC added in v0.3.0

func (b *Builder) WithGRPC(srv *grpc.Server) *Builder

WithGRPC allows the server to support hybrid http/grpc calls

func (*Builder) WithHandlers added in v0.3.1

func (b *Builder) WithHandlers(enabled bool) *Builder

WithHandlers toggles the use of Gorilla Handlers.

Handlers are enabled by default:

* RecoveryHandler - converts panics into 500 Internal Server Error * CombinedLoggingHandler - logging HTTP requests in a known format

func (*Builder) WithLogger added in v0.4.1

func (b *Builder) WithLogger(log logr.Logger) *Builder

WithLogger configures the logging implementation that is used.

Defaults to https://github.com/go-logr/stdr if this function is not called.

func (*Builder) WithPort added in v0.2.0

func (b *Builder) WithPort(port int) *Builder

WithPort sets the port that the server will run on.

func (*Builder) WithProbes added in v0.5.0

func (b *Builder) WithProbes(probes *probe.Handler) *Builder

WithProbes overrides the default configuration used for the HTTP health checks

func (*Builder) WithPrometheus added in v0.2.0

func (b *Builder) WithPrometheus() *Builder

WithPrometheus enables Prometheus metric collection from function invocation.

Deprecated

func (*Builder) WithTLS added in v0.6.0

func (b *Builder) WithTLS(certFile, keyFile string, tlsConfig *tls.Config) *Builder

Jump to

Keyboard shortcuts

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