serverless

package
v0.0.0-...-e06565c Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AWS_LAUNCH_LOCK_PREFIX = "aws_launch_lock_"
)
View Source
var (
	ErrFunctionNotFound = errors.New("no function found")
)
View Source
var (
	SERVERLESS_CONNECTOR_API_KEY string
)

Functions

func Init

func Init(config *app.Config)

func LaunchPlugin

func LaunchPlugin(
	originPackage []byte,
	decoder decoder.PluginDecoder,
	timeout int,
	ignoreIdempotent bool,
) (*stream.Stream[LaunchFunctionResponse], error)

LaunchPlugin uploads the plugin to specific serverless connector return the function url and name

func Ping

func Ping() error

Ping the serverless connector, return error if failed

func SetupFunction

func SetupFunction(
	manifest plugin_entities.PluginDeclaration,
	checksum string,
	context io.Reader,
	timeout int,
) (*stream.Stream[LaunchFunctionResponse], error)

Setup the function from serverless connector, it will receive the context as the input and build it a docker image, then run it on serverless platform like AWS Lambda it returns a event stream, the caller should consider it as a async operation

Types

type LaunchFunctionEvent

type LaunchFunctionEvent string
const (
	Error       LaunchFunctionEvent = "error"
	Info        LaunchFunctionEvent = "info"
	Function    LaunchFunctionEvent = "function"
	FunctionUrl LaunchFunctionEvent = "function_url"
	Done        LaunchFunctionEvent = "done"
)

type LaunchFunctionFinalStageMessage

type LaunchFunctionFinalStageMessage struct {
	Endpoint string `comma:"endpoint"`
	Name     string `comma:"name"`
	ID       string `comma:"id"`
}

type LaunchFunctionResponse

type LaunchFunctionResponse struct {
	Event   LaunchFunctionEvent `json:"event"`
	Message string              `json:"message"`
}

type LaunchFunctionResponseChunk

type LaunchFunctionResponseChunk struct {
	Stage   LaunchStage `json:"Stage"`
	Obj     string      `json:"Obj"`
	State   LaunchState `json:"State"`
	Message string      `json:"Message"`
}

type LaunchStage

type LaunchStage string
const (
	LAUNCH_STAGE_HEALTHZ LaunchStage = "healthz"
	LAUNCH_STAGE_START   LaunchStage = "start"
	LAUNCH_STAGE_BUILD   LaunchStage = "build"
	LAUNCH_STAGE_RUN     LaunchStage = "run"
	LAUNCH_STAGE_END     LaunchStage = "end"
)

type LaunchState

type LaunchState string
const (
	LAUNCH_STATE_SUCCESS LaunchState = "success"
	LAUNCH_STATE_RUNNING LaunchState = "running"
	LAUNCH_STATE_FAILED  LaunchState = "failed"
)

type RunnerInstance

type RunnerInstance struct {
	ID           string `json:"ID" validate:"required"`
	Name         string `json:"Name" validate:"required"`
	Endpoint     string `json:"Endpoint" validate:"required"`
	ResourceName string `json:"ResourceName" validate:"required"`
	Status       struct {
		State string `json:"State" validate:"required"`
	} `json:"Status" validate:"required"`
}

type RunnerInstances

type RunnerInstances struct {
	Error string           `json:"error"`
	Items []RunnerInstance `json:"Items"`
}

type ServerlessFunction

type ServerlessFunction struct {
	FunctionName string `json:"function_name" validate:"required"`
	FunctionDRN  string `json:"function_drn" validate:"required"`
	FunctionURL  string `json:"function_url" validate:"required"`
}

func FetchFunction

func FetchFunction(manifest plugin_entities.PluginDeclaration, checksum string) (*ServerlessFunction, error)

Fetch the function from serverless connector, return error if failed

Jump to

Keyboard shortcuts

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