Compare commits
2
Commits
eb67f251d8
...
6e70b7e8c1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e70b7e8c1 | ||
|
|
dc04ac4360 |
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
// Package coreconfig lets any service in this workspace receive AuthGuard's and CarrierNode's
|
// Package coreconfig lets any service in this workspace receive AuthGuard's, CarrierNode's,
|
||||||
// current base URL(s) pushed from ProjectConfigurator, instead of each service hardcoding them in
|
// ComfyUI'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
|
// 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
|
// 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
|
// project it has registered whenever either changes, and again on a periodic tick, so a service
|
||||||
@@ -16,9 +17,17 @@ import (
|
|||||||
"sync"
|
"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 {
|
type Info struct {
|
||||||
AuthGuardURL string `json:"authGuardUrl"`
|
AuthGuardURL string `json:"authGuardUrl"`
|
||||||
|
// ComfyUIURL is the configured ComfyUI endpoint for services that use the
|
||||||
|
// generator. It is optional so services that do not use ComfyUI can ignore it.
|
||||||
|
ComfyUIURL string `json:"comfyUiUrl,omitempty"`
|
||||||
|
// 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
|
// 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
|
// for the services that only ever talk to one CarrierNode instance via
|
||||||
@@ -58,6 +67,12 @@ func (s *Store) Get() Info {
|
|||||||
// authclient.Client's SetBaseURL, or (via OnUpdate) to keep one continuously up to date.
|
// authclient.Client's SetBaseURL, or (via OnUpdate) to keep one continuously up to date.
|
||||||
func (s *Store) AuthGuardURL() string { return s.Get().AuthGuardURL }
|
func (s *Store) AuthGuardURL() string { return s.Get().AuthGuardURL }
|
||||||
|
|
||||||
|
// ComfyUIURL is a convenience accessor for Get().ComfyUIURL.
|
||||||
|
func (s *Store) ComfyUIURL() string { return s.Get().ComfyUIURL }
|
||||||
|
|
||||||
|
// 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
|
// 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
|
// as a single-instance carriernodeclient.Client's BaseURL: carriernodeclient.New(secret, func(ctx
|
||||||
// context.Context) string { return store.CarrierNodeURL() }).
|
// context.Context) string { return store.CarrierNodeURL() }).
|
||||||
@@ -87,6 +102,12 @@ func (s *Store) Set(next Info) {
|
|||||||
if url := strings.TrimSpace(next.AuthGuardURL); url != "" {
|
if url := strings.TrimSpace(next.AuthGuardURL); url != "" {
|
||||||
s.info.AuthGuardURL = url
|
s.info.AuthGuardURL = url
|
||||||
}
|
}
|
||||||
|
if url := strings.TrimRight(strings.TrimSpace(next.ComfyUIURL), "/"); url != "" {
|
||||||
|
s.info.ComfyUIURL = url
|
||||||
|
}
|
||||||
|
if url := strings.TrimRight(strings.TrimSpace(next.ProjectConfiguratorURL), "/"); url != "" {
|
||||||
|
s.info.ProjectConfiguratorURL = url
|
||||||
|
}
|
||||||
if len(next.CarrierNodeURLs) > 0 {
|
if len(next.CarrierNodeURLs) > 0 {
|
||||||
s.info.CarrierNodeURLs = next.CarrierNodeURLs
|
s.info.CarrierNodeURLs = next.CarrierNodeURLs
|
||||||
s.info.CarrierNodeURL = next.CarrierNodeURLs[0]
|
s.info.CarrierNodeURL = next.CarrierNodeURLs[0]
|
||||||
|
|||||||
@@ -22,6 +22,16 @@ func TestStoreSetIgnoresBlankFields(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStoreSetComfyUIURL(t *testing.T) {
|
||||||
|
store := NewStore(Info{})
|
||||||
|
|
||||||
|
store.Set(Info{ComfyUIURL: "http://comfyui:8188/"})
|
||||||
|
|
||||||
|
if got := store.ComfyUIURL(); got != "http://comfyui:8188" {
|
||||||
|
t.Fatalf("ComfyUIURL = %q, want trimmed URL", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestStoreOnUpdateFiresWithNewInfo(t *testing.T) {
|
func TestStoreOnUpdateFiresWithNewInfo(t *testing.T) {
|
||||||
store := NewStore(Info{})
|
store := NewStore(Info{})
|
||||||
var got Info
|
var got Info
|
||||||
|
|||||||
Reference in new issue
Block a user