Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 963 Bytes

File metadata and controls

33 lines (24 loc) · 963 Bytes

cassandra

Cassandra/GoCQL utilities.

LoggingConnectObserver

A ConnectObserver implementation for GoCQL that uses servicelib-golang/logger to log new connections. Successful connections are logged at DEBUG, and failures at ERROR.

package main

import (
    "os"

    "gerrit.wikimedia.org/r/mediawiki/services/servicelib-golang/cassandra"
    log "gerrit.wikimedia.org/r/mediawiki/services/servicelib-golang/logger"
    "github.com/gocql/gocql"
)

func main() {
    logger _ := log.NewLogger(os.Stdout, "sessionstore", "INFO")
    cluster := gocql.NewCluster("192.168.1.1", "192.168.1.2", "192.168.1.3")
    cluster.ConnectObserver = &LoggingConnectObserver{Logger: logger}

    session, err := cluster.CreateSession()
    //...
}