34 lines
534 B
Go
34 lines
534 B
Go
package zookeeper
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"git.selly.red/Selly-Modules/logger"
|
|
"github.com/samuel/go-zookeeper/zk"
|
|
)
|
|
|
|
var zkClient *zk.Conn
|
|
|
|
// Connect ...
|
|
func Connect(uri string) error {
|
|
c, _, err := zk.Connect([]string{uri}, time.Second*30)
|
|
if err != nil {
|
|
logger.Error("connect", logger.LogData{
|
|
Source: "zookeeper.Connect",
|
|
Message: err.Error(),
|
|
Data: logger.Map{
|
|
"uri": uri,
|
|
},
|
|
})
|
|
return err
|
|
}
|
|
|
|
fmt.Printf("⚡️[zookeeper]: connected to %s \n", uri)
|
|
|
|
// Set client
|
|
zkClient = c
|
|
|
|
return nil
|
|
}
|