gocql | Package gocql implements a fast and robust Cassandra client
kandi X-RAY | gocql Summary
kandi X-RAY | gocql Summary
[Join the chat at [GoDoc] Package gocql implements a fast and robust Cassandra client for the Go programming language. Project Website: API documentation: Discussions:
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of gocql
gocql Key Features
gocql Examples and Code Snippets
Community Discussions
Trending Discussions on gocql
QUESTION
I am trying to setup a cassandra DB and connect to it with a golang app.
this is my docker-compose
ANSWER
Answered 2022-Mar-08 at 17:28Each container has its own localhost (127.0.0.1
) address - you need to connect to IP address of your machine (if you use bridge
), or maybe better to connect by the name (cassandra
)
QUESTION
i have a database field that is set to decimal, while in my Go project i am having problem choosing which datatype can be use. each time i send a create reuquest to my code, i get a "cannot marshal 'decimal' into #golang datatype#
this my database schema
...ANSWER
Answered 2022-Feb-15 at 12:13If you look into documentation for Gocql package, then you will see that the decimal
is mapped to the Go's infDec
data type (see its doc) so you need to use it instead of Float64
.
QUESTION
I have a Go service that needs to connect Keyspaces on AWS. My pod has a role and AWS_SECRET_ACCESS_KEY
, AWS_ACCESS_KEY_ID
and AWS_SESSION_TOKEN
env vars.
I want to use aws SDK v2. What credential provider should I use? ec2rolecreds
or other one (maybe stscreds
)?
I tried to implement example from here. But I get an error
...ANSWER
Answered 2022-Feb-08 at 00:26no EC2 IMDS role found, operation error ec2imds: GetMetadata, exceeded maximum number of attempts, 3, request send failed, Get \"http://169.254.169.254/latest/meta-data/iam/security-credentials/\": dial tcp 169.254.169.254:80: connect: host is down
Your snippet of code is attempting to use the EC2 instance meta-data service to read an IAM role to use. For that to work, you need to be able to communicate with it, and the role must be attached to the instance.
Is your Go service running on an EC2 instance? If not, that would explain your error. If it is, make sure the process or container has appropriate network access (eg: network namespace) to communicate with 169.254.169.254.
QUESTION
yugabyte cluster has 2 regions, 3 AZs, 6 node architecture.
4 nodes in central region, 2 nodes in east region
...ANSWER
Answered 2022-Jan-27 at 09:41How can a client driver know, which tablet server to send the request?
The driver periodically queries this table:
QUESTION
[Question posted by a user on YugabyteDB Community Slack]
I'm currently trying out the Yugabyte k8s operator deployment with my app, which is using the Go Yugabyte cql driver. I have the app working, connecting, and querying seemingly fine, using a single dns yb-tservers.my-namespace.svc.cluster.local
that resolves to 3 ip addresses. My app is in a different k8s namespace on the same cluster. However, the app is logging the following from the client driver:
ANSWER
Answered 2021-Oct-01 at 17:29Specify the tserver addresses with their headless service dns names like below and it should work:
QUESTION
Is there a way to convert a Go type like []string
to a set
using gocql? Or do I need to make my own mapper for that? I know gocql is able to convert a Go value to a Scylla/Cassandra value with their marshaller but I want to get the type, not the data value (gocql returns a byte array).
Thank you!
...ANSWER
Answered 2021-Sep-30 at 22:42I found that gocqltable does the trick for what I want.
gocqltable has a mapper built in to convert Go types to Cassandra types, so I copied the type.go
file into my project (since the original is unexported) and used it as specified in table.go
.
You can find the stringTypeOf
method I used here, and the usage of it here.
QUESTION
I have a cassandra debug.log. It has a lot of SELECT * queries that are not fired by any application. Applications request specific fields in SELECT queries, also the queries seem to have a LIMIT 5000
clause which I am pretty sure is not there in any application. Are these queries fired by cassandra internally? The debug log is filled with such queries. The application uses gocql driver to connect to cassandra.
ANSWER
Answered 2021-Jan-15 at 02:22All those queries are coming from your application. They are not done by Cassandra.
Those messages from MonitoringTask
are logged by a feature in Cassandra 3.10+ called slow query logging (CASSANDRA-12403). I've previously explained it in this post -- https://community.datastax.com/questions/7835/.
The slow query logging aggregates queries which took longer than slow_query_log_timeout_in_ms
(default is 500ms) into groups of 5-second "windows". As part of the aggregation, columns are not enumerated in the logging and are instead replaced with an asterisk (*
) so they can be easily grouped.
In addition, drivers have paging enabled. When your application does not set a page size, the drivers default to a page size of 5000 (LIMIT 5000
). This is the limit which gets logged in the slow query message you posted. Cheers!
QUESTION
I'm trying to build a simplified example of an app which uses username-and-password authentication to connect to Cassandra. To this end, I've adapted the docker-compose.yml
from https://hub.docker.com/r/bitnami/cassandra/ as follows:
ANSWER
Answered 2020-Nov-04 at 18:00Cassandra takes a few seconds to startup and begin accepting connections; backend
is attempting to connect before it is ready. Your configuration works OK (for me) if you start up backend
after a small delay (using docker-compose start backend
). Modifying backend
to retry the connection works reliably for me i.e.
QUESTION
Cassandra table and UDT
...ANSWER
Answered 2020-Oct-06 at 10:59Try defining your struct like this (use cql
instead of json
in your struct definition)
QUESTION
How might you force a Cassandra error that triggers a retry policy?
According to the DataStax, the following errors trigger a retry policy:
- Read and write timeouts.
- When the coordinator determines there are not enough replicas to satisfy a request.
Edit: The driver I'm using is called gocql
...ANSWER
Answered 2020-Jul-21 at 13:18Toggle the network connection of a node off, and it will appear momentarily down. Any request that needed that node to satisfy the consistency level, or if that node was the co-ordinator of the query will need to retry.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gocql
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page