🎉 Initial commit of Ring
This commit is contained in:
@@ -2,13 +2,13 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hash/fnv"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"git.solsynth.dev/goatworks/turbine/pkg/shared/hash"
|
||||
"git.solsynth.dev/goatworks/turbine/pkg/shared/registrar"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
@@ -17,12 +17,6 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func hash(s string) uint32 {
|
||||
h := fnv.New32a()
|
||||
h.Write([]byte(s))
|
||||
return h.Sum32()
|
||||
}
|
||||
|
||||
func init() {
|
||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
|
||||
}
|
||||
@@ -69,7 +63,7 @@ func main() {
|
||||
}
|
||||
|
||||
serviceName := "config"
|
||||
instanceID := fmt.Sprint(hash(fmt.Sprintf("%s-%s-%d", serviceName, host, port)))[:8]
|
||||
instanceID := fmt.Sprint(hash.Hash(fmt.Sprintf("%s-%s-%d", serviceName, host, port)))[:8]
|
||||
|
||||
err = serviceReg.Register(serviceName, "http", instanceID, host, port, 30)
|
||||
if err != nil {
|
||||
@@ -83,7 +77,7 @@ func main() {
|
||||
})
|
||||
|
||||
// This is the main endpoint that serves the configuration as JSON.
|
||||
app.Get("/", func(c fiber.Ctx) error {
|
||||
app.Get("/api/", func(c fiber.Ctx) error {
|
||||
log.Info().Msg("Serving shared configuration as JSON")
|
||||
|
||||
// Use a new Viper instance to read the shared config
|
||||
|
||||
Reference in New Issue
Block a user