func defaultMkConn(host string, ah AuthHandler) (*memcached.Client, error) { conn, err := memcached.Connect("tcp", host) if err != nil { return nil, err } if TCPKeepalive == true { conn.SetKeepAliveOptions(time.Duration(TCPKeepaliveInterval) * time.Second) } if EnableMutationToken == true { res, err := conn.EnableMutationToken() if err != nil || res.Status != gomemcached.SUCCESS { logging.Warnf("Unable to enable mutation token %v", err) } } if gah, ok := ah.(GenericMcdAuthHandler); ok { err = gah.AuthenticateMemcachedConn(host, conn) if err != nil { conn.Close() return nil, err } return conn, nil } name, pass, bucket := ah.GetCredentials() if name != "default" { _, err = conn.Auth(name, pass) if err != nil { conn.Close() return nil, err } // Select bucket (Required for cb_auth creds) // Required when doing auth with _admin credentials if bucket != "" && bucket != name { _, err = conn.SelectBucket(bucket) if err != nil { conn.Close() return nil, err } } } return conn, nil }
func bucketFinalizer(b *Bucket) { if b.connPools != nil { logging.Warnf("Finalizing a bucket with active connections.") } }