Golang with ScyllaDB
We all know how powerful Golang and ScyllaDB are. Golang with Scylla is really powerful.
ScyllaDB benchmarking: https://benchant.com/blog/mongodb-vs-scylladb-benchmark
I will not go into details of setting up golang with VSCode and setting up scyllaDB cluster.
PreRequisites:
- GoLang with VSCode
- ScyllaDB Cluster(Either local or create one free cluster. on https://www.scylladb.com/)
- (Optional) If created on scylladb.com donwload the certificate to connect
Once the cluster is created on scyllaDB or localhost.
head to cqlsh. Run below commands.
> CREATE KEYSPACE catalog WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy','DC1' : 3};
> use catalog;
> CREATE TABLE mutant_data ( first_name text, last_name text, address text, picture_location text, PRIMARY KEY((first_name, last_name)));
> insert into mutant_data ("first_name","last_name","address","picture_location") VALUES ('Bob','Loblaw','1313 Mockingbird Lane', 'http://www.facebook.com/bobloblaw'); insert into mutant_data ("first_name","last_name","address","picture_location") VALUES ('Bob','Zemuda','1202 Coffman Lane', 'http://www.facebook.com/bzemuda'); insert into mutant_data ("first_name","last_name","address","picture_location") VALUES ('Jim','Jeffries','1211 Hollywood Lane', 'http://www.facebook.com/jeffries');
Go ahead and pull the code from github
under db folder conn.yaml, update the certificate downloaded from scylla cluster created on scylladb.com and the path.
Step1: head to the terminal in vscode
> go get .
Step2: Run the main.go program
> go run main.go
Step3: localhost:8080 in your favourite browser.
Bingo! you just wrote your golang program with scyllaDB as database.
Now go ahead and try CRUD operations.
optional:
Dockerize the project
docker build -t mygoscyllapp .
Now push the image to your favourite registry and run it on k8s.
Leave a clap if you liked it or please share your observations or improvisations in the comments below.
Happy Coding :)