Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
/ url-shortener Public archive

URL Shortener using Key Generation Service (KGS)

Notifications You must be signed in to change notification settings

txya900619/url-shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

url-shorterner

URL Shortener using Key Generation Service (KGS)

TODO

  • add cronjob to delete expired short url
  • better logging
  • repository tests
  • e2e tests
  • cache when not found
  • Dockerfile
  • docker-compose.yml
  • CI/CD
  • k8s config (maybe in other repo)

Getting started

docker-compose

  1. download docker-compose.yml
wget https://raw.githubusercontent.com/txya900619/url-shortener/main/deployments/docker-compose.yml
  1. docker-compose up
docker-compose up

manual

  1. Install gowatch
go install github.com/silenceper/gowatch@latest
  1. Install generate dependencies
go install github.com/google/wire/cmd/wire@latest \
&& go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest \
&& go install go install google.golang.org/protobuf/cmd/protoc-gen-go@latest \
&& go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
  1. Generate needed files
go generate ./...
  1. Start PostgreSQL
docker run --name postgres-docker -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=123456 -d postgres
  1. Start Redis
docker run --name redis-docker -p 6379:6379 -d redis redis-server --requirepass "abc123"
  1. Start Cassandra
docker run --name cassandra-docker -p 9042:9042 bitnami/cassandra:latest
  1. Start kgs (if you want to use in production, change KEY_LENGTH to 6 or more)
cd cmd/kgs \
&& gowatch
  1. Start shorturl server
cd cmd/shorturl \
&& gowatch

How to use

See openapi doc

Why use these DBMS

  • PostgreSQL (TODO)
  • Redis (TODO)
  • Cassandra (TODO)

About

URL Shortener using Key Generation Service (KGS)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published