go-zookeeper / zk

Native ZooKeeper client for Go
BSD 3-Clause "New" or "Revised" License
512 stars 130 forks source link

support krb5 auth and level log #75

Closed zhuliquan closed 2 years ago

zhuliquan commented 2 years ago

support krb5 and level log

usage

package main

import (
      github.com/go-zookeeper/zk
      log "github.com/sirupsen/logrus"
) 

func main() {

    log.SetLevel(log.DebugLevel)
    zkConn, _, err := zk.Connect([]string{"localhost"}, time.Second*10, zk.WithSASL(
        &zk.SASLConfig{
            SASLType: zk.KERBEROS,
            KRBConfig: &zk.KRBConfig{
                KeytabPath:  "./test.keytab",
                KrbCfgPath:  "./test.config",
                Realm:       "test.com",
                Username:    "test",
                ServiceName: "zookeeper",
            },
        },
    ))
    if err != nil {
        panic(err)
    }
    if res, _, err := zkConn.Get("/test/test_krb5"); err != nil {
        t.Logf("get %s from zookeeper", res)
    } else {
        panic(err)
    }
}