Track Workers by uuid for Reconnection

This commit is contained in:
Samuel Lorch 2024-04-26 22:41:55 +02:00
parent 9ac9ed8fe2
commit d0f220fd0a
6 changed files with 64 additions and 9 deletions

View file

@ -10,15 +10,15 @@ import (
"git.lastassault.de/speatzle/morffix/config"
"git.lastassault.de/speatzle/morffix/constants"
"github.com/google/uuid"
"nhooyr.io/websocket"
)
func Start(conf config.Config) {
ctx := context.Background()
headers := http.Header{}
uuid := uuid.New()
slog.InfoContext(ctx, "Connecting to Server...", "Address", conf.Worker.Address)
headers.Add(constants.SHARED_SECRET_HEADER, conf.SharedSecret)
headers.Add(constants.UUID_HEADER, uuid.String())
c, res, err := websocket.Dial(ctx, conf.Worker.Address, &websocket.DialOptions{
HTTPHeader: headers,
})