...

Package faas_openfaas

import "scheduler/faas_openfaas"
Overview
Index

Overview ▾

Package faas_openfaas implements a faas execution logic based on the OpenFaaS framework

Index ▾

func ComputeFunctionMD5(fn *Function) string
func FunctionDeploy(function Function) (*types.FaasApiResponse, error)
func FunctionExecute(functionName string, payload []byte, contentType string) (*types.FaasApiResponse, error)
func FunctionGetAvailableReplicas(serviceName string) (uint, error)
func FunctionGetReplicas(serviceName string) (uint, error)
func FunctionScale(functionName string, replicas uint) (*types.FaasApiResponse, error)
func FunctionScaleByOne(functionName string) (*types.FaasApiResponse, error)
func FunctionScaleDownByOne(functionName string) (*types.FaasApiResponse, error)
func GenFunctionDeploy(host string, function Function) (*types.FaasApiResponse, error)
func GenFunctionExecute(host string, functionName string, payload []byte, contentType string) (*types.FaasApiResponse, error)
func GenFunctionGetAvailableReplicas(host string, serviceName string) (uint, error)
func GenFunctionGetReplicas(host string, serviceName string) (uint, error)
func GenFunctionScale(host string, functionName string, replicas uint) (*types.FaasApiResponse, error)
func GenFunctionScaleByOne(host string, functionName string) (*types.FaasApiResponse, error)
func GenFunctionScaleDownByOne(host string, functionName string) (*types.FaasApiResponse, error)
func GetApiFunctionUrl(host string, functionName string) string
func GetApiScaleFunction(host string, functionName string) string
func GetApiSystemFunctionUrl(host string, functionName string) string
func GetApiSystemFunctionsUrl(host string) string
func GetApiUrl(host string) string
func GetDurationFromExecuteApiCallResponse(res *types.FaasApiResponse) float64
func HttpGet(url string) (*http.Response, error)
func HttpPost(url string, payload []byte, contentType string) (*http.Response, error)
func HttpPostJSON(url string, json string) (*http.Response, error)
func SetAuthHeader(req *http.Request)
type CurrentLoad
    func GenGetCurrentLoad(host string) (*CurrentLoad, error)
    func GetCurrentLoad() (*CurrentLoad, error)
type ErrorFunctionNotFound
    func (ErrorFunctionNotFound) Error() string
type ErrorGeneric
    func (e ErrorGeneric) Error() string
type ErrorHttpCannotCreateRequest
    func (e ErrorHttpCannotCreateRequest) Error() string
type ErrorImpossibleToScaleFunction
    func (e ErrorImpossibleToScaleFunction) Error() string
type ErrorInternal
    func (e ErrorInternal) Error() string
type Function
    func FunctionGet(functionName string) (*Function, *types.FaasApiResponse, error)
    func FunctionsGet() ([]Function, *types.FaasApiResponse, error)
    func GenFunctionGet(host string, functionName string) (*Function, *types.FaasApiResponse, error)
    func GenFunctionsGet(host string) ([]Function, *types.FaasApiResponse, error)
type FunctionScalePayload
type IdentifiableFunction
type MachineResources
type Service

Package files

api_function_deploy.go api_function_execute.go api_function_get.go api_function_scale.go api_functions_get.go errors.go faas.go services.go services_generic.go services_utils.go services_utils_generic.go types.go utils.go

func ComputeFunctionMD5

func ComputeFunctionMD5(fn *Function) string

ComputeFunctionMD5 computes the ID of a function

func FunctionDeploy

func FunctionDeploy(function Function) (*types.FaasApiResponse, error)

func FunctionExecute

func FunctionExecute(functionName string, payload []byte, contentType string) (*types.FaasApiResponse, error)

func FunctionGetAvailableReplicas

func FunctionGetAvailableReplicas(serviceName string) (uint, error)

func FunctionGetReplicas

func FunctionGetReplicas(serviceName string) (uint, error)

func FunctionScale

func FunctionScale(functionName string, replicas uint) (*types.FaasApiResponse, error)

func FunctionScaleByOne

func FunctionScaleByOne(functionName string) (*types.FaasApiResponse, error)

func FunctionScaleDownByOne

func FunctionScaleDownByOne(functionName string) (*types.FaasApiResponse, error)

func GenFunctionDeploy

func GenFunctionDeploy(host string, function Function) (*types.FaasApiResponse, error)

func GenFunctionExecute

func GenFunctionExecute(host string, functionName string, payload []byte, contentType string) (*types.FaasApiResponse, error)

func GenFunctionGetAvailableReplicas

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

func GenFunctionGetReplicas

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

func GenFunctionScale

func GenFunctionScale(host string, functionName string, replicas uint) (*types.FaasApiResponse, error)

func GenFunctionScaleByOne

func GenFunctionScaleByOne(host string, functionName string) (*types.FaasApiResponse, error)

func GenFunctionScaleDownByOne

func GenFunctionScaleDownByOne(host string, functionName string) (*types.FaasApiResponse, 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 *types.FaasApiResponse) 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)

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

func (e ErrorHttpCannotCreateRequest) Error() string

type ErrorImpossibleToScaleFunction

type ErrorImpossibleToScaleFunction struct{}

func (ErrorImpossibleToScaleFunction) Error

func (e ErrorImpossibleToScaleFunction) Error() string

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"`
}

func FunctionGet

func FunctionGet(functionName string) (*Function, *types.FaasApiResponse, error)

func FunctionsGet

func FunctionsGet() ([]Function, *types.FaasApiResponse, error)

func GenFunctionGet

func GenFunctionGet(host string, functionName string) (*Function, *types.FaasApiResponse, error)

func GenFunctionsGet

func GenFunctionsGet(host string) ([]Function, *types.FaasApiResponse, error)

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"`
}