Documentation
¶
Index ¶
- Constants
- Variables
- func AddHost(h *txeh.Hosts, address, host string) error
- func AddHosts(h *txeh.Hosts, addresses, hosts []string) error
- func ComparePassword(hashedPwd string, plainPwd string) bool
- func EnvBoolVar(value *bool, key string)
- func EnvIntVar(value *int, key string)
- func EnvStringVar(value *string, key string)
- func GetWorkDirectory() string
- func HashPassword(pwd string) (string, error)
- func NewHosts(readFile, writeFile string) (*txeh.Hosts, error)
- func RemoveHost(h *txeh.Hosts, host string) error
- func RemoveHosts(h *txeh.Hosts, hosts []string) error
- func SFTPConnect(user, password, host string, port int) (*sftp.Client, error)
- func SFTPDownload(sftpClient *sftp.Client, remoteFilePath, localDir string) error
- func SFTPUpload(sftpClient *sftp.Client, localFilePath, remoteDir string) error
- func SSHConnect(user, password, host string, port int) (*ssh.Client, error)
- func SSHRun(client *ssh.Client, shell string) (result string, err error)
- func Save(h *txeh.Hosts) error
- func ScpDownloadFiles(files []string, path, user, password, ip string) error
- func ScpFiles(files []string, path, user, password, ip string) error
- func VerifyPassword(pwd string) error
- type CustomClaims
- type JWT
- type WorkerPool
Constants ¶
View Source
const ( StateRunning uint32 = 0 StateStopped uint32 = 1 )
Variables ¶
View Source
var ( DefaultUserName = "ckman" DefaultSigningKey = "change me" TokenExpireTime = 3600 )
View Source
var ( // ErrorStopped when stopped ErrorStopped = errors.New("WorkerPool already stopped") )
Functions ¶
func ComparePassword ¶
func EnvBoolVar ¶
func EnvStringVar ¶
func GetWorkDirectory ¶
func GetWorkDirectory() string
func HashPassword ¶
func SFTPDownload ¶
func ScpDownloadFiles ¶
func VerifyPassword ¶
Types ¶
type CustomClaims ¶
type CustomClaims struct {
jwt.StandardClaims
Name string `json:"name"`
ClientIP string `json:"clientIp"`
}
type JWT ¶
type JWT struct {
SigningKey []byte
}
func (*JWT) CreateToken ¶
func (j *JWT) CreateToken(claims CustomClaims) (string, error)
func (*JWT) ParserToken ¶
func (j *JWT) ParserToken(tokenString string) (*CustomClaims, int)
type WorkerPool ¶
WorkerPool is a blocked worker pool inspired by https://github.com/gammazero/workerpool/
func NewWorkerPool ¶
func NewWorkerPool(maxWorkers int, queueSize int) *WorkerPool
New creates and starts a pool of worker goroutines.
func (*WorkerPool) Pending ¶
func (w *WorkerPool) Pending() uint64
func (*WorkerPool) Resize ¶
func (w *WorkerPool) Resize(maxWorkers int)
Resize ensures worker number match the expected one.
func (*WorkerPool) Restart ¶
func (w *WorkerPool) Restart()
func (*WorkerPool) StopWait ¶
func (w *WorkerPool) StopWait()
StopWait stops the worker pool and waits for all queued tasks tasks to complete.
func (*WorkerPool) Submit ¶
func (w *WorkerPool) Submit(fn func()) (err error)
Submit enqueues a function for a worker to execute. Submit will block regardless if there is no free workers.
Click to show internal directories.
Click to hide internal directories.