Conversation
This commit introduces unit tests for the JSON serialization of LoadedAPIInfo and LoadedPolicyInfo structs, ensuring that they correctly marshal and unmarshal to and from JSON format. Additionally, it updates the GWStats struct to include LoadedAPIs and LoadedPolicies, enhancing the reporting of loaded resources. The tests verify that empty loaded resources are omitted from the JSON output when applicable. - Added tests for LoadedAPIInfo and LoadedPolicyInfo serialization. - Updated GWStats to include LoadedAPIs and LoadedPolicies. - Ensured proper omission of empty fields in JSON output.
|
This PR enhances the gateway's node registration payload sent to the Multi-Datacenter Bridge (MDCB) by including the specific IDs of all loaded APIs and policies. This provides operators with detailed visibility into the configuration state of each gateway node, showing exactly which resources are active. Files Changed AnalysisThe changes are logically structured across three main areas:
Overall, the changes are well-tested, with 298 additions (mostly tests) versus only 4 deletions, covering data structures, business logic, and payload construction. Architecture & Impact Assessment
Data Flow DiagramsequenceDiagram
participant Operator
participant MDCB
participant Gateway
Gateway->>Gateway: buildNodeInfo()
Note right of Gateway: Collects node stats, including <br> a list of loaded API IDs <br> and Policy IDs.
Gateway->>MDCB: Register/Heartbeat with extended NodeData
MDCB->>MDCB: Store enriched node information
Operator->>MDCB: GET /dataplanes
MDCB-->>Operator: Return node data, including loaded APIs/Policies
Scope Discovery & Context Expansion
Metadata
Powered by Visor from Probelabs Last updated: 2026-01-27T11:58:09.455Z | Triggered by: pr_updated | Commit: d1ba70b 💡 TIP: You can chat with Visor using |
|
API Changes --- prev.txt 2026-01-27 11:57:25.654272260 +0000
+++ current.txt 2026-01-27 11:57:16.036310320 +0000
@@ -574,8 +574,10 @@
https://tyk.io/docs/basic-config-and-security/security/authentication-authorization/ext-oauth-middleware/.
type GWStats struct {
- APIsCount int `json:"apis_count"`
- PoliciesCount int `json:"policies_count"`
+ APIsCount int `json:"apis_count"`
+ PoliciesCount int `json:"policies_count"`
+ LoadedAPIs []LoadedAPIInfo `json:"loaded_apis,omitempty"`
+ LoadedPolicies []LoadedPolicyInfo `json:"loaded_policies,omitempty"`
}
type GlobalRateLimit struct {
@@ -946,6 +948,16 @@
Values []string
}
+type LoadedAPIInfo struct {
+ APIID string `json:"api_id"`
+}
+ LoadedAPIInfo represents a loaded API with its metadata.
+
+type LoadedPolicyInfo struct {
+ PolicyID string `json:"policy_id"`
+}
+ LoadedPolicyInfo represents a loaded policy with its metadata.
+
type LogEventHandlerConf struct {
// Disabled indicates whether the handler is inactive.
Disabled bool `bson:"disabled" json:"disabled"`
@@ -10198,6 +10210,14 @@
func (gw *Gateway) GetConfig() config.Config
+func (gw *Gateway) GetLoadedAPIIDs() []model.LoadedAPIInfo
+ GetLoadedAPIIDs returns a list of all loaded API IDs with metadata. This is
+ used for reporting loaded resources to MDCB.
+
+func (gw *Gateway) GetLoadedPolicyIDs() []model.LoadedPolicyInfo
+ GetLoadedPolicyIDs returns a list of all loaded policy IDs with metadata.
+ This is used for reporting loaded resources to MDCB.
+
func (gw *Gateway) GetNodeID() string
GetNodeID reads NodeID safely.
|
Security Issues (2)
✅ Architecture Check PassedNo architecture issues found – changes LGTM. Performance Issues (2)
Quality Issues (1)
Powered by Visor from Probelabs Last updated: 2026-01-27T11:58:12.929Z | Triggered by: pr_updated | Commit: d1ba70b 💡 TIP: You can chat with Visor using |
This commit updates the comments for the LoadedAPIInfo and LoadedPolicyInfo structs to clarify their purpose and remove references to future extensibility regarding checksums. The changes enhance the readability and maintainability of the code without altering any functionality.
|



Description
Extends the gateway's node registration data sent to MDCB to include the IDs of currently loaded APIs and policies.
Changes:
LoadedAPIInfoandLoadedPolicyInfostructs toapidef/rpc.goGWStatswithloaded_apisandloaded_policiesfields (omitempty for backwardcompatibility)
GetLoadedAPIIDs()andGetLoadedPolicyIDs()helper methods to GatewaybuildNodeInfo()to populate loaded resource IDsThis enables MDCB operators to see exactly which APIs and policies each gateway node has loaded via the
/dataplanesendpoint.Related Issue
https://tyktech.atlassian.net/browse/TT-16455?atlOrigin=eyJpIjoiZTI2ODVmZGU2ZjE5NDkxY2FiMTIzZTQzYzAzMzYwMDQiLCJwIjoiaiJ9
Motivation and Context
https://tyktech.atlassian.net/browse/TT-16455?atlOrigin=eyJpIjoiZTI2ODVmZGU2ZjE5NDkxY2FiMTIzZTQzYzAzMzYwMDQiLCJwIjoiaiJ9
How This Has Been Tested
Manually tested, and automated tests were added
Screenshots (if appropriate)
Types of changes
Checklist
Ticket Details
TT-16455
Generated at: 2026-01-27 11:56:44