handlers

package
v0.0.0-...-a7e6769 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: MIT Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const (
	//OrchestrationIdentifier identifier string for swarm provider
	OrchestrationIdentifier = "swarm"
	//ProviderName provider string for swarm provider
	ProviderName = "faas-swarm"
)
View Source
const DefaultMaxReplicas = 20

DefaultMaxReplicas is the amount of replicas a service will auto-scale up to.

View Source
const MaxScaleLabel = "com.openfaas.scale.max"

MaxScaleLabel label indicating max scale for a function

View Source
const MinScaleLabel = "com.openfaas.scale.min"

MinScaleLabel label indicating min scale for a function

Variables

This section is empty.

Functions

func BuildEncodedAuthConfig

func BuildEncodedAuthConfig(basicAuthB64 string, dockerImage string) (string, error)

BuildEncodedAuthConfig parses the image name for a repository, user name, and image name If a repository is not included (ie: username/function-name), 'docker.io/' will be prepended

func DeleteHandler

func DeleteHandler(c ServiceDeleter) http.HandlerFunc

DeleteHandler delete a function

func DeployHandler

func DeployHandler(c *client.Client, maxRestarts uint64, restartDelay time.Duration) http.HandlerFunc

DeployHandler creates a new function (service) inside the swarm network.

func FunctionReader

func FunctionReader(wildcard bool, c client.ServiceAPIClient) http.HandlerFunc

FunctionReader reads functions from Swarm metadata

func Health

func Health() http.HandlerFunc

func MakeInfoHandler

func MakeInfoHandler(version, sha string) http.HandlerFunc

MakeInfoHandler creates handler for /system/info endpoint

func MakeSecretsHandler

func MakeSecretsHandler(c client.SecretAPIClient) http.HandlerFunc

MakeSecretsHandler returns handler for managing secrets

func NamespaceLister

func NamespaceLister() http.HandlerFunc

Swarm does not use namespaces, so we return an empty list. see https://github.com/openfaas-incubator/connector-sdk/pull/46

func NewLogRequester

func NewLogRequester(client ServiceLogger) logs.Requester

NewLogRequester returns a Requestor instance that can be used in the function logs endpoint

func ReplicaReader

func ReplicaReader(c *client.Client) http.HandlerFunc

ReplicaReader reads replica and image status data from a function

func ReplicaUpdater

func ReplicaUpdater(c *client.Client) http.HandlerFunc

ReplicaUpdater updates a function

func UpdateHandler

func UpdateHandler(c *client.Client, maxRestarts uint64, restartDelay time.Duration) http.HandlerFunc

UpdateHandler updates an existng function

Types

type FunctionLookup

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

FunctionLookup is a openfaas-provider proxy.BaseURLResolver that allows the caller to verify that a function is resolvable.

func NewFunctionLookup

func NewFunctionLookup(client ServiceLister, dnsRoundRobin bool) *FunctionLookup

NewFunctionLookup creates a new FunctionLookup resolver

func (*FunctionLookup) Resolve

func (l *FunctionLookup) Resolve(name string) (u url.URL, err error)

Resolve implements the openfaas-provider proxy.BaseURLResolver interface. In short it verifies that a function with the given name is resolvable by Docker Swarm. It can be configured to do this via DNS or by querying the Docker Service list.

func (*FunctionLookup) ResolveContext

func (l *FunctionLookup) ResolveContext(ctx context.Context, name string) (u url.URL, err error)

ResolveContext provides an implementation of openfaas-provider proxy.BaseURLResolver with context support. See `Resolve`

type LogRequester

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

LogRequester implements the Requester interface for Swarm

func (LogRequester) Query

func (l LogRequester) Query(ctx context.Context, r logs.Request) (<-chan logs.Message, error)

Query implements the actual Swarm logs request logic for the Requester interface

type ScaleServiceRequest

type ScaleServiceRequest struct {
	ServiceName string `json:"serviceName"`
	Replicas    uint64 `json:"replicas"`
}

ScaleServiceRequest request to scale a function

type ServiceDeleter

type ServiceDeleter interface {
	ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
	ServiceRemove(ctx context.Context, serviceID string) error
}

ServiceDeleter is the sub-interface of client.ServiceAPIClient that is required for deleting a OpenFaaS Function. This interface is satisfied by *client.Client

type ServiceLister

type ServiceLister interface {
	ServiceList(context.Context, types.ServiceListOptions) ([]swarm.Service, error)
}

ServiceLister is the subset of the Docker client.ServiceAPIClient needed to enable the function lookup

type ServiceLogger

type ServiceLogger interface {
	ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
}

ServiceLogger is the subset of Docker Client methods required for querying function logs

type ServiceQuery

type ServiceQuery interface {
	GetReplicas(service string) (currentReplicas uint64, maxReplicas uint64, minReplicas uint64, err error)
	SetReplicas(service string, count uint64) error
}

ServiceQuery provides interface for replica querying/setting

func NewSwarmServiceQuery

func NewSwarmServiceQuery(c *client.Client) ServiceQuery

NewSwarmServiceQuery create new Docker Swarm implementation

type SwarmServiceQuery

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

SwarmServiceQuery implementation for Docker Swarm

func (SwarmServiceQuery) GetReplicas

func (s SwarmServiceQuery) GetReplicas(serviceName string) (uint64, uint64, uint64, error)

GetReplicas replica count for function

func (SwarmServiceQuery) SetReplicas

func (s SwarmServiceQuery) SetReplicas(serviceName string, count uint64) error

SetReplicas update the replica count

Jump to

Keyboard shortcuts

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