Documentation
¶
Index ¶
- func Purge() error
- type Client
- type Container
- func (c *Container) Cleanup() error
- func (c *Container) Exec(cmd []string) (string, error)
- func (c *Container) GetAddressForService(service *network.ServiceDescription) *network.AddressPort
- func (c *Container) Hostname() string
- func (c *Container) IsRunning() bool
- func (c *Container) SaveLogTo(directory string) error
- func (c *Container) SendSignal(signal Signal) error
- func (c *Container) Stop() error
- func (c *Container) StreamLog() (io.ReadCloser, error)
- type ContainerConfig
- type Network
- type Signal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides means to spawn Docker containers capable of hosting services like the go-opera client.
func NewClient ¶
NewClient creates a new client facilitating the creation of Docker Containers capable of hosting services. Clients successfully created through this function should be Closed() eventually.
func (*Client) CreateBridgeNetwork ¶
CreateBridgeNetwork creates a new Docker bridge network.
func (*Client) Start ¶
func (c *Client) Start(config *ContainerConfig) (*Container, error)
Start creates and runs one Container. The provided configuration allows to configure the Docker image to run inside the container -- and thus the services to be offered -- and port-forwarding specifications to make those services reachable from outside the Docker container (e.g. by the application running this code).
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container represents a Docker Container, typically used for running a Fantom network Node, thus an instance of the go-opera client. *Container implements the driver.Host interface.
func (*Container) Cleanup ¶
Cleanup stops the container (unless it is already stopped) and frees any resources associated to it. After the operation, the Container is to be considered invalid.
func (*Container) Exec ¶
Exec executes a command in the container. This method is blocking until the command has finished. The output of the command is returned as a string (stdout + stderr). The command is required to be tokenized and interpreted in shell's exec form.
func (*Container) GetAddressForService ¶
func (c *Container) GetAddressForService(service *network.ServiceDescription) *network.AddressPort
GetAddressForService retrieves the Address of a service running in this Container and being exported to the Docker's host environment. If there is no such service (e.g., because it was not marked as to be exported during the Start of the Container), nil will be returned.
func (*Container) Hostname ¶
Hostname returns the hostname of the Container. In this case it is the ID of the Docker Container.
func (*Container) IsRunning ¶
IsRunning returns true if the Container has not been stopped yet and is expected to offer its services.
func (*Container) SaveLogTo ¶
SaveLogTo fetches the log of the container and saves it to the given directory.
func (*Container) SendSignal ¶
SendSignal sends a signal to the container.
type ContainerConfig ¶
type ContainerConfig struct {
ImageName string
ShutdownTimeout *time.Duration
PortForwarding map[network.Port]network.Port // Container Port => Host Port
Environment map[string]string
Entrypoint []string // Entrypoint to run when starting the container. Optional.
Network *Network // Docker network to join, nil to join bridge network
DataDirBinding *string // mount client datadir to this path on host
}
ContainerConfig defines parameters for running Docker Containers.