Documentation ¶
Index ¶
- Constants
- Variables
- func AddHost(h *txeh.Hosts, address, host string) error
- func AddHosts(h *txeh.Hosts, addresses, hosts []string) error
- func CloseConns(hosts []string)
- func ComparePassword(hashedPwd string, plainPwd string) bool
- func ConnectClickHouse(host string, port int, database string, user string, password string) (*sql.DB, error)
- func ConvertDisk(size uint64) string
- func Decimal(value float64) float64
- func EnvBoolVar(value *bool, key string)
- func EnvIntVar(value *int, key string)
- func EnvStringVar(value *string, key string)
- func GetConnection(host string) *sql.DB
- func GetMergeTreeTables(engine string, db *sql.DB) ([]string, map[string][]string, error)
- func GetShardAvaliableHosts(conf *model.CKManClickHouseConfig) ([]string, error)
- func GetWorkDirectory() string
- func HashPassword(pwd string) (string, error)
- func MaxInt(x, y int) int
- func NewHosts(readFile, writeFile string) (*txeh.Hosts, error)
- func RemoteExecute(user, password, host string, port int, cmd string) (string, 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, localFilePath string) error
- func SFTPUpload(sftpClient *sftp.Client, localFilePath, remoteFilePath 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 ScpDownloadFile(remoteFile, localFile, user, password, ip string, port int) error
- func ScpDownloadFiles(files []string, localPath, user, password, ip string, port int) error
- func ScpFile(localFile, remoteFile, user, password, ip string, port int) error
- func ScpFiles(files []string, remotePath, user, password, ip string, port int) error
- func SetConnOptions(conn *sql.DB)
- func VerifyPassword(pwd string) error
- type Connection
- type CustomClaims
- type JWT
- type RSAEncryption
- func (encry RSAEncryption) Decode(encode []byte, publicKey string) ([]byte, error)
- func (encry RSAEncryption) Encode(decode []byte, privateKey string) ([]byte, error)
- func (encry RSAEncryption) GenPrivateKey(privateKey string) []byte
- func (encry RSAEncryption) GenPublicKey(publicKey string) []byte
- func (encry RSAEncryption) GetPrivateKey(privateKey string) (*rsa.PrivateKey, error)
- func (encry RSAEncryption) GetPublicKey(publicKey string) (*rsa.PublicKey, error)
- type TempFile
- type UserTokenModel
- type WorkerPool
Constants ¶
View Source
const ( AUTHENTICATION_PUB_KEY_PREFIX = "-----BEGIN RSA Public Key-----\n" AUTHENTICATION_PRI_KEY_PREFIX = "-----BEGIN RSA Private Key-----\n" AUTHENTICATION_PUB_KEY_SUFFIX = "\n-----END RSA Public Key-----" AUTHENTICATION_PRI_KEY_SUFFIX = "\n-----END RSA Private Key-----" )
The token is resolved with fixed public key and private key. The unified portal uses the private key to encrypt the token, and ckman only needs to decrypt it with the public key.
View Source
const ( KB uint64 = 1 << (10 * iota) MB GB TB PB )
View Source
const ( StateRunning uint32 = 0 StateStopped uint32 = 1 )
Variables ¶
View Source
var ( DefaultUserName = "ckman" DefaultSigningKey = "change me" )
View Source
var ( ErrDataToLarge = errors.New("message too long for RSA public key size") ErrDataLen = errors.New("data length error") ErrDataBroken = errors.New("data broken, first byte is not zero") ErrKeyPairDismatch = errors.New("data is not encrypted by the private key") ErrDecryption = errors.New("decryption error") ErrPublicKey = errors.New("get public key error") ErrPrivateKey = errors.New("get private key error") )
View Source
var ConnectPool sync.Map
View Source
var ( // ErrorStopped when stopped ErrorStopped = errors.New("WorkerPool already stopped") )
View Source
var MaxWorkersDefault int = MaxInt(2*runtime.NumCPU(), 10)
Functions ¶
func CloseConns ¶ added in v1.3.4
func CloseConns(hosts []string)
func ComparePassword ¶
func ConnectClickHouse ¶ added in v1.3.0
func ConvertDisk ¶ added in v1.3.6
func EnvBoolVar ¶
func EnvStringVar ¶
func GetConnection ¶ added in v1.3.4
func GetMergeTreeTables ¶ added in v1.3.0
func GetShardAvaliableHosts ¶ added in v1.3.4
func GetShardAvaliableHosts(conf *model.CKManClickHouseConfig) ([]string, error)
func GetWorkDirectory ¶
func GetWorkDirectory() string
func HashPassword ¶
func RemoteExecute ¶ added in v1.3.2
func SFTPDownload ¶
func SFTPUpload ¶
func ScpDownloadFile ¶ added in v1.3.7
func ScpDownloadFiles ¶
func SetConnOptions ¶ added in v1.3.4
func VerifyPassword ¶
Types ¶
type Connection ¶ added in v1.3.4
type Connection struct {
// contains filtered or unexported fields
}
type CustomClaims ¶
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 RSAEncryption ¶ added in v1.2.6
type RSAEncryption struct{}
func (RSAEncryption) Decode ¶ added in v1.2.6
func (encry RSAEncryption) Decode(encode []byte, publicKey string) ([]byte, error)
func (RSAEncryption) Encode ¶ added in v1.2.6
func (encry RSAEncryption) Encode(decode []byte, privateKey string) ([]byte, error)
ckman do not need encode token
func (RSAEncryption) GenPrivateKey ¶ added in v1.2.6
func (encry RSAEncryption) GenPrivateKey(privateKey string) []byte
func (RSAEncryption) GenPublicKey ¶ added in v1.2.6
func (encry RSAEncryption) GenPublicKey(publicKey string) []byte
func (RSAEncryption) GetPrivateKey ¶ added in v1.2.6
func (encry RSAEncryption) GetPrivateKey(privateKey string) (*rsa.PrivateKey, error)
func (RSAEncryption) GetPublicKey ¶ added in v1.2.6
func (encry RSAEncryption) GetPublicKey(publicKey string) (*rsa.PublicKey, error)
type TempFile ¶ added in v1.3.7
func NewTempFile ¶ added in v1.3.7
type UserTokenModel ¶ added in v1.2.6
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.
func (*WorkerPool) Wait ¶ added in v1.3.2
func (w *WorkerPool) Wait()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.