Documentation
¶
Overview ¶
Package sections provides factory functions for creating HAProxy configuration operations.
This file contains generic CRUD builders that turn a single registration into Create/Update/Delete operation descriptor factories. Descriptors no longer carry per-section execute closures — the orchestrator pushes the full rendered config via the dataplane raw endpoint.
Package sections provides factory functions for creating HAProxy configuration operations.
Operations describe a single diff entry produced by the comparator. They are consumed by:
- the orchestrator (to decide whether the diff is fully runtime-eligible, and to build the X-Runtime-Actions header for server field updates),
- logging / metrics (Section + Describe).
They do NOT execute themselves: the orchestrator pushes the full rendered config via the dataplane API's raw endpoint, no per-section API call exists.
Package sections provides factory functions for creating HAProxy Enterprise Edition operations.
This file contains factory functions for EE-only sections: - Bot Management Profiles (v3.0+ EE) - Captcha (v3.0+ EE) - WAF Profile (v3.2+ EE) - WAF Global (v3.2+ EE)
Package sections provides factory functions for creating HAProxy configuration operations.
This file contains helper functions to reduce repetition in factory functions.
Package sections provides generic operation types for HAProxy configuration management.
Operations are descriptors of a single diff entry — what kind of change, which section, a human-readable string. They are produced by the comparator, consumed by the orchestrator to decide push strategy (raw-push always; runtime actions for server field updates), and inspected by metrics/logging. They no longer carry an Execute method — the orchestrator pushes the full rendered config via the dataplane API's raw endpoint and never calls per-section API endpoints.
Index ¶
- Variables
- func ServerIneligibleFields(current, desired *models.Server) []string
- type ContainerChildCRUD
- type FrontendMaxconnUpdateOp
- type IndexChildCRUD
- type NameChildCRUD
- type Operation
- func NewGlobalUpdate(_ *models.Global) Operation
- func NewServerCreate(backendName string, server *models.Server) Operation
- func NewServerDelete(backendName string, server *models.Server) Operation
- func NewServerUpdate(backendName string, current, desired *models.Server) Operation
- func NewTracesUpdate(_ *models.Traces) Operation
- func NewWAFGlobalCreate(_ *v32ee.WafGlobal) Operation
- func NewWAFGlobalDelete(_ *v32ee.WafGlobal) Operation
- func NewWAFGlobalUpdate(_ *v32ee.WafGlobal) Operation
- type OperationType
- type ServerUpdateOp
- func (op *ServerUpdateOp) BackendName() string
- func (op *ServerUpdateOp) CurrentServer() *models.Server
- func (op *ServerUpdateOp) Describe() string
- func (op *ServerUpdateOp) IsFullyRuntimeEligible() bool
- func (op *ServerUpdateOp) Section() string
- func (op *ServerUpdateOp) Server() *models.Server
- func (op *ServerUpdateOp) ServerName() string
- func (op *ServerUpdateOp) Type() OperationType
- type TopLevelCRUD
Constants ¶
This section is empty.
Variables ¶
var ( BackendOps = NewTopLevelCRUD("backend", "backend", backendNameFn) FrontendOps = NewTopLevelCRUD("frontend", "frontend", frontendNameFn) DefaultsOps = NewTopLevelCRUD("defaults", "defaults section", defaultsNameFn) )
Top-level CRUD builders for core sections.
var ( ACLFrontendOps = NewIndexChildCRUDWithDescriber[*models.ACL]("acl", describeACLOp("frontend")) ACLBackendOps = NewIndexChildCRUDWithDescriber[*models.ACL]("acl", describeACLOp("backend")) )
CRUD builders for ACLs in frontends and backends.
var ( BotMgmtProfileOps = NewTopLevelCRUD("botmgmt-profile", "botmgmt-profile", botMgmtProfileName) CaptchaOps = NewTopLevelCRUD("captcha", "captcha", captchaEEName) WafProfileOps = NewTopLevelCRUD("waf-profile", "waf-profile", wafProfileName) )
Top-level CRUD builders for Enterprise Edition sections.
var ( FilterFrontendOps = NewIndexChildCRUD[*models.Filter]("filter", "filter", "frontend", filterIdentifier) FilterBackendOps = NewIndexChildCRUD[*models.Filter]("filter", "filter", "backend", filterIdentifier) LogTargetFrontendOps = NewIndexChildCRUD[*models.LogTarget]("log_target", "log target", "frontend", logTargetIdentifier) LogTargetBackendOps = NewIndexChildCRUD[*models.LogTarget]("log_target", "log target", "backend", logTargetIdentifier) LogForwardOps = NewTopLevelCRUD[*models.LogForward]("log_forward", "log-forward", logForwardName) )
CRUD builders for filters, log targets and the log-forward top-level section.
var ( HTTPRequestRuleFrontendOps = NewIndexChildCRUD[*models.HTTPRequestRule]("http_request_rule", "HTTP request rule", "frontend", httpRequestRuleIdentifier) HTTPRequestRuleBackendOps = NewIndexChildCRUD[*models.HTTPRequestRule]("http_request_rule", "HTTP request rule", "backend", httpRequestRuleIdentifier) HTTPResponseRuleFrontendOps = NewIndexChildCRUD[*models.HTTPResponseRule]("http_response_rule", "HTTP response rule", "frontend", httpResponseRuleIdentifier) HTTPResponseRuleBackendOps = NewIndexChildCRUD[*models.HTTPResponseRule]("http_response_rule", "HTTP response rule", "backend", httpResponseRuleIdentifier) )
CRUD builders for HTTP request and response rules.
var ( QuicInitialRuleFrontendOps = NewIndexChildCRUDWithDescriber[*models.QUICInitialRule]("quic_initial_rule", describeQUICInitialRule("frontend")) QuicInitialRuleDefaultsOps = NewIndexChildCRUDWithDescriber[*models.QUICInitialRule]("quic_initial_rule", describeQUICInitialRule("defaults")) )
CRUD builders for QUIC initial rules in frontends and defaults sections. QUIC initial rules are only available in HAProxy DataPlane API v3.1+.
var ( CacheOps = NewTopLevelCRUD("cache", "cache", cacheNameFn) HTTPErrorsOps = NewTopLevelCRUD("http_errors", "http-errors section", httpErrorsSectionName) MailersOps = NewTopLevelCRUD("mailers", "mailers", mailersSectionName) PeerSectionOps = NewTopLevelCRUD("peers", "peer section", peerSectionName) ResolverOps = NewTopLevelCRUD("resolver", "resolver", resolverNameFn) RingOps = NewTopLevelCRUD("ring", "ring", ringNameFn) CrtStoreOps = NewTopLevelCRUD("crt_store", "crt-store", crtStoreName) UserlistOps = NewTopLevelCRUD("userlist", "userlist", userlistName) FcgiAppOps = NewTopLevelCRUD("fcgi_app", "fcgi-app", fcgiAppName) LogProfileOps = NewTopLevelCRUD("log_profile", "log-profile", logProfileName) AcmeProviderOps = NewTopLevelCRUD("acme_provider", "acme-provider", acmeProviderName) )
Top-level CRUD builders for additional sections.
var ( UserOps = NewContainerChildCRUD[*models.User]("user", "user", "userlist", userNameFn) MailerEntryOps = NewContainerChildCRUD[*models.MailerEntry]("mailer_entry", "mailer entry", "mailers section", mailerEntryName) PeerEntryOps = NewContainerChildCRUD[*models.PeerEntry]("peer_entry", "peer entry", "peer section", peerEntryName) NameserverOps = NewContainerChildCRUD[*models.Nameserver]("nameserver", "nameserver", "resolvers section", nameserverNameFn) )
Container-child CRUD builders.
var ( BackendSwitchingRuleFrontendOps = NewIndexChildCRUD[*models.BackendSwitchingRule]("backend_switching_rule", "backend switching rule", "frontend", backendSwitchingRuleIdentifier) ServerSwitchingRuleBackendOps = NewIndexChildCRUD[*models.ServerSwitchingRule]("server_switching_rule", "server switching rule", "backend", serverSwitchingRuleIdentifier) )
CRUD builders for backend and server switching rules.
var ( TCPRequestRuleFrontendOps = NewIndexChildCRUD[*models.TCPRequestRule]("tcp_request_rule", "TCP request rule", "frontend", tcpRequestRuleIdentifier) TCPRequestRuleBackendOps = NewIndexChildCRUD[*models.TCPRequestRule]("tcp_request_rule", "TCP request rule", "backend", tcpRequestRuleIdentifier) TCPResponseRuleBackendOps = NewIndexChildCRUD[*models.TCPResponseRule]("tcp_response_rule", "TCP response rule", "backend", tcpResponseRuleIdentifier) StickRuleBackendOps = NewIndexChildCRUD[*models.StickRule]("stick_rule", "stick rule", "backend", stickRuleIdentifier) HTTPAfterResponseRuleBackendOps = NewIndexChildCRUD[*models.HTTPAfterResponseRule]("http_after_response_rule", "HTTP after response rule", "backend", httpAfterResponseRuleIdentifier) HTTPAfterResponseRuleFrontendOps = NewIndexChildCRUD[*models.HTTPAfterResponseRule]("http_after_response_rule", "HTTP after response rule", "frontend", httpAfterResponseRuleIdentifier) HTTPCheckBackendOps = NewIndexChildCRUD[*models.HTTPCheck]("http_check", "HTTP check", "backend", httpCheckIdentifier) TCPCheckBackendOps = NewIndexChildCRUD[*models.TCPCheck]("tcp_check", "TCP check", "backend", tcpCheckIdentifier) CaptureFrontendOps = NewIndexChildCRUD[*models.Capture]("capture", "capture", "frontend", captureIdentifier) )
Index-child CRUD builders for TCP/HTTP rules, checks, sticks and captures.
var BindFrontendOps = NewNameChildCRUD[*models.Bind]( "bind", "bind", "frontend", func(bind *models.Bind, _ string) string { return bindIdentifier(bind) }, )
CRUD builder for binds in a frontend.
var ServerTemplateOps = NewNameChildCRUD[*models.ServerTemplate]( "server_template", "server template", "backend", func(_ *models.ServerTemplate, childName string) string { return childName }, )
ServerTemplateOps groups create/update/delete factories for server-template operations under a backend.
Functions ¶
func ServerIneligibleFields ¶
ServerIneligibleFields returns the JSON field names that differ between current and desired but are not in serverRuntimeSupportedJSONFields (i.e., they require a HAProxy reload). Returns an empty slice when all changed fields are runtime-eligible. Used for diagnostics to explain why the runtime-optimized path was skipped.
Common causes of non-eligible fields in production:
- "check": occurs when individual server lines carry the `check` keyword (e.g., `server SRV_1 10.0.0.1:8080 check enabled`) but reserved slots do not. Fix: move `check` to the `default-server` directive so all server lines stay at address:port + enabled/disabled only, making every slot-swap fully runtime-eligible.
Types ¶
type ContainerChildCRUD ¶
type ContainerChildCRUD[T any] struct { Create func(containerName string, model T) Operation Update func(containerName string, model T) Operation Delete func(containerName string, model T) Operation }
ContainerChildCRUD holds pre-built Create/Update/Delete factories for a container-child resource (user-in-userlist, nameserver-in-resolver, etc.).
func NewContainerChildCRUD ¶
func NewContainerChildCRUD[T any](section, displayName, containerType string, nameFn func(T) string) ContainerChildCRUD[T]
NewContainerChildCRUD creates a CRUD builder for a container-child resource.
type FrontendMaxconnUpdateOp ¶
type FrontendMaxconnUpdateOp struct {
// contains filtered or unexported fields
}
FrontendMaxconnUpdateOp is a specialized frontend update that carries ONLY a maxconn change, applied to the live worker via the runtime API (`set maxconn frontend`) without a reload. The comparator emits it only when maxconn is the sole differing frontend attribute and the desired value is set; any other attribute change keeps the whole frontend update structural.
Like ServerUpdateOp, it is admitted to the runtime fast path by partitionByRuntimeEligibility and turned into an X-Runtime-Actions verb by buildRuntimeActions (both in pkg/dataplane/orchestrator.go). It is its own type rather than a generic op so those two functions can recognise it by type assertion, exactly as they do for ServerUpdateOp.
func NewFrontendMaxconnUpdate ¶
func NewFrontendMaxconnUpdate(frontendName string, maxconn int64) *FrontendMaxconnUpdateOp
NewFrontendMaxconnUpdate creates a runtime-eligible frontend maxconn update. maxconn is the desired value; the caller has already established that it is set and is the only changed (non-nested) frontend attribute.
func (*FrontendMaxconnUpdateOp) Describe ¶
func (op *FrontendMaxconnUpdateOp) Describe() string
func (*FrontendMaxconnUpdateOp) FrontendName ¶
func (op *FrontendMaxconnUpdateOp) FrontendName() string
FrontendName returns the frontend whose maxconn is being updated.
func (*FrontendMaxconnUpdateOp) RuntimeAction ¶
func (op *FrontendMaxconnUpdateOp) RuntimeAction() string
RuntimeAction returns the X-Runtime-Actions verb that applies this update via the dataplane API's skip_reload raw push (parsed by executeRuntimeActions: `SetFrontendMaxConn <name> <value>`).
func (*FrontendMaxconnUpdateOp) Section ¶
func (op *FrontendMaxconnUpdateOp) Section() string
func (*FrontendMaxconnUpdateOp) Type ¶
func (op *FrontendMaxconnUpdateOp) Type() OperationType
type IndexChildCRUD ¶
type IndexChildCRUD[T any] struct { Create func(parentName string, model T, index int) Operation Update func(parentName string, model T, index int) Operation Delete func(parentName string, model T, index int) Operation }
IndexChildCRUD holds pre-built Create/Update/Delete factories for an index-based child resource (ACL, HTTP/TCP rules, checks, captures, etc.).
func NewIndexChildCRUD ¶
func NewIndexChildCRUD[T any](section, displayName, parentType string, identifierFn func(T) string) IndexChildCRUD[T]
NewIndexChildCRUD creates a CRUD builder for an index-based child resource.
func NewIndexChildCRUDWithDescriber ¶
func NewIndexChildCRUDWithDescriber[T any]( section string, describer func(opType OperationType, model T, parentName string, index int) func() string, ) IndexChildCRUD[T]
NewIndexChildCRUDWithDescriber is the general form of NewIndexChildCRUD where each operation's description is built by the caller-supplied describer.
type NameChildCRUD ¶
type NameChildCRUD[T any] struct { Create func(parentName, childName string, model T) Operation Update func(parentName, childName string, model T) Operation Delete func(parentName, childName string, model T) Operation }
NameChildCRUD holds pre-built Create/Update/Delete factories for a name-based child resource (server, server_template, bind, etc.).
func NewNameChildCRUD ¶
func NewNameChildCRUD[T any](section, displayType, parentType string, descNameFn func(model T, childName string) string) NameChildCRUD[T]
NewNameChildCRUD creates a CRUD builder for a name-based child resource.
type Operation ¶
type Operation interface {
Type() OperationType
Section() string
Describe() string
}
Operation describes a single diff entry produced by the comparator.
func NewGlobalUpdate ¶
NewGlobalUpdate creates an operation to update the global section.
func NewServerCreate ¶
NewServerCreate creates an operation to create a server in a backend.
func NewServerDelete ¶
NewServerDelete creates an operation to delete a server from a backend.
func NewServerUpdate ¶
NewServerUpdate creates an operation to update a server in a backend. Both current and desired server models are required to determine whether all changed fields are runtime-eligible (no reload needed).
func NewTracesUpdate ¶
NewTracesUpdate creates an operation to update the traces section. The traces section is a singleton - it can be created or replaced. Traces configuration is only available in HAProxy DataPlane API v3.1+.
func NewWAFGlobalCreate ¶
NewWAFGlobalCreate creates an operation to create the WAF global configuration. WAF global is a singleton section (only one per configuration).
func NewWAFGlobalDelete ¶
NewWAFGlobalDelete creates an operation to delete the WAF global configuration.
func NewWAFGlobalUpdate ¶
NewWAFGlobalUpdate creates an operation to update the WAF global configuration.
type OperationType ¶
type OperationType int
OperationType represents the type of HAProxy configuration operation.
const ( OperationCreate OperationType = iota OperationUpdate OperationDelete )
type ServerUpdateOp ¶
type ServerUpdateOp struct {
// contains filtered or unexported fields
}
ServerUpdateOp is a specialized operation for server updates. It carries the current and desired models alongside the runtime-eligibility flag the orchestrator uses to decide whether the diff is fully runtime-eligible (no reload required).
func (*ServerUpdateOp) BackendName ¶
func (op *ServerUpdateOp) BackendName() string
BackendName returns the name of the backend containing this server.
func (*ServerUpdateOp) CurrentServer ¶
func (op *ServerUpdateOp) CurrentServer() *models.Server
CurrentServer returns the current (pre-update) server model. Used for diagnostics to identify which fields changed and why they are/aren't runtime-eligible.
func (*ServerUpdateOp) Describe ¶
func (op *ServerUpdateOp) Describe() string
func (*ServerUpdateOp) IsFullyRuntimeEligible ¶
func (op *ServerUpdateOp) IsFullyRuntimeEligible() bool
IsFullyRuntimeEligible returns true if all changed server fields are in the runtime-supported set (no reload required for this update).
func (*ServerUpdateOp) Section ¶
func (op *ServerUpdateOp) Section() string
func (*ServerUpdateOp) Server ¶
func (op *ServerUpdateOp) Server() *models.Server
Server returns the server model being updated.
func (*ServerUpdateOp) ServerName ¶
func (op *ServerUpdateOp) ServerName() string
ServerName returns the name of the server being updated.
func (*ServerUpdateOp) Type ¶
func (op *ServerUpdateOp) Type() OperationType
type TopLevelCRUD ¶
type TopLevelCRUD[T any] struct { Create func(model T) Operation Update func(model T) Operation Delete func(model T) Operation }
TopLevelCRUD holds pre-built Create/Update/Delete factories for a top-level resource.
func NewTopLevelCRUD ¶
func NewTopLevelCRUD[T any](section, displayName string, nameFn func(T) string) TopLevelCRUD[T]
NewTopLevelCRUD creates a CRUD builder for a top-level resource (backend, frontend, etc.). The displayName is used in operation descriptions and may differ from the section name.