Sync shared snapshot from b012d58

This commit is contained in:
Gabriel20xx committed 2026-09-16 10:54:57 +02:00
1 parent eb67f251d8
commit dc04ac4360
1 file changed
+14 -3
+14 -3
View File
@@ -1,5 +1,5 @@
// Package coreconfig lets any service in this workspace receive AuthGuard's and CarrierNode's
// current base URL(s) pushed from ProjectConfigurator, instead of each service hardcoding them in
// Package coreconfig lets any service in this workspace receive AuthGuard's, CarrierNode's, and
// ProjectConfigurator's current base URL(s) pushed from ProjectConfigurator, instead of each service hardcoding them in
// its own env vars. ProjectConfigurator's Projects workspace is the operator-facing source of
// truth for both (its authguard_url/carriernode_url(_N) settings); it pushes a fresh copy to every
// project it has registered whenever either changes, and again on a periodic tick, so a service
@@ -16,9 +16,14 @@ import (
"sync"
)
// Info is AuthGuard's and CarrierNode's current base URL(s), as pushed by ProjectConfigurator.
// Info is AuthGuard's, CarrierNode's, and ProjectConfigurator's current base URL(s), as pushed by
// ProjectConfigurator.
type Info struct {
AuthGuardURL string `json:"authGuardUrl"`
// ProjectConfiguratorURL is the ProjectConfigurator instance that owns the current workspace
// configuration. Consumers with independent databases can use it to read settings such as the
// configured mount mappings.
ProjectConfiguratorURL string `json:"projectConfiguratorUrl"`
// CarrierNodeURL is the primary CarrierNode instance's URL (CarrierNodeURLs[0], if any) - kept
// for the services that only ever talk to one CarrierNode instance via
@@ -58,6 +63,9 @@ func (s *Store) Get() Info {
// authclient.Client's SetBaseURL, or (via OnUpdate) to keep one continuously up to date.
func (s *Store) AuthGuardURL() string { return s.Get().AuthGuardURL }
// ProjectConfiguratorURL is a convenience accessor for Get().ProjectConfiguratorURL.
func (s *Store) ProjectConfiguratorURL() string { return s.Get().ProjectConfiguratorURL }
// CarrierNodeURL is a convenience accessor for Get().CarrierNodeURL - the natural closure to wire
// as a single-instance carriernodeclient.Client's BaseURL: carriernodeclient.New(secret, func(ctx
// context.Context) string { return store.CarrierNodeURL() }).
@@ -87,6 +95,9 @@ func (s *Store) Set(next Info) {
if url := strings.TrimSpace(next.AuthGuardURL); url != "" {
s.info.AuthGuardURL = url
}
if url := strings.TrimRight(strings.TrimSpace(next.ProjectConfiguratorURL), "/"); url != "" {
s.info.ProjectConfiguratorURL = url
}
if len(next.CarrierNodeURLs) > 0 {
s.info.CarrierNodeURLs = next.CarrierNodeURLs
s.info.CarrierNodeURL = next.CarrierNodeURLs[0]