Documentation ¶
Index ¶
- func ApplyTemplate(filePath string, tplStr string, vars map[string]interface{}) error
- func BookPorts(num int, host ...string) ([]int, error)
- func CheckExecutable(names ...string) error
- func CheckListening(ports ...int) bool
- func CombineError(errs ...error) error
- func Exec(workdir string, envs []string, stdin io.Reader, name string, ...) error
- func GetPort() int
- func NewDockerClient() (cl *docker.Client)
- func RegisterService(t ServiceType, f ServiceFactory)
- func RemoveContainer(client *docker.Client, container *docker.Container) error
- func StartContainer(client *docker.Client, options ...ContainerOptionFunc) (c *docker.Container, ipaddr string, err error)
- func WaitPortAvail(port int, timeout time.Duration, host ...string) error
- type ContainerNode
- type ContainerOptionFunc
- type HbaseService
- type Service
- type ServiceDocker
- type ServiceFactory
- type ServiceLauncher
- type ServiceOption
- type ServiceType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyTemplate ¶
ApplyTemplate applies given variables to the "tplStr" and stores to "filePath"
func CheckExecutable ¶
CheckExecutable checks if given names are executables
func CheckListening ¶
CheckListening checks if localhost is listening given ports
func CombineError ¶
CombineError given errors into one err, note that nil error will be ignored
func Exec ¶
Exec runs "name" and "arg" in directory "workdir" with environements "envs" and wait util process finined. It returns error if fail to execute or exit code is not zero.
func NewDockerClient ¶
NewDockerClient create docker client via unix socket
func RegisterService ¶
func RegisterService(t ServiceType, f ServiceFactory)
RegisterService registers a service factory of the given type
func RemoveContainer ¶
RemoveContainer remove the started container
func StartContainer ¶
func StartContainer(client *docker.Client, options ...ContainerOptionFunc) (c *docker.Container, ipaddr string, err error)
StartContainer starts the required container
Types ¶
type ContainerNode ¶
type ContainerOptionFunc ¶
type ContainerOptionFunc func(*docker.CreateContainerOptions) error
ContainerOptionFunc is a function that configures a Client. It is used in createDockerOptions.
func SetCommand ¶
func SetCommand(cmd []string) ContainerOptionFunc
SetCommand set the command for the container
func SetEnv ¶
func SetEnv(env []string) ContainerOptionFunc
SetEnv set the command for the container
func SetExposedPorts ¶
func SetExposedPorts(ports []string) ContainerOptionFunc
TODO:
PortBindings: map[docker.Port][]docker.PortBinding{ "8888/tcp": {{HostIP: "", HostPort: "12345"}}, },
SetExposedPorts accepts format as "1234/tcp", "5678/udp"
func SetImage ¶
func SetImage(image string) ContainerOptionFunc
SetImage set the docker image for the container
type HbaseService ¶
type HbaseService interface { // RunScript runs the hbase script directly RunScript(script string) error // RunScript runs the hbase script file RunScriptFromFile(file string) error }
HbaseService represents hbase service
type Service ¶
type Service interface { // Start launches the service and return its listening port Start() (string, error) // Stop stops the service Stop() error // StartDocker launches the service and return its listening port via docker StartDocker(*docker.Client) (string, error) // Stop stops the service via docker StopDocker(*docker.Client) error }
Service represents a service
type ServiceDocker ¶
type ServiceDocker interface { // Start creates and starts an instance of supported service by the give type. It // returns its listening ip:port and the corresponding stop function. Start(ServiceType, ...ServiceOption) (ipport string, stopFunc func() error, err error) // StopAll stop all created services StopAll() error // Get retruns service, return nil if no service for the given ipport Get(ipport string) interface{} }
ServiceDocker defines an interface to create service via docker
func NewServiceDocker ¶
func NewServiceDocker() ServiceDocker
NewServiceDocker returns an instance of ServiceDocker TODO: with specified docker address
type ServiceLauncher ¶
type ServiceLauncher interface { // Start creates and starts an instance of supported service by the give type. It // returns its listening ip:port and the corresponding stop function. Start(ServiceType, ...ServiceOption) (ipport string, stopFunc func() error, err error) // StopAll stop all created services StopAll() error // Get retruns service, return nil if no service for the given ipport Get(ipport string) interface{} }
ServiceLauncher defines an interface to create service
func NewServiceLauncher ¶
func NewServiceLauncher() ServiceLauncher
NewServiceLauncher returns an instance of ServiceLauncher
type ServiceOption ¶
ServiceOption defines option function to setup service
func RedisAuth ¶
func RedisAuth(password string) ServiceOption
func RedisMemory ¶
func RedisMemory(maxMem string) ServiceOption
func RedisPort ¶
func RedisPort(port int) ServiceOption
type ServiceType ¶
type ServiceType string
ServiceType defines type
const ( ZooKeeper ServiceType = "zookeeper" HBase ServiceType = "hbase" Redis ServiceType = "redis" Etcd ServiceType = "etcd" Gnatsd ServiceType = "gnatsd" Disque ServiceType = "disque" Consul ServiceType = "consul" ElasticSearch ServiceType = "elasticsearch" )
supported service types