Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8694,6 +8694,14 @@ const docTemplate = `{
"type": "string"
}
},
"circuit_breaker_threshold": {
"description": "consecutive failures to trip open (0=disabled)",
"type": "integer"
},
"circuit_breaker_timeout": {
"description": "ms in open before half-open",
"type": "integer"
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"created_at": {
"type": "string"
},
Expand All @@ -8712,6 +8720,10 @@ const docTemplate = `{
"description": "Max request body size in bytes",
"type": "integer"
},
"max_retries": {
"description": "max retry attempts (0=disabled)",
"type": "integer"
},
"methods": {
"description": "New: HTTP methods to match (empty = all)",
"type": "array",
Expand Down Expand Up @@ -8757,6 +8769,10 @@ const docTemplate = `{
"description": "Time to receive headers in milliseconds",
"type": "integer"
},
"retry_timeout": {
"description": "total retry window in ms",
"type": "integer"
},
"strip_prefix": {
"description": "If true, removes path_prefix from request before forwarding",
"type": "boolean"
Expand Down Expand Up @@ -11102,6 +11118,14 @@ const docTemplate = `{
"type": "string"
}
},
"circuit_breaker_threshold": {
"type": "integer",
"minimum": 0
},
"circuit_breaker_timeout": {
"type": "integer",
"minimum": 0
},
"dial_timeout": {
"type": "integer",
"minimum": 0
Expand All @@ -11114,6 +11138,10 @@ const docTemplate = `{
"type": "integer",
"minimum": 0
},
"max_retries": {
"type": "integer",
"minimum": 0
},
"methods": {
"type": "array",
"items": {
Expand Down Expand Up @@ -11141,6 +11169,10 @@ const docTemplate = `{
"type": "integer",
"minimum": 0
},
"retry_timeout": {
"type": "integer",
"minimum": 0
},
"strip_prefix": {
"type": "boolean"
},
Expand Down
32 changes: 32 additions & 0 deletions docs/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -8686,6 +8686,14 @@
"type": "string"
}
},
"circuit_breaker_threshold": {
"description": "consecutive failures to trip open (0=disabled)",
"type": "integer"
},
"circuit_breaker_timeout": {
"description": "ms in open before half-open",
"type": "integer"
},
"created_at": {
"type": "string"
},
Expand All @@ -8704,6 +8712,10 @@
"description": "Max request body size in bytes",
"type": "integer"
},
"max_retries": {
"description": "max retry attempts (0=disabled)",
"type": "integer"
},
"methods": {
"description": "New: HTTP methods to match (empty = all)",
"type": "array",
Expand Down Expand Up @@ -8749,6 +8761,10 @@
"description": "Time to receive headers in milliseconds",
"type": "integer"
},
"retry_timeout": {
"description": "total retry window in ms",
"type": "integer"
},
"strip_prefix": {
"description": "If true, removes path_prefix from request before forwarding",
"type": "boolean"
Expand Down Expand Up @@ -11094,6 +11110,14 @@
"type": "string"
}
},
"circuit_breaker_threshold": {
"type": "integer",
"minimum": 0
},
"circuit_breaker_timeout": {
"type": "integer",
"minimum": 0
},
"dial_timeout": {
"type": "integer",
"minimum": 0
Expand All @@ -11106,6 +11130,10 @@
"type": "integer",
"minimum": 0
},
"max_retries": {
"type": "integer",
"minimum": 0
},
"methods": {
"type": "array",
"items": {
Expand Down Expand Up @@ -11133,6 +11161,10 @@
"type": "integer",
"minimum": 0
},
"retry_timeout": {
"type": "integer",
"minimum": 0
},
"strip_prefix": {
"type": "boolean"
},
Expand Down
24 changes: 24 additions & 0 deletions docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@ definitions:
items:
type: string
type: array
circuit_breaker_threshold:
description: consecutive failures to trip open (0=disabled)
type: integer
circuit_breaker_timeout:
description: ms in open before half-open
type: integer
Comment thread
coderabbitai[bot] marked this conversation as resolved.
created_at:
type: string
dial_timeout:
Expand All @@ -424,6 +430,9 @@ definitions:
max_body_size:
description: Max request body size in bytes
type: integer
max_retries:
description: max retry attempts (0=disabled)
type: integer
methods:
description: 'New: HTTP methods to match (empty = all)'
items:
Expand Down Expand Up @@ -457,6 +466,9 @@ definitions:
response_header_timeout:
description: Time to receive headers in milliseconds
type: integer
retry_timeout:
description: total retry window in ms
type: integer
strip_prefix:
description: If true, removes path_prefix from request before forwarding
type: boolean
Expand Down Expand Up @@ -2147,6 +2159,12 @@ definitions:
items:
type: string
type: array
circuit_breaker_threshold:
minimum: 0
type: integer
circuit_breaker_timeout:
minimum: 0
type: integer
dial_timeout:
minimum: 0
type: integer
Expand All @@ -2156,6 +2174,9 @@ definitions:
max_body_size:
minimum: 0
type: integer
max_retries:
minimum: 0
type: integer
methods:
items:
type: string
Expand All @@ -2175,6 +2196,9 @@ definitions:
response_header_timeout:
minimum: 0
type: integer
retry_timeout:
minimum: 0
type: integer
strip_prefix:
type: boolean
target_url:
Expand Down
4 changes: 4 additions & 0 deletions internal/core/domain/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ type GatewayRoute struct {
BlockedCIDRs []string `json:"blocked_cidrs,omitempty"` // IPs blocked from access
BlockedIPNets []*net.IPNet `json:"-"` // pre-parsed at creation/refresh for fast lookup
MaxBodySize int64 `json:"max_body_size,omitempty"` // Max request body size in bytes
CircuitBreakerThreshold int `json:"circuit_breaker_threshold,omitempty"` // consecutive failures to trip open (0=disabled)
CircuitBreakerTimeout int64 `json:"circuit_breaker_timeout,omitempty"` // ms in open before half-open
MaxRetries int `json:"max_retries,omitempty"` // max retry attempts (0=disabled)
RetryTimeout int64 `json:"retry_timeout,omitempty"` // total retry window in ms
Priority int `json:"priority"` // Manual priority for tie-breaking
Comment on lines +35 to 39
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Expand Down
8 changes: 6 additions & 2 deletions internal/core/ports/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ type CreateRouteParams struct {
RequireTLS bool
AllowedCIDRs []string
BlockedCIDRs []string
MaxBodySize int64
Priority int
MaxBodySize int64
CircuitBreakerThreshold int
CircuitBreakerTimeout int64
MaxRetries int
RetryTimeout int64
Priority int
Comment on lines +44 to +49
Comment on lines +44 to +49
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

These options need an “unset” state, not plain ints.

0 is the documented disable value for several of these settings, but value types collapse “omitted” and “explicit 0” into the same state. Because CreateRoute later defaults zero values, callers cannot actually disable retries/circuit breaking through this contract. Use pointer fields here or separate enabled flags before this API shape ships.

🧩 Contract sketch
-	MaxBodySize               int64
-	CircuitBreakerThreshold   int
-	CircuitBreakerTimeout     int64
-	MaxRetries                int
-	RetryTimeout              int64
-	Priority                  int
+	MaxBodySize               *int64
+	CircuitBreakerThreshold   *int
+	CircuitBreakerTimeout     *int64
+	MaxRetries                *int
+	RetryTimeout              *int64
+	Priority                  *int

You'd then default only nil values and preserve explicit 0.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/core/ports/gateway.go` around lines 44 - 49, The config fields
MaxBodySize, CircuitBreakerThreshold, CircuitBreakerTimeout, MaxRetries,
RetryTimeout and Priority must allow an "unset" state so explicit zero differs
from omitted; change their types on the API struct to pointer types (e.g. *int64
/ *int) or add explicit enabled flags, and update the CreateRoute logic to apply
defaults only when the pointer is nil (preserve an explicit 0 when pointer is
non-nil). Locate and update the struct with those fields and the CreateRoute
function to read/assign defaults from nil checks rather than testing for value
== 0.

}

// GatewayService provides business logic for managing the API gateway and ingress traffic.
Expand Down
Loading
Loading