[Part2] HexArch – Connect GoLang to Cassandra
In this video, I show you how to connect our GoLang project from our tutorial series to our local Cassandra cluster using the gocql driver using the Hexagonal Architecture model. As mentioned in the video, this code will be tagged as v2.0 in GitHub.
Make sure to checkout my previous video on starting this project and how to download and run
Cassandra locally: https://youtu.be/2oVa7JLaO5E
Project name: CandyShop
GitHub Repository: https://github.com/CaiqueCosta/YouTube-Tutorials
Cassandra scripts for creating keyspace:
*********Todo: setup candy_shop_db keyspace in cassandra*********
CREATE KEYSPACE candy_shop_db WITH replication = {‘class’: ‘SimpleStrategy’, ‘replication_factor’ : 1};
CREATE TABLE IF NOT EXISTS candies (
candy_id uuid,
category text,
name text,
price float,
PRIMARY KEY (candy_id, category)
);
INSERT INTO candies (candy_id, category, name, price) VALUES (now(), ‘Chocolate’, ‘KitKat’, 1.99);
INSERT INTO candies (candy_id, category, name, price) VALUES (now(), ‘Sour’, ‘Skittles’, 1.89);
***********************************************************************
Comments are closed.