Documentation
¶
Overview ¶
Package host provides to deploy node.
Index ¶
- Variables
- func AvailablePort(network string, exclude []string) (string, error)
- func ContainerInspect(ctx context.Context, client *dockerClient.Client, id string) (dockerTypes.ContainerJSON, error)
- func CustomNodesActionContainerCmd(args []string) []string
- func LoadHostsContextValue(ctx context.Context, l **Hosts) error
- func LoadLogSaverContextValue(ctx context.Context, l **LogSaver) error
- func LoadLogWatcherContextValue(ctx context.Context, l **LogWatcher) error
- func LoadMongodbContextValue(ctx context.Context, l **Mongodb) error
- func MongodbContainerName() string
- func NodeCustomContainerName(alias string) string
- func NodeInitContainerName(alias string) string
- func NodeRunContainerName(alias string) string
- func PullImage(client *dockerClient.Client, image string, update bool) error
- func PullImages(client *dockerClient.Client, images []string, update bool) error
- func ReadContainerLogs(ctx context.Context, client *dockerClient.Client, id string, ...) error
- func RunWaitGroup(n int, callback func(int) error) error
- func TraverseContainers(ctx context.Context, client *dockerClient.Client, ...) error
- type Action
- type Condition
- type ContestLogEntry
- type Host
- type Hosts
- func (hs *Hosts) AddHost(h Host) error
- func (hs *Hosts) Close() error
- func (hs *Hosts) LenHosts() int
- func (hs *Hosts) LenNodes() int
- func (hs *Hosts) NodeExists(alias string) bool
- func (hs *Hosts) TraverseHosts(callback func(h Host) (bool, error)) error
- func (hs *Hosts) TraverseNodes(callback func(node *Node) (bool, error)) error
- type LocalHost
- func (ho *LocalHost) AvailablePort(_, network string) (string, error)
- func (ho *LocalHost) BaseDir() string
- func (ho *LocalHost) Clean(ctx context.Context, dryrun, force bool) error
- func (ho *LocalHost) Close(ctx context.Context) error
- func (ho *LocalHost) Connect() error
- func (ho *LocalHost) DockerClient() *dockerClient.Client
- func (ho *LocalHost) Host() string
- func (ho *LocalHost) MongodbContainerID() string
- func (ho *LocalHost) MongodbURI() string
- func (ho *LocalHost) Nodes() map[string]*Node
- func (ho *LocalHost) Prepare(common string, vars *config.Vars) (map[string]interface{}, error)
- func (*LocalHost) ShellExec(ctx context.Context, name string, args []string) (io.ReadCloser, io.ReadCloser, error)
- type LogEntry
- type LogEntryBSON
- type LogSaver
- type LogWatcher
- type Mongodb
- func (mg *Mongodb) AddLogEntries(ctx context.Context, entries []LogEntry) error
- func (mg *Mongodb) Close(ctx context.Context) error
- func (mg *Mongodb) Connect(ctx context.Context) error
- func (mg *Mongodb) Find(ctx context.Context, col string, query bson.M) (map[string]interface{}, bool, error)
- func (mg *Mongodb) Initialize(ctx context.Context) error
- type Node
- func (no *Node) Alias() string
- func (no *Node) ConfigData() []byte
- func (no *Node) ConfigFile() string
- func (no *Node) ConfigMap() map[string]interface{}
- func (no *Node) Host() Host
- func (no *Node) LogFile() string
- func (no *Node) PortMap() nat.PortMap
- func (no *Node) Prepare(commonDesign, design string, vars *config.Vars) (map[string]interface{}, error)
- type NodeExistedMsg
- type NodeLogEntry
- type NodeStderrError
- type NullAction
- type Sequence
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ContainerLabel = "mitum-contest" ContainerLabelMongodb = "mongodb" ContainerLabelNode = "node" ContainerLabelNodeAlias = ContainerLabel + "-node" ContainerLabelNodeType = ContainerLabel + "-type" ContainerLabelNodeInitType = "init" ContainerLabelNodeRunType = "run" DefaultNodeImage = "debian:testing-slim" DefaultMongodbImage = "mongo" )
View Source
var ( ContextValueHosts util.ContextKey = "hosts" ContextValueMongodb util.ContextKey = "mongodb" ContextValueLogSaver util.ContextKey = "log_saver" ContextValueLogWatcher util.ContextKey = "log_watcher" )
View Source
var ContainerLogIgnoreError = util.NewError("failed to read container logs; ignored")
View Source
var ContestLogName = "contest"
View Source
var DefaultContainerCmdNodeInit = []string{
"/runner", "node", "init",
"--log", "log",
"--log-level", "debug",
"--log-format", "json",
"/config.yml",
}
View Source
var DefaultContainerCmdNodeRun = []string{
"/runner", "node", "run",
"--log", "log",
"--log-level", "debug",
"--log-format", "json",
"/config.yml",
}
Functions ¶
func ContainerInspect ¶
func ContainerInspect(ctx context.Context, client *dockerClient.Client, id string) (dockerTypes.ContainerJSON, error)
func LoadLogWatcherContextValue ¶
func LoadLogWatcherContextValue(ctx context.Context, l **LogWatcher) error
func MongodbContainerName ¶
func MongodbContainerName() string
func NodeCustomContainerName ¶
func NodeInitContainerName ¶
func NodeRunContainerName ¶
func PullImages ¶
func PullImages(client *dockerClient.Client, images []string, update bool) error
func ReadContainerLogs ¶
func ReadContainerLogs( ctx context.Context, client *dockerClient.Client, id string, options dockerTypes.ContainerLogsOptions, callback func(uint8, []byte), ) error
func TraverseContainers ¶
func TraverseContainers( ctx context.Context, client *dockerClient.Client, callback func(dockerTypes.Container, ) (bool, error)) error
Types ¶
type ContestLogEntry ¶
type ContestLogEntry struct {
// contains filtered or unexported fields
}
func NewContestLogEntry ¶
func NewContestLogEntry(msg []byte, isError bool) ContestLogEntry
func (ContestLogEntry) IsError ¶
func (ls ContestLogEntry) IsError() bool
func (ContestLogEntry) Map ¶
func (ls ContestLogEntry) Map() (map[string]interface{}, error)
func (ContestLogEntry) Msg ¶
func (ls ContestLogEntry) Msg() []byte
type Host ¶
type Host interface { Host() string DockerClient() *dockerClient.Client BaseDir() string Connect() error Close(context.Context) error Clean(context.Context, bool, bool) error Prepare(string, *config.Vars) (map[string]interface{}, error) AvailablePort(string, string) (string, error) Nodes() map[string]*Node MongodbContainerID() string MongodbURI() string ShellExec(context.Context, string, []string) (io.ReadCloser, io.ReadCloser, error) }
type LocalHost ¶
func NewLocalHost ¶
func (*LocalHost) AvailablePort ¶
func (*LocalHost) Clean ¶
Clean cleans the stopped containers. If the containers are still running, returns error.
func (*LocalHost) DockerClient ¶
func (ho *LocalHost) DockerClient() *dockerClient.Client
func (*LocalHost) MongodbContainerID ¶
func (*LocalHost) MongodbURI ¶
type LogEntryBSON ¶
type LogEntryBSON struct {
// contains filtered or unexported fields
}
func NewLogEntryBSON ¶
func NewLogEntryBSON(l LogEntry) LogEntryBSON
func (LogEntryBSON) MarshalBSON ¶
func (lo LogEntryBSON) MarshalBSON() ([]byte, error)
type LogSaver ¶
type LogSaver struct { *logging.Logging *util.ContextDaemon // contains filtered or unexported fields }
func NewLogSaver ¶
func (*LogSaver) LogEntryChan ¶
type LogWatcher ¶
type LogWatcher struct { sync.RWMutex *logging.Logging *util.ContextDaemon // contains filtered or unexported fields }
func NewLogWatcher ¶
func (*LogWatcher) Current ¶
func (lw *LogWatcher) Current() (*Sequence, bool)
func (*LogWatcher) Stop ¶
func (lw *LogWatcher) Stop() error
type Mongodb ¶
type Mongodb struct {
// contains filtered or unexported fields
}
func NewMongodb ¶
func NewMongodb(cs connstring.ConnString) *Mongodb
func NewMongodbFromString ¶
func (*Mongodb) AddLogEntries ¶
type NodeExistedMsg ¶
type NodeExistedMsg struct { StatusCode int64 `json:"status_code"` Msg string `json:"m"` Err error `json:"error"` }
func (NodeExistedMsg) MarshalJSON ¶
func (msg NodeExistedMsg) MarshalJSON() ([]byte, error)
type NodeLogEntry ¶
type NodeLogEntry struct {
// contains filtered or unexported fields
}
func NewNodeLogEntry ¶
func NewNodeLogEntry(node string, msg []byte, isError bool) (NodeLogEntry, error)
func NewNodeLogEntryWithInterface ¶
func NewNodeLogEntryWithInterface(node string, i interface{}, isError bool) (NodeLogEntry, error)
func (NodeLogEntry) IsError ¶
func (ls NodeLogEntry) IsError() bool
func (NodeLogEntry) Map ¶
func (ls NodeLogEntry) Map() (map[string]interface{}, error)
func (NodeLogEntry) Msg ¶
func (ls NodeLogEntry) Msg() []byte
func (NodeLogEntry) Node ¶
func (ls NodeLogEntry) Node() string
type NodeStderrError ¶
func NewNodeStderrError ¶
func NewNodeStderrError(node string, b []byte) NodeStderrError
func (NodeStderrError) Error ¶
func (e NodeStderrError) Error() string
func (NodeStderrError) String ¶
func (e NodeStderrError) String() string
type Sequence ¶
type Sequence struct {
// contains filtered or unexported fields
}
func NewSequence ¶
func (*Sequence) Register ¶
func (sq *Sequence) Register() config.DesignRegister
func (*Sequence) SetRegister ¶
Click to show internal directories.
Click to hide internal directories.