Documentation ¶
Index ¶
- Constants
- Variables
- func EnvBoolVar(value *bool, key string)
- func EnvIntVar(value *int, key string)
- func EnvStringVar(value *string, key string)
- func GetIP4Byname(host string) (ips []string, err error)
- func GetNetAddrPort(addr net.Addr) (port int)
- func GetOutboundIP() (ip net.IP, err error)
- func GetShift(s int) (shift uint)
- func GetSourceName(name string) (sourcename string)
- func GetSpareTCPPort(portBegin int) (port int)
- func InitGlobalParsingPool()
- func InitGlobalTimerWheel()
- func InitGlobalWritingPool(maxWorkers int)
- func InitLogger(newLogPaths []string)
- func JksToPem(jksPath, jksPassword string, overwrite bool) (certPemPath, keyPemPath string, err error)
- func NewTLSConfig(caCertFiles, clientCertFile, clientKeyFile string, insecureSkipVerify bool) (*tls.Config, error)
- func Run(appName string, initFunc, jobFunc, cleanupFunc func() error)
- func SetLogLevel(newLogLevel string)
- func StringContains(arr []string, str string) bool
- func WaitForExitSign()
- type WorkerPool
Constants ¶
const ( StateRunning uint32 = 0 StateStopped uint32 = 1 )
Variables ¶
var ( GlobalTimerWheel *goetty.TimeoutWheel //the global timer wheel GlobalParsingPool *WorkerPool //for all tasks' parsing, cpu intensive GlobalWritingPool *WorkerPool //the all tasks' writing ClickHouse, cpu-net balance Logger *zap.Logger )
var ( // ErrStopped when stopped ErrStopped = errors.New("WorkerPool already stopped") )
Functions ¶
func EnvBoolVar ¶ added in v1.5.2
func EnvStringVar ¶ added in v1.5.2
func GetIP4Byname ¶ added in v1.5.2
func GetNetAddrPort ¶ added in v1.5.2
func GetOutboundIP ¶ added in v1.5.2
GetOutboundIP get preferred outbound ip of this machine https://stackoverflow.com/questions/23558425/how-do-i-get-the-local-ip-address-in-go
func GetShift ¶ added in v1.5.2
GetShift returns the smallest `shift` which 1<<shift is no smaller than s
func GetSourceName ¶ added in v1.5.2
GetSourceName returns the field name in message for the given ClickHouse column
func GetSpareTCPPort ¶ added in v1.5.2
GetSpareTCPPort find a spare TCP port
func InitGlobalParsingPool ¶ added in v1.5.2
func InitGlobalParsingPool()
InitGlobalParsingPool initialize GlobalParsingPool
func InitGlobalTimerWheel ¶ added in v1.5.2
func InitGlobalTimerWheel()
InitGlobalTimerWheel initialize the global timer wheel
func InitGlobalWritingPool ¶ added in v1.5.2
func InitGlobalWritingPool(maxWorkers int)
InitGlobalWritingPool initialize GlobalWritingPool
func InitLogger ¶ added in v1.5.2
func InitLogger(newLogPaths []string)
func JksToPem ¶ added in v1.5.2
func JksToPem(jksPath, jksPassword string, overwrite bool) (certPemPath, keyPemPath string, err error)
JksToPem converts JKS to PEM Refers to: https://serverfault.com/questions/715827/how-to-generate-key-and-crt-file-from-jks-file-for-httpd-apache-server
func NewTLSConfig ¶ added in v1.5.2
func NewTLSConfig(caCertFiles, clientCertFile, clientKeyFile string, insecureSkipVerify bool) (*tls.Config, error)
Refers to: https://medium.com/processone/using-tls-authentication-for-your-go-kafka-client-3c5841f2a625 https://github.com/denji/golang-tls https://www.baeldung.com/java-keystore-truststore-difference
func SetLogLevel ¶ added in v1.5.2
func SetLogLevel(newLogLevel string)
func StringContains ¶
StringContains check if contains string in array
func WaitForExitSign ¶ added in v1.5.2
func WaitForExitSign()
Types ¶
type WorkerPool ¶ added in v1.5.2
WorkerPool is a blocked worker pool inspired by https://github.com/gammazero/workerpool/
func NewWorkerPool ¶ added in v1.5.2
func NewWorkerPool(maxWorkers int, queueSize int) *WorkerPool
New creates and starts a pool of worker goroutines.
func (*WorkerPool) Resize ¶ added in v1.5.2
func (w *WorkerPool) Resize(maxWorkers int)
Resize ensures worker number match the expected one.
func (*WorkerPool) Restart ¶ added in v1.5.2
func (w *WorkerPool) Restart()
func (*WorkerPool) StopWait ¶ added in v1.5.2
func (w *WorkerPool) StopWait()
StopWait stops the worker pool and waits for all queued tasks tasks to complete.
func (*WorkerPool) Submit ¶ added in v1.5.2
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.