From 68821b97292443a9fd11482630031e2d34a3eed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Wed, 24 Jun 2026 08:41:02 +0300 Subject: [PATCH 1/4] dev/macos.sh: bumps Gonfique to last alpha. --- dev/macos.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/macos.sh b/dev/macos.sh index e83bd099..3a03bd95 100644 --- a/dev/macos.sh +++ b/dev/macos.sh @@ -19,7 +19,7 @@ which go || which stringer || go install "golang.org/x/tools/cmd/stringer@latest" which gonfique || - go install "github.com/ufukty/gonfique@v1.3.1" + go install "go.ufukty.com/gonfique/v2@v2.0.0-alpha.9" which sqlc || go install "github.com/sqlc-dev/sqlc/cmd/sqlc@latest" which govalid || From 5b60c86e9523cf8aa3a73e3b24b7a62561a48f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Wed, 24 Jun 2026 08:44:01 +0300 Subject: [PATCH 2/4] be/config/deployment: rewrites directives for Gonfique v2 and moves the Cors to top-level for both semantics and convenience of overwriting types of other values to `time.Time`. --- Makefile | 3 +- backend/config/deployment/config.go | 96 +++++++++++++++--------- backend/config/deployment/directives.yml | 14 +++- platform/local/deployment.yml | 5 +- 4 files changed, 76 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index e4b7f769..69ef46a3 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,6 @@ all: \ backend/config/deployment/config.go: platform/local/deployment.yml backend/config/deployment/directives.yml gonfique generate \ - -pkg deployment \ - -directives backend/config/deployment/directives.yml \ + -config backend/config/deployment/directives.yml \ -in platform/local/deployment.yml \ -out backend/config/deployment/config.go \ No newline at end of file diff --git a/backend/config/deployment/config.go b/backend/config/deployment/config.go index 46737452..8aa4789d 100644 --- a/backend/config/deployment/config.go +++ b/backend/config/deployment/config.go @@ -1,55 +1,79 @@ -// Code generated by gonfique. DO NOT EDIT. +// Code generated by gonfique v2.0.0-alpha.9. DO NOT EDIT. package deployment import ( "fmt" - "gopkg.in/yaml.v3" "os" "time" + + "gopkg.in/yaml.v3" ) +// exported for cors +type Cors struct { + AllowOrigin string `yaml:"allow-origin"` +} + +// exported for environment +type Environment string + +// exported for ports +type Ports struct { + Gateway int `yaml:"gateway"` + Internal int `yaml:"internal"` + Objectives int `yaml:"objectives"` + Pdp int `yaml:"pdp"` + Profiles int `yaml:"profiles"` + Registration int `yaml:"registration"` + Registry int `yaml:"registry"` + Sessions int `yaml:"sessions"` + Tags int `yaml:"tags"` + Users int `yaml:"users"` +} + +// exported for reception +type Reception struct { + RequestTimeout time.Duration `yaml:"request-timeout"` +} + +// exported for registry +type Registry struct { + ClearanceDelay time.Duration `yaml:"clearance-delay"` + ClearancePeriod time.Duration `yaml:"clearance-period"` + InstanceTimeout time.Duration `yaml:"instance-timeout"` +} + +// exported for registry-file +type RegistryFile struct { + UpdatePeriod time.Duration `yaml:"update-period"` +} + +// exported for router type Router struct { - Cors struct { - AllowOrigin string `yaml:"allow-origin"` - } `yaml:"cors"` GracePeriod time.Duration `yaml:"grace-period"` IdleTimeout time.Duration `yaml:"idle-timeout"` ReadTimeout time.Duration `yaml:"read-timeout"` WriteTimeout time.Duration `yaml:"write-timeout"` } + +// exported for sidecar +type Sidecar struct { + QueryingTickerDelay time.Duration `yaml:"querying-ticker-delay"` + QueryingTickerPeriod time.Duration `yaml:"querying-ticker-period"` + RechekingTickerDelay time.Duration `yaml:"recheking-ticker-delay"` + RechekingTickerPeriod time.Duration `yaml:"recheking-ticker-period"` +} + type Config struct { - Environment string `yaml:"environment"` - Ports struct { - Gateway int `yaml:"gateway"` - Internal int `yaml:"internal"` - Objectives int `yaml:"objectives"` - Pdp int `yaml:"pdp"` - Profiles int `yaml:"profiles"` - Registration int `yaml:"registration"` - Registry int `yaml:"registry"` - Sessions int `yaml:"sessions"` - Tags int `yaml:"tags"` - Users int `yaml:"users"` - } `yaml:"ports"` - Reception struct { - RequestTimeout time.Duration `yaml:"request-timeout"` - } `yaml:"reception"` - Registry struct { - ClearanceDelay time.Duration `yaml:"clearance-delay"` - ClearancePeriod time.Duration `yaml:"clearance-period"` - InstanceTimeout time.Duration `yaml:"instance-timeout"` - } `yaml:"registry"` - RegistryFile struct { - UpdatePeriod time.Duration `yaml:"update-period"` - } `yaml:"registry-file"` - Router Router `yaml:"router"` - Sidecar struct { - QueryingTickerDelay time.Duration `yaml:"querying-ticker-delay"` - QueryingTickerPeriod time.Duration `yaml:"querying-ticker-period"` - RechekingTickerDelay time.Duration `yaml:"recheking-ticker-delay"` - RechekingTickerPeriod time.Duration `yaml:"recheking-ticker-period"` - } `yaml:"sidecar"` + Cors Cors `yaml:"cors"` + Environment Environment `yaml:"environment"` + Ports Ports `yaml:"ports"` + Reception Reception `yaml:"reception"` + Registry Registry `yaml:"registry"` + RegistryFile RegistryFile `yaml:"registry-file"` + Router Router `yaml:"router"` + Sidecar Sidecar `yaml:"sidecar"` } func ReadConfig(path string) (*Config, error) { diff --git a/backend/config/deployment/directives.yml b/backend/config/deployment/directives.yml index f1870af2..cb14159b 100644 --- a/backend/config/deployment/directives.yml +++ b/backend/config/deployment/directives.yml @@ -1,2 +1,12 @@ -router: - declare: Router +meta: + package: deployment + type: Config + +rules: + "*": {export: true} + + "sidecar.*": {replace: time.Duration time} + "registry.*": {replace: time.Duration time} + "registry-file.*": {replace: time.Duration time} + "reception.*": {replace: time.Duration time} + "router.*": {replace: time.Duration time} \ No newline at end of file diff --git a/platform/local/deployment.yml b/platform/local/deployment.yml index 2bdbb47d..5b031017 100644 --- a/platform/local/deployment.yml +++ b/platform/local/deployment.yml @@ -5,8 +5,9 @@ router: read-timeout: 1s idle-timeout: 1s grace-period: 1s - cors: - allow-origin: "*" + +cors: + allow-origin: "*" reception: request-timeout: 2s From 0306caa8904b2655a49258de2f45c252e2bf1940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Thu, 2 Jul 2026 17:09:27 +0300 Subject: [PATCH 3/4] be/int/web/reception: adapts changes in deployment config schema. --- backend/internal/web/reception/agent.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/internal/web/reception/agent.go b/backend/internal/web/reception/agent.go index 12f5a440..e57c49fd 100644 --- a/backend/internal/web/reception/agent.go +++ b/backend/internal/web/reception/agent.go @@ -2,12 +2,13 @@ package reception import ( "fmt" + "net/http" + "net/url" + "logbook/config/deployment" "logbook/internal/logger" "logbook/internal/web/forwarder" "logbook/models" - "net/http" - "net/url" "go.ufukty.com/gohandlers/pkg/gohandlers" ) @@ -42,7 +43,7 @@ type Lister interface { } func (ag *Agent) RegisterEndpoints(public, private Lister) error { - origin, err := url.JoinPath(ag.deplcfg.Router.Cors.AllowOrigin) + origin, err := url.JoinPath(ag.deplcfg.Cors.AllowOrigin) if err != nil { return fmt.Errorf("url.JoinPath: %w", err) } From 8e3e141d738b08e084c1187a4c6e42465908d803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Thu, 2 Jul 2026 17:10:05 +0300 Subject: [PATCH 4/4] be/int/web/reception: renames fields for readability. --- backend/internal/web/reception/agent.go | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/backend/internal/web/reception/agent.go b/backend/internal/web/reception/agent.go index e57c49fd..c4edb974 100644 --- a/backend/internal/web/reception/agent.go +++ b/backend/internal/web/reception/agent.go @@ -15,16 +15,16 @@ import ( // [Agent] is the registration Agent which helps services, and gateways to register their handlers and forwarders appropriately type Agent struct { - deplcfg *deployment.Config - r *http.ServeMux - l *logger.Logger + c *deployment.Config + r *http.ServeMux + l *logger.Logger } -func NewAgent(deplcfg *deployment.Config, l *logger.Logger) *Agent { +func NewAgent(c *deployment.Config, l *logger.Logger) *Agent { return &Agent{ - deplcfg: deplcfg, - r: http.NewServeMux(), - l: l.Sub("agent"), + c: c, + r: http.NewServeMux(), + l: l.Sub("agent"), } } @@ -43,7 +43,7 @@ type Lister interface { } func (ag *Agent) RegisterEndpoints(public, private Lister) error { - origin, err := url.JoinPath(ag.deplcfg.Cors.AllowOrigin) + origin, err := url.JoinPath(ag.c.Cors.AllowOrigin) if err != nil { return fmt.Errorf("url.JoinPath: %w", err) } @@ -53,7 +53,7 @@ func (ag *Agent) RegisterEndpoints(public, private Lister) error { if public != nil { for hn, info := range public.ListHandlers() { c := newCors(info.Ref, origin, []string{info.Method}, corsheaders) - pl := newReceptionist(ag.deplcfg, ag.l.Sub(info.Path), c) + pl := newReceptionist(ag.c, ag.l.Sub(info.Path), c) ag.l.Printf("registering: %s (%s, OPTIONS %s) -> %p\n", hn, info.Method, info.Path, pl) for _, method := range []string{info.Method, "OPTIONS"} { @@ -65,15 +65,15 @@ func (ag *Agent) RegisterEndpoints(public, private Lister) error { if private != nil { for hn, info := range private.ListHandlers() { - pl := newReceptionist(ag.deplcfg, ag.l.Sub(info.Path), info.Ref) + pl := newReceptionist(ag.c, ag.l.Sub(info.Path), info.Ref) pattern := fmt.Sprintf("%s %s", info.Method, info.Path) ag.l.Printf("registering: %s (%s) -> %p\n", hn, pattern, pl) ag.r.Handle(pattern, pl) } } - ag.r.Handle("GET /ping", newReceptionist(ag.deplcfg, ag.l.Sub("ping"), http.HandlerFunc(pong))) - ag.r.Handle("GET /", newReceptionist(ag.deplcfg, ag.l.Sub("not-found"), http.HandlerFunc(http.NotFound))) + ag.r.Handle("GET /ping", newReceptionist(ag.c, ag.l.Sub("ping"), http.HandlerFunc(pong))) + ag.r.Handle("GET /", newReceptionist(ag.c, ag.l.Sub("not-found"), http.HandlerFunc(http.NotFound))) return nil } @@ -82,11 +82,11 @@ func (ag *Agent) RegisterForwarders(fwds map[models.Service]*forwarder.LoadBalan for addr, fwd := range fwds { ag.l.Printf("registering forwarder for: %s -> %p\n", addr, fwd) l := ag.l.Sub(fmt.Sprintf("strip-prefix(%s)", addr)) - ag.r.Handle(string(addr)+"/", newReceptionist(ag.deplcfg, l, http.StripPrefix(string(addr), fwd))) + ag.r.Handle(string(addr)+"/", newReceptionist(ag.c, l, http.StripPrefix(string(addr), fwd))) } - ag.r.Handle("/ping", newReceptionist(ag.deplcfg, ag.l.Sub("ping"), http.HandlerFunc(pong))) - ag.r.Handle("/", newReceptionist(ag.deplcfg, ag.l.Sub("not-found"), http.HandlerFunc(http.NotFound))) + ag.r.Handle("/ping", newReceptionist(ag.c, ag.l.Sub("ping"), http.HandlerFunc(pong))) + ag.r.Handle("/", newReceptionist(ag.c, ag.l.Sub("not-found"), http.HandlerFunc(http.NotFound))) return nil }