app

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppStatus

type AppStatus struct {
	Running bool
	State   string
	Image   string
	Port    int
}

AppStatus describes the current state of the application container.

type DockerClient

type DockerClient interface {
	PullImage(ctx context.Context, image string) error
	CreateContainer(ctx context.Context, config *docker.ContainerConfig) (string, error)
	StartContainer(ctx context.Context, containerID string) error
	StopContainer(ctx context.Context, containerID string, timeout *int) error
	RemoveContainer(ctx context.Context, containerID string, force bool) error
	ListContainersByLabels(ctx context.Context, labels map[string]string) ([]types.Container, error)
	GetContainerLogs(ctx context.Context, containerID string, tail int) (string, error)
}

DockerClient is the subset of *docker.Client used by the DockerManager.

type DockerManager

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

DockerManager runs the application under test as a Docker container. Like the mock services, the container is labelled so separate CLI invocations can find it again.

func NewDockerManager

func NewDockerManager(dockerClient DockerClient, logger *zap.Logger) *DockerManager

NewDockerManager creates a Docker-backed app manager.

func (*DockerManager) Logs

func (m *DockerManager) Logs(ctx context.Context, tail int) ([]string, error)

Logs returns the last tail lines of the application container logs.

func (*DockerManager) Restart

func (m *DockerManager) Restart(ctx context.Context, cfg *plugin.AppConfig) error

Restart stops the running application (if any) and starts it again.

func (*DockerManager) Start

func (m *DockerManager) Start(ctx context.Context, cfg *plugin.AppConfig) error

Start launches the application container. It fails if an application is already running.

func (*DockerManager) Status

func (m *DockerManager) Status(ctx context.Context) (*AppStatus, error)

Status reports the state of the application container.

func (*DockerManager) Stop

func (m *DockerManager) Stop(ctx context.Context) error

Stop stops and removes the application container.

type GenericLauncher

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

GenericLauncher runs an arbitrary local executable or script as the application under test, with a TCP readiness probe.

func NewGenericLauncher

func NewGenericLauncher(procMgr *process.Manager, logger *zap.Logger) *GenericLauncher

NewGenericLauncher creates a generic launcher backed by the given process manager.

func (GenericLauncher) GetPID

func (l GenericLauncher) GetPID() (int, error)

GetPID returns the PID of the running application.

func (GenericLauncher) IsReady

func (l GenericLauncher) IsReady(_ context.Context) (bool, error)

IsReady reports whether the application is up. With a configured port it runs the technology-specific probe; otherwise a running process is considered ready.

func (GenericLauncher) Launch

func (l GenericLauncher) Launch(ctx context.Context, config *plugin.AppConfig) error

Launch starts the application process.

func (GenericLauncher) Restart

func (l GenericLauncher) Restart(ctx context.Context) error

Restart stops and relaunches the application with the original config.

func (GenericLauncher) Stop

func (l GenericLauncher) Stop(_ context.Context) error

Stop terminates the application process gracefully.

func (GenericLauncher) Technology

func (l GenericLauncher) Technology() string

Technology returns the launcher identifier.

type GolangLauncher

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

GolangLauncher runs a compiled Go application as the application under test, with an HTTP readiness probe (any HTTP response means the server is up).

func NewGolangLauncher

func NewGolangLauncher(procMgr *process.Manager, logger *zap.Logger) *GolangLauncher

NewGolangLauncher creates a Go launcher backed by the given process manager.

func (GolangLauncher) GetPID

func (l GolangLauncher) GetPID() (int, error)

GetPID returns the PID of the running application.

func (GolangLauncher) IsReady

func (l GolangLauncher) IsReady(_ context.Context) (bool, error)

IsReady reports whether the application is up. With a configured port it runs the technology-specific probe; otherwise a running process is considered ready.

func (GolangLauncher) Launch

func (l GolangLauncher) Launch(ctx context.Context, config *plugin.AppConfig) error

Launch starts the application process.

func (GolangLauncher) Restart

func (l GolangLauncher) Restart(ctx context.Context) error

Restart stops and relaunches the application with the original config.

func (GolangLauncher) Stop

func (l GolangLauncher) Stop(_ context.Context) error

Stop terminates the application process gracefully.

func (GolangLauncher) Technology

func (l GolangLauncher) Technology() string

Technology returns the launcher identifier.

type Manager

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

Manager manages application lifecycle

func NewManager

func NewManager(launcher plugin.AppLauncher) *Manager

NewManager creates a new app manager

func (*Manager) Restart

func (m *Manager) Restart(ctx context.Context) error

Restart restarts the application

func (*Manager) Start

func (m *Manager) Start(ctx context.Context, config *plugin.AppConfig) error

Start starts the application

func (*Manager) Stop

func (m *Manager) Stop(ctx context.Context) error

Stop stops the application

Directories

Path Synopsis
Package nativeapp reproduces the legacy DIA component tool's golang app launcher (app-launchers/golang.bash, no docker image): it starts the project binaries built into $GOPATH/bin as detached native processes, each on an incrementing port with the emulator host env vars, and stops them by name.
Package nativeapp reproduces the legacy DIA component tool's golang app launcher (app-launchers/golang.bash, no docker image): it starts the project binaries built into $GOPATH/bin as detached native processes, each on an incrementing port with the emulator host env vars, and stops them by name.

Jump to

Keyboard shortcuts

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