Пример #1
0
func init() {
	kname := "test_ihopeudonthaveakeyspacenamedlikedthis"
	var err error

	cluster := gocql.NewCluster(getTestHosts()...)
	cluster.Consistency = gocql.One
	cluster.Timeout = 10 * time.Second               // Travis' C* is sloooow
	cluster.MaxWaitSchemaAgreement = 2 * time.Minute // travis might be slow
	cluster.RetryPolicy = &gocql.SimpleRetryPolicy{
		NumRetries: 3}
	sess, err := cluster.CreateSession()
	if err != nil {
		panic(err)
	}
	conn := &connection{q: goCQLBackend{session: sess}}
	ns = conn.KeySpace(kname)

	err = conn.DropKeySpace(kname)
	if err != nil {
		panic(err)
	}
	err = conn.CreateKeySpace(kname)
	if err != nil {
		panic(err)
	}
}
Пример #2
0
func newGoCQLBackend(nodeIps []string, username, password string) (QueryExecutor, error) {
	cluster := gocql.NewCluster(nodeIps...)
	cluster.Consistency = gocql.One
	cluster.ProtoVersion = 3
	cluster.Authenticator = gocql.PasswordAuthenticator{
		Username: username,
		Password: password,
	}
	sess, err := cluster.CreateSession()
	if err != nil {
		return nil, err
	}
	return GoCQLSessionToQueryExecutor(sess), nil
}