faas

package
v0.0.0-...-5ae6e0f Latest Latest
Warning

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

Go to latest
Published: May 15, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package faas makes possible the communication with the OpenFaaS service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeFunctionMD5

func ComputeFunctionMD5(fn *Function) string

ComputeFunctionMD5 computes the ID of a function

func FunctionGet

func FunctionGet(functionName string) (*Function, *APIResponse, error)

func FunctionGetAvailableReplicas

func FunctionGetAvailableReplicas(serviceName string) (uint, error)

func FunctionGetReplicas

func FunctionGetReplicas(serviceName string) (uint, error)

func FunctionsGet

func FunctionsGet() ([]Function, *APIResponse, error)

func GenFunctionGet

func GenFunctionGet(host string, functionName string) (*Function, *APIResponse, error)

func GenFunctionGetAvailableReplicas

func GenFunctionGetAvailableReplicas(host string, serviceName string) (uint, error)

func GenFunctionGetReplicas

func GenFunctionGetReplicas(host string, serviceName string) (uint, error)

func GenFunctionsGet

func GenFunctionsGet(host string) ([]Function, *APIResponse, error)

func GetApiFunctionUrl

func GetApiFunctionUrl(host string, functionName string) string

func GetApiScaleFunction

func GetApiScaleFunction(host string, functionName string) string

func GetApiSystemFunctionUrl

func GetApiSystemFunctionUrl(host string, functionName string) string

func GetApiSystemFunctionsUrl

func GetApiSystemFunctionsUrl(host string) string

func GetApiUrl

func GetApiUrl(host string) string

func GetDurationFromExecuteApiCallResponse

func GetDurationFromExecuteApiCallResponse(res *APIResponse) float64

func HttpGet

func HttpGet(url string) (*http.Response, error)

func HttpPost

func HttpPost(url string, payload []byte, contentType string) (*http.Response, error)

func HttpPostJSON

func HttpPostJSON(url string, json string) (*http.Response, error)

func SetAuthHeader

func SetAuthHeader(req *http.Request)

Types

type APIResponse

type APIResponse struct {
	Headers    http.Header
	Body       []byte
	StatusCode int
}

func FunctionDeploy

func FunctionDeploy(function Function) (*APIResponse, error)

func FunctionExecute

func FunctionExecute(functionName string, payload []byte, contentType string) (*APIResponse, error)

func FunctionScale

func FunctionScale(functionName string, replicas uint) (*APIResponse, error)

func FunctionScaleByOne

func FunctionScaleByOne(functionName string) (*APIResponse, error)

func FunctionScaleDownByOne

func FunctionScaleDownByOne(functionName string) (*APIResponse, error)

func GenFunctionDeploy

func GenFunctionDeploy(host string, function Function) (*APIResponse, error)

func GenFunctionExecute

func GenFunctionExecute(host string, functionName string, payload []byte, contentType string) (*APIResponse, error)

func GenFunctionScale

func GenFunctionScale(host string, functionName string, replicas uint) (*APIResponse, error)

func GenFunctionScaleByOne

func GenFunctionScaleByOne(host string, functionName string) (*APIResponse, error)

func GenFunctionScaleDownByOne

func GenFunctionScaleDownByOne(host string, functionName string) (*APIResponse, error)

type CurrentLoad

type CurrentLoad struct {
	NumberOfServices       uint `json:"total_services" bson:"total_services"`
	TotalReplicas          uint `json:"total_replicas" bson:"total_running_replicas"`
	TotalAvailableReplicas uint `json:"total_available_replicas" bson:"total_available_replicas"`
}

func GenGetCurrentLoad

func GenGetCurrentLoad(host string) (*CurrentLoad, error)

GetCurrentLoad parse the current load from OpenFaas

func GetCurrentLoad

func GetCurrentLoad() (*CurrentLoad, error)

GetCurrentLoad parse the current load from OpenFaas

type ErrorFunctionNotFound

type ErrorFunctionNotFound struct{}

func (ErrorFunctionNotFound) Error

func (ErrorFunctionNotFound) Error() string

type ErrorGeneric

type ErrorGeneric struct {
	ResponseBody string
}

func (ErrorGeneric) Error

func (e ErrorGeneric) Error() string

type ErrorHttpCannotCreateRequest

type ErrorHttpCannotCreateRequest struct{}

func (ErrorHttpCannotCreateRequest) Error

type ErrorImpossibleToScaleFunction

type ErrorImpossibleToScaleFunction struct{}

func (ErrorImpossibleToScaleFunction) Error

type ErrorInternal

type ErrorInternal struct {
	ResponseBody string
}

func (ErrorInternal) Error

func (e ErrorInternal) Error() string

type Function

type Function struct {
	Name         string            `json:"name,omitempty" bson:"name"`
	Service      string            `json:"service,omitempty" bson:"service"`
	Network      string            `json:"network,omitempty" bson:"network"`
	Image        string            `json:"image,omitempty" bson:"image"`
	EnvProcess   string            `json:"envProcess,omitempty" bson:"envProcess"`
	EnvVars      map[string]string `json:"envVars,omitempty" bson:"envVars"`
	Constraints  []string          `json:"constraints,omitempty" bson:"constraints"`
	Labels       map[string]string `json:"labels,omitempty" bson:"labels"`
	Annotations  []string          `json:"annotations,omitempty" bson:"annotations"`
	Secrets      []string          `json:"secrets,omitempty" bson:"secrets"`
	RegistryAuth string            `json:"registryAuth,omitempty" bson:"registryAuth"`
	Limits       MachineResources  `json:"limits,omitempty" bson:"limits"`
	Requests     MachineResources  `json:"requests,omitempty" bson:"requests"`

	InvocationCount   uint `json:"invocationCount,omitempty" bson:"invocationCount"`
	Replicas          uint `json:"replicas,omitempty" bson:"replicas"`
	AvailableReplicas uint `json:"availableReplicas,omitempty" bson:"availableReplicas"`
}

type FunctionScalePayload

type FunctionScalePayload struct {
	Service  string `json:"service,omitempty" bson:"service"`
	Replicas uint   `json:"replicas,omitempty" bson:"replicas"`
}

type IdentifiableFunction

type IdentifiableFunction struct {
	Name         string            `json:"name,omitempty" bson:"name"`
	Service      string            `json:"service,omitempty" bson:"service"`
	Network      string            `json:"network,omitempty" bson:"network"`
	Image        string            `json:"image,omitempty" bson:"image"`
	EnvProcess   string            `json:"envProcess,omitempty" bson:"envProcess"`
	EnvVars      map[string]string `json:"envVars,omitempty" bson:"envVars"`
	Constraints  []string          `json:"constraints,omitempty" bson:"constraints"`
	Labels       map[string]string `json:"labels,omitempty" bson:"labels"`
	Annotations  []string          `json:"annotations,omitempty" bson:"annotations"`
	Secrets      []string          `json:"secrets,omitempty" bson:"secrets"`
	RegistryAuth string            `json:"registryAuth,omitempty" bson:"registryAuth"`
	Limits       MachineResources  `json:"limits,omitempty" bson:"limits"`
	Requests     MachineResources  `json:"requests,omitempty" bson:"requests"`
}

type MachineResources

type MachineResources struct {
	Memory string `json:"memory,omitempty" bson:"memory"`
	CPU    string `json:"cpu,omitempty" bson:"cpu"`
}

type Service

type Service struct {
	OpenFaaSFunction Function `json:"openfaas_service,omitempty" bson:"openfaas_service"`
	Deadline         uint64   `json:"deadline,omitempty" bson:"deadline"`
}

Jump to

Keyboard shortcuts

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