diff --git a/README.md b/README.md new file mode 100644 index 0000000..44af1e3 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# Rincon + +rincon-logo + +[![Build Status](https://github.com/BK1031/Rincon/actions/workflows/test.yml/badge.svg)](https://github.com/BK1031/Rincon/actions/workflows/test.yml) +[![codecov](https://codecov.io/gh/BK1031/Rincon/graph/badge.svg?token=R4NMABYGOZ)](https://codecov.io/gh/BK1031/Rincon) +[![GoDoc](https://pkg.go.dev/badge/github.com/bk1031/rincon?status.svg)](https://pkg.go.dev/github.com/bk1031/rincon?tab=doc) +[![Docker Pulls](https://img.shields.io/docker/pulls/bk1031/rincon?style=flat-square)](https://hub.docker.com/repository/docker/bk1031/rincon) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) +[![Release](https://img.shields.io/github/release/bk1031/rincon.svg?style=flat-square)](https://github.com/bk1031/rincon/releases) + + +Rincon is a cloud-native service registry written in [Go](https://go.dev/). +It is designed to be fast, lightweight, and highly scalable. +Rincon is also platform-agnostic, and can run in the cloud, a container, or even on bare-metal, +making it perfect for both local development and production environments. + +Rincon makes it easy for services to register themselves and to discover other services. +Built-in support for health checking allows monitoring service status and prevents routing to unavailable services. +External services such as SaaS vendors can also be registered to create a unified discovery interface. + +## Getting Started + +The easiest way to get started with Rincon is to use the official Docker image. +You can pull it from [Docker Hub](https://hub.docker.com/r/bk1031/rincon). + +```bash +$ docker run -d -p 10311:10311 bk1031/rincon:latest +``` + +Alternatively if you have an existing compose file, you can add Rincon as a service. +This way you can also connect Rincon to your existing database. + +```yml + +``` + +## Configuration + +## API Endpoints + + + +## Roadmap \ No newline at end of file diff --git a/assets/rincon-circle.png b/assets/rincon-circle.png new file mode 100644 index 0000000..67318ef Binary files /dev/null and b/assets/rincon-circle.png differ diff --git a/config/config.go b/config/config.go index af88ff6..629aee1 100644 --- a/config/config.go +++ b/config/config.go @@ -4,7 +4,7 @@ import ( "os" ) -var Version = "1.0.3" +var Version = "1.1.0" var Env = os.Getenv("ENV") var Port = os.Getenv("PORT") @@ -39,3 +39,4 @@ var DatabasePort = os.Getenv("DB_PORT") var DatabaseName = os.Getenv("DB_NAME") var DatabaseUser = os.Getenv("DB_USER") var DatabasePassword = os.Getenv("DB_PASSWORD") +var DatabaseTablePrefix = os.Getenv("DB_TABLE_PREFIX") diff --git a/model/route.go b/model/route.go index 782dabc..63da9bf 100644 --- a/model/route.go +++ b/model/route.go @@ -1,6 +1,9 @@ package model -import "time" +import ( + "rincon/config" + "time" +) type Route struct { Route string `json:"route" gorm:"primaryKey"` @@ -9,7 +12,7 @@ type Route struct { } func (Route) TableName() string { - return "route" + return config.DatabaseTablePrefix + "route" } type RouteNode struct { diff --git a/model/service.go b/model/service.go index d04956e..9a33efd 100644 --- a/model/service.go +++ b/model/service.go @@ -1,6 +1,9 @@ package model -import "time" +import ( + "rincon/config" + "time" +) type Service struct { ID int `json:"id" gorm:"primaryKey"` @@ -13,7 +16,7 @@ type Service struct { } func (Service) TableName() string { - return "service" + return config.DatabaseTablePrefix + "service" } type ServiceDependency struct { @@ -25,5 +28,5 @@ type ServiceDependency struct { } func (ServiceDependency) TableName() string { - return "service_dependency" + return config.DatabaseTablePrefix + "service_dependency" } diff --git a/service/heartbeat_test.go b/service/heartbeat_test.go index b596f77..1bc970c 100644 --- a/service/heartbeat_test.go +++ b/service/heartbeat_test.go @@ -15,7 +15,7 @@ func TestInitializeHeartbeat(t *testing.T) { HealthCheck: "http://localhost:10312/health", }) CreateService(model.Service{ - Name: "Lacumbre", + Name: "Montecito", Version: "2.7.9", Endpoint: "http://localhost:10313", HealthCheck: "https://bk1031.dev", diff --git a/utils/config.go b/utils/config.go index 285f028..622bc43 100644 --- a/utils/config.go +++ b/utils/config.go @@ -53,6 +53,10 @@ func VerifyConfig() { config.HeartbeatInterval = "10" SugarLogger.Debugln("HEARTBEAT_INTERVAL is not set, defaulting to 10") } + if config.DatabaseTablePrefix == "" { + config.DatabaseTablePrefix = "rin_" + SugarLogger.Debugln("DB_TABLE_PREFIX is not set, defaulting to rin_") + } } func verifySql() {