dockersetupcommand

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_NET_INTERFACE = "eth0"
	CLEANUP_CONTAINER_CMD = "tc qdisc del dev %s root"

	IMAGE_NAME          = "alpine:3.24.1"
	START_CONTAINER_CMD = "apk add --no-cache iproute2 && tc qdisc add dev %s root %s && sleep infinity"
)
View Source
const (
	DELAY_CONTAINER_CMD = "netem delay %dms"
)
View Source
const (
	PACKET_LOSS_CONTAINER_CMD = "netem loss %f%%"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ComposeUpCommand

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

func NewComposeUpCommand

func NewComposeUpCommand(cmd *parser.SetupCommandDTO, baseDir string, ctx context.Context) (*ComposeUpCommand, error)

func (*ComposeUpCommand) Cleanup

func (s *ComposeUpCommand) Cleanup() error

func (*ComposeUpCommand) Execute

func (s *ComposeUpCommand) Execute() error

type ContainerCommandExecutor

type ContainerCommandExecutor interface {
	Execute(containerId string, cmd string) error
}

type ContainerKiller

type ContainerKiller interface {
	Kill(containerId string) error
}

type ContainerPauser

type ContainerPauser interface {
	Pause(containerId string) error
}

type ContainerStarter

type ContainerStarter interface {
	Start(containerId string) error
}

type ContainerStopper

type ContainerStopper interface {
	Stop(containerId string) error
}

type ContainerThrottler

type ContainerThrottler interface {
	Throttle(cmd string, netInterface string, targetContainerId string) error
	Unthrottle(netInterface string, targetContainerId string) error
}

type ContainerUnpauser

type ContainerUnpauser interface {
	Unpause(containerId string) error
}

type CustomQdiscContainerCommand

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

func NewCustomQdiscContainerCommand

func NewCustomQdiscContainerCommand(cmd *parser.SetupCommandDTO, throttler ContainerThrottler) (*CustomQdiscContainerCommand, error)

func (*CustomQdiscContainerCommand) Cleanup

func (s *CustomQdiscContainerCommand) Cleanup() error

func (*CustomQdiscContainerCommand) Execute

func (s *CustomQdiscContainerCommand) Execute() error

type DelayContainerCommand

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

func NewDelayContainerCommand

func NewDelayContainerCommand(cmd *parser.SetupCommandDTO, throttler ContainerThrottler) (*DelayContainerCommand, error)

func (*DelayContainerCommand) Cleanup

func (s *DelayContainerCommand) Cleanup() error

func (*DelayContainerCommand) Execute

func (s *DelayContainerCommand) Execute() error

type DockerContainerThrottler

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

func (*DockerContainerThrottler) Throttle

func (t *DockerContainerThrottler) Throttle(cmd string, netInterface string, targetContainerId string) error

func (*DockerContainerThrottler) Unthrottle

func (t *DockerContainerThrottler) Unthrottle(netInterface string, targetContainerId string) error

type DockerHandler

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

func NewDockerHandler

func NewDockerHandler(cli *client.Client, baseDir string, ctx context.Context) *DockerHandler

func (*DockerHandler) Build

func (e *DockerHandler) Build(targetContainerId string, netInterface string, cmd string) (string, error)

Highly optimizable implementation

func (*DockerHandler) Execute

func (e *DockerHandler) Execute(containerId string, cmd string) error

ALERT: this Execute method is used to exec a command in a container, meanwhile the Execute method of the ExecContainerCommand is used to execute the command defined in the setup command

func (*DockerHandler) Kill

func (e *DockerHandler) Kill(containerId string) error

func (*DockerHandler) Pause

func (e *DockerHandler) Pause(containerId string) error

func (*DockerHandler) Start

func (e *DockerHandler) Start(containerId string) error

func (*DockerHandler) Stop

func (e *DockerHandler) Stop(containerId string) error

func (*DockerHandler) Unpause

func (e *DockerHandler) Unpause(containerId string) error

type DockerSetupCommand

type DockerSetupCommand interface {
	Execute() error
	Cleanup() error
}

func NewDockerSetupCommand

func NewDockerSetupCommand(cmd *parser.SetupCommandDTO, handler *DockerHandler) (DockerSetupCommand, error)

type ExecContainerCleanupCommand

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

func NewExecContainerCleanupCommand

func NewExecContainerCleanupCommand(cleanupCmd *parser.CleanupCommandDTO, containerId string, executor ContainerCommandExecutor) (*ExecContainerCleanupCommand, error)

func (*ExecContainerCleanupCommand) Cleanup

func (c *ExecContainerCleanupCommand) Cleanup() error

type ExecContainerCommand

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

func (*ExecContainerCommand) Cleanup

func (s *ExecContainerCommand) Cleanup() error

func (*ExecContainerCommand) Execute

func (s *ExecContainerCommand) Execute() error

type HelperContainerBuilder

type HelperContainerBuilder interface {
	Build(targetContainerId string, netInterface string, cmd string) (string, error)
}

type KillContainerCommand

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

func NewKillContainerCommand

func NewKillContainerCommand(cmd *parser.SetupCommandDTO, killer ContainerKiller, starter ContainerStarter) (*KillContainerCommand, error)

func (*KillContainerCommand) Cleanup

func (s *KillContainerCommand) Cleanup() error

func (*KillContainerCommand) Execute

func (s *KillContainerCommand) Execute() error

type PacketLossContainerCommand

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

func NewPacketLossContainerCommand

func NewPacketLossContainerCommand(cmd *parser.SetupCommandDTO, throttler ContainerThrottler) (*PacketLossContainerCommand, error)

func (*PacketLossContainerCommand) Cleanup

func (s *PacketLossContainerCommand) Cleanup() error

func (*PacketLossContainerCommand) Execute

func (s *PacketLossContainerCommand) Execute() error

type PauseContainerCommand

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

func NewPauseContainerCommand

func NewPauseContainerCommand(cmd *parser.SetupCommandDTO, pauser ContainerPauser, unpauser ContainerUnpauser) (*PauseContainerCommand, error)

func (*PauseContainerCommand) Cleanup

func (s *PauseContainerCommand) Cleanup() error

func (*PauseContainerCommand) Execute

func (s *PauseContainerCommand) Execute() error

type StartContainerCommand

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

func NewStartContainerCommand

func NewStartContainerCommand(cmd *parser.SetupCommandDTO, starter ContainerStarter, stopper ContainerStopper) (*StartContainerCommand, error)

func (*StartContainerCommand) Cleanup

func (s *StartContainerCommand) Cleanup() error

func (*StartContainerCommand) Execute

func (s *StartContainerCommand) Execute() error

type StopContainerCommand

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

func NewStopContainerCommand

func NewStopContainerCommand(cmd *parser.SetupCommandDTO, stopper ContainerStopper, starter ContainerStarter) (*StopContainerCommand, error)

func (*StopContainerCommand) Cleanup

func (s *StopContainerCommand) Cleanup() error

func (*StopContainerCommand) Execute

func (s *StopContainerCommand) Execute() error

type UnpauseContainerCommand

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

func NewUnpauseContainerCommand

func NewUnpauseContainerCommand(cmd *parser.SetupCommandDTO, unpauser ContainerUnpauser, pauser ContainerPauser) (*UnpauseContainerCommand, error)

func (*UnpauseContainerCommand) Cleanup

func (s *UnpauseContainerCommand) Cleanup() error

func (*UnpauseContainerCommand) Execute

func (s *UnpauseContainerCommand) Execute() error

Jump to

Keyboard shortcuts

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