Giter Site home page Giter Site logo

docs's People

Contributors

aar0np avatar artemchebotko avatar ashhopkins avatar clun avatar dieterrandolph avatar gstachni avatar hadesarchitect avatar hemidactylus avatar jeremya avatar kodrillar avatar melienherrera avatar mendonk avatar msmygit avatar osaeed-ds avatar pieterhumphrey avatar ragsns avatar sonicdmg avatar stinkymatt avatar synedra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

docs's Issues

Stargate gRPC develop page

In the Develop section of Awesome Astra, we currently provide guides to get started with Document API and REST but are missing a guide to get started with gRPC. This is a tracking issue to follow the progress of the gRPC guide.

Update Golang gocql docs

What

Golang documentation for gocql driver is outdated and is not working with Cassandra 4.0+ versions nor latest driver versions.

It would be nice to update the documentation to avoid confusion to newcomers.

How

After a research, I've encountered gocql version 1.20 (and potentially lower versions) had a host peer-related function referencing to system.peers_v2 table which is not existent in Cassandra 4.0+ AFAIK. Thus, driver is not able to create a session.

Updating to gocql 1.2.1 fixed this issue while another issue surfaced (x509: cannot validate certificate for because it doesn't contain any IP SANs).

In order to solve this last issue, just add ServerName field to tls.Config struct referencing to host variable defined previously and used as cluster host.

Example:

package main

import (
	"context"
	"crypto/tls"
	"crypto/x509"
	"fmt"
	"os"
	"path/filepath"
	"time"

	"github.com/gocql/gocql"
)

func main() {
	const (
		port = 29042
	)
	var err error

	hostname := "YOUR_DATABASE_ID-YOUR_REGION.db.astra.datastax.com"
	username := "YOUR_CLIENT_ID" // or set as "token" to use secure token strategy
	password := "YOUR_CLIENT_SECRET" // or secure token

	caPath, _ := filepath.Abs("PATH_TO_SECURE_BUNDLE/ca.crt")
	certPath, _ := filepath.Abs("PATH_TO_SECURE_BUNDLE/cert")
	keyPath, _ := filepath.Abs("PATH_TO_SECURE_BUNDLE/key")

	cluster := gocql.NewCluster(hostname)
	cluster.Port = port
	cluster.ProtoVersion = 4
        // set to true to avoid system.peer table fetch and bypass first error (NOT RECOMMENDED)
	//cluster.DisableInitialHostLookup = true

	cluster.Authenticator = gocql.PasswordAuthenticator{
		Username: username,
		Password: password,
	}

	cert, err := tls.LoadX509KeyPair(certPath, keyPath)
	if err != nil {
		panic(err)
	}
	caCert, err := os.ReadFile(caPath)
	if err != nil {
		panic(err)
	}
	caCertPool := x509.NewCertPool()
	ok := caCertPool.AppendCertsFromPEM(caCert)
	if !ok {
		panic("cannot append cert")
	}
	tlsConfig := &tls.Config{
		Certificates: []tls.Certificate{cert},
		RootCAs:      caCertPool,
                // set to true if ServerName field is not populated (NOT RECOMMENDED)
		//InsecureSkipVerify: true,
		ServerName: "YOUR_DATABASE_ID-YOUR_REGION.db.astra.datastax.com",
	}

	cluster.SslOpts = &gocql.SslOptions{
		Config:                 tlsConfig,
		EnableHostVerification: false,
	}

	session, err := cluster.CreateSession()
	if err != nil {
		panic(err)
	}
	defer session.Close()
	ctx := context.Background()

	var strClusterName string
	err2 := session.Query(`SELECT cluster_name FROM system.local`).WithContext(ctx).Scan(&strClusterName)
	if err2 != nil {
		panic(err2)
	} else {
		fmt.Println("cluster_name:", strClusterName)
	}

	duration := time.Duration(10) * time.Second // Pause for 10 seconds
	time.Sleep(duration)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.