engine

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDebugPort = 8000

Variables

This section is empty.

Functions

func BuildEnv

func BuildEnv(options StartOptions, envOptions EnvOptions) []string

func CheckMockStatus

func CheckMockStatus(port int) error

CheckMockStatus invokes the status endpoint on the specified port and checks it returns an HTTP 200 status.

func EnsureFileCacheDir

func EnsureFileCacheDir() (string, error)

func GetConfiguredVersion

func GetConfiguredVersion(engineType EngineType, override string, allowCached bool) string

func GetConfiguredVersionOrResolve

func GetConfiguredVersionOrResolve(engineType EngineType, override string, allowCached bool, resolveIfLatest bool) string

func GetHighestVersion

func GetHighestVersion(engines []EngineMetadata) string

func IsMockUp

func IsMockUp(port int) (success bool)

IsMockUp invokes the status endpoint on the specified port and returns a boolean indicating whether it is healthy.

func PopulateHealth

func PopulateHealth(mock *ManagedMock)

func RegisterEngine

func RegisterEngine(engineType EngineType, b func(configDir string, startOptions StartOptions) MockEngine)

func RegisterLibrary

func RegisterLibrary(engineType EngineType, b func() EngineLibrary)

func ResolveLatestToVersion

func ResolveLatestToVersion(engineType EngineType, allowCached bool) (string, error)

func SanitiseVersionOutput

func SanitiseVersionOutput(s string) string

func WaitForOp

func WaitForOp(desc string, timeoutDuration time.Duration, abortC chan bool, operation func() bool) (success bool)

func WaitForUrl

func WaitForUrl(desc string, url string, abortC chan bool) (success bool)

func WaitUntilUp

func WaitUntilUp(port int, shutDownC chan bool) (success bool)

Types

type EngineLibrary

type EngineLibrary interface {
	CheckPrereqs() (bool, []string)
	List() ([]EngineMetadata, error)
	GetProvider(version string) Provider

	// IsSealedDistro indicates whether a library represents a fixed distribution.
	// Fixed distributions have a single version, so do not support version
	// resolution or fetching engine binaries.
	IsSealedDistro() bool

	// ShouldEnsurePlugins indicates whether missing default plugins should be
	// installed before starting the engine.
	ShouldEnsurePlugins() bool
}

func GetLibrary

func GetLibrary(engineType EngineType) EngineLibrary

type EngineMetadata

type EngineMetadata struct {
	EngineType EngineType
	Version    string
}

func (*EngineMetadata) Build

func (e *EngineMetadata) Build(configDir string, startOptions StartOptions) MockEngine

type EngineType

type EngineType string
const (
	EngineTypeNone             EngineType = ""
	EngineTypeAwsLambda        EngineType = "awslambda"
	EngineTypeDockerCore       EngineType = "docker"
	EngineTypeDockerAll        EngineType = "docker-all"
	EngineTypeDockerDistroless EngineType = "docker-distroless"
	EngineTypeJvmSingleJar     EngineType = "jvm"
	EngineTypeJvmUnpacked      EngineType = "unpacked"
	EngineTypeGolang           EngineType = "golang"
)

func EnumerateLibraries

func EnumerateLibraries() []EngineType

func GetConfiguredType

func GetConfiguredType(override string) EngineType

func GetConfiguredTypeWithDefault

func GetConfiguredTypeWithDefault(override string, defaultType EngineType) EngineType

type EnvOptions

type EnvOptions struct {
	IncludeHome bool
	IncludePath bool
}

type ManagedMock

type ManagedMock struct {
	ID     string
	Name   string
	Port   int
	Health MockHealth
}

type MockEngine

type MockEngine interface {
	Start(wg *sync.WaitGroup) (success bool)
	Stop(wg *sync.WaitGroup)
	StopImmediately(wg *sync.WaitGroup)
	Restart(wg *sync.WaitGroup)
	ListAllManaged() ([]ManagedMock, error)
	StopAllManaged() int
	GetVersionString() (string, error)
}

func BuildEngine

func BuildEngine(engineType EngineType, configDir string, startOptions StartOptions) MockEngine

BuildEngine is a convenience function that gets the library for the given engine type, obtains a provider for the version specified in the start options, then invokes the provider's builder function.

Note that the provider's Provide() function is not invoked explicitly, although it may be invoked implicitly from the builder function.

type MockHealth

type MockHealth string
const (
	MockHealthHealthy   MockHealth = "healthy"
	MockHealthUnhealthy MockHealth = "unhealthy"
	MockHealthUnknown   MockHealth = "unknown"
)

type Provider

type Provider interface {
	Satisfied() bool
	Provide(policy PullPolicy) error
	GetEngineType() EngineType
	Build(configDir string, startOptions StartOptions) MockEngine

	// Bundle creates a single archive file containing the engine binary and
	// configuration files. The archive is written to the specified destination.
	// If the engine type is 'docker', destination should be a valid image name.
	Bundle(configDir string, dest string) error
}

type PullPolicy

type PullPolicy int
const (
	PullSkip         PullPolicy = iota
	PullAlways       PullPolicy = iota
	PullIfNotPresent PullPolicy = iota
)

type StartOptions

type StartOptions struct {
	Port            int
	Version         string
	PullPolicy      PullPolicy
	LogLevel        string
	ReplaceRunning  bool
	Deduplicate     string
	EnablePlugins   bool
	EnableFileCache bool
	Environment     []string
	DirMounts       []string
	DebugMode       bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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