util

package
v3.4.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2018 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StatefulServiceType = "StatefulServiceType"

StatefulServiceType 有状态应用

View Source
var StatelessServiceType = "StatelessServiceType"

StatelessServiceType 无状态应用

Functions

func CheckAndCreateDir

func CheckAndCreateDir(path string) error

CheckAndCreateDir check and create dir

func CmdRunWithTimeout

func CmdRunWithTimeout(cmd *exec.Cmd, timeout time.Duration) (bool, error)

CmdRunWithTimeout exec cmd with timeout

func Deweight

func Deweight(data *[]string)

Deweight 去除数组重复

func Exec

func Exec(ctx context.Context, f func() error, wait time.Duration) error

Exec 上下文执行

func FileExists

func FileExists(filename string) (bool, error)

FileExists check file exist

func GetIDFromKey

func GetIDFromKey(key string) string

GetIDFromKey 从 etcd 的 key 中取 id

func IntermittentExec

func IntermittentExec(ctx context.Context, f func(), t time.Duration)

IntermittentExec 间歇性执行

func LocalIP

func LocalIP() (net.IP, error)

LocalIP 获取本机 ip 获取第一个非 loopback ip

func NewUUID

func NewUUID() string

NewUUID 创建无-的32位uuid

func OpenOrCreateFile

func OpenOrCreateFile(filename string) (*os.File, error)

OpenOrCreateFile open or create file

func ReadHostID

func ReadHostID(filePath string) (string, error)

ReadHostID 读取当前机器ID ID是节点的唯一标识,acp_node将把ID与机器信息的绑定关系维护于etcd中

func SendNoBlocking

func SendNoBlocking(m []byte, ch chan []byte)

SendNoBlocking 无阻塞发送

Types

type SSHClient

type SSHClient struct {
	IP             string
	Port           int
	User           string
	Password       string
	Method         string
	Key            string
	Stdout, Stderr io.Writer
	Cmd            string
}

SSHClient ssh client

func NewSSHClient

func NewSSHClient(ip, user, password, cmd string, port int, stdout, stderr io.Writer) *SSHClient

NewSSHClient new ssh client

func (*SSHClient) Connection

func (server *SSHClient) Connection() error

Connection 执行远程连接

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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