Skip to content

Commit

Permalink
Merge pull request #3 from BK1031/bk1031/db-table-prefix
Browse files Browse the repository at this point in the history
DB table prefix support
  • Loading branch information
BK1031 authored May 21, 2024
2 parents ee4e8b0 + 1ea56d0 commit e8e0a9d
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 7 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Rincon

<img align="right" width="159px" src="https://github.com/BK1031/Rincon/blob/bk1031/readme/assets/rincon-circle.png?raw=true" alt="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
Binary file added assets/rincon-circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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")
7 changes: 5 additions & 2 deletions model/route.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package model

import "time"
import (
"rincon/config"
"time"
)

type Route struct {
Route string `json:"route" gorm:"primaryKey"`
Expand All @@ -9,7 +12,7 @@ type Route struct {
}

func (Route) TableName() string {
return "route"
return config.DatabaseTablePrefix + "route"
}

type RouteNode struct {
Expand Down
9 changes: 6 additions & 3 deletions model/service.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package model

import "time"
import (
"rincon/config"
"time"
)

type Service struct {
ID int `json:"id" gorm:"primaryKey"`
Expand All @@ -13,7 +16,7 @@ type Service struct {
}

func (Service) TableName() string {
return "service"
return config.DatabaseTablePrefix + "service"
}

type ServiceDependency struct {
Expand All @@ -25,5 +28,5 @@ type ServiceDependency struct {
}

func (ServiceDependency) TableName() string {
return "service_dependency"
return config.DatabaseTablePrefix + "service_dependency"
}
2 changes: 1 addition & 1 deletion service/heartbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit e8e0a9d

Please sign in to comment.