TykTechnologies / tyk

Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols
Other
9.76k stars 1.09k forks source link

[TT-13238] Clean up RPC data model #6608

Closed titpetric closed 1 month ago

titpetric commented 1 month ago
TT-13238
Summary Data model cleanup on gateway
Type Task Task
Status In Dev
Points N/A
Labels SESAP

User description

https://tyktech.atlassian.net/browse/TT-13238


PR Type

enhancement, bug fix


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
health_check.go
Update health check to use model package                                 

gateway/health_check.go
  • Replaced apidef package references with model package.
  • Updated health check logic to use model types.
  • rpc_storage_handler.go
    Refactor RPC storage handler to use model package               

    gateway/rpc_storage_handler.go
  • Replaced apidef package references with model package.
  • Updated RPC storage handler functions to use model types.
  • merged_apis.go
    Introduce MergedAPI and MergedAPIList types                           

    internal/model/merged_apis.go
  • Added new MergedAPI and MergedAPIList types.
  • Implemented methods for managing and filtering merged APIs.
  • rpc.go
    Refactor rpc.go to use model package                                         

    internal/model/rpc.go
  • Changed package name from apidef to model.
  • Updated NodeData struct to use HostDetails from model.
  • synchronization_forcer.go
    Update synchronization logic to use model package               

    rpc/synchronization_forcer.go
  • Replaced apidef package references with model package.
  • Updated synchronization logic to use model types.
  • Tests
    rpc_storage_handler_test.go
    Update RPC storage handler tests for model package             

    gateway/rpc_storage_handler_test.go
  • Replaced apidef package references with model package in tests.
  • Updated test cases to align with new model types.
  • rpc_test.go
    Refactor RPC tests to use model package                                   

    gateway/rpc_test.go
  • Replaced apidef package references with model package in RPC tests.
  • Adjusted test logic to accommodate changes in data structures.
  • Bug fix
    health_check.go
    Rename package to model in health_check.go                             

    internal/model/health_check.go - Changed package name from `apidef` to `model`.

    ๐Ÿ’ก PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    buger commented 1 month ago

    :broken_heart: The detected issue is not in one of the allowed statuses :broken_heart:

    Detected Status In Refinement :x:
    Allowed Statuses In Dev,In Code Review,Ready for Testing,In Test,In Progress,In Review :heavy_check_mark:

    Please ensure your jira story is in one of the allowed statuses

    github-actions[bot] commented 1 month ago

    PR Reviewer Guide ๐Ÿ”

    Here are some key observations to aid the review process:

    โฑ๏ธ Estimated effort to review: 3 ๐Ÿ”ต๐Ÿ”ต๐Ÿ”ตโšชโšช
    ๐Ÿงช No relevant tests
    ๐Ÿ”’ No security concerns identified
    โšก Recommended focus areas for review

    Refactoring
    The health check logic has been refactored to use the new `model` package. Ensure that the new implementation aligns with the expected behavior and that all functionalities are preserved. Function Mapping
    The dispatcher functions have been updated to use the new `model` types. Verify that the new function mappings are correctly implemented and that they handle the data as expected. New Feature
    The new `MergedAPI` and `MergedAPIList` types have been introduced. Review the methods associated with these types to ensure they correctly manage and filter API data.
    github-actions[bot] commented 1 month ago

    PR Code Suggestions โœจ

    No code suggestions found for the PR.

    github-actions[bot] commented 1 month ago

    API Changes

    --- prev.txt    2024-10-09 11:59:08.801023315 +0000
    +++ current.txt 2024-10-09 11:59:02.697052366 +0000
    @@ -1499,6 +1499,14 @@
        Body                string            `bson:"body" json:"body"`
     }
    
    +type HostDetails struct {
    +   Hostname string
    +   PID      int
    +   Address  string
    +}
    +    HostDetails contains information about a host machine, including its
    +    hostname, process ID (PID), and IP address.
    +
     type HostList struct {
        // Has unexported fields.
     }
    @@ -1634,7 +1642,7 @@
        Tags            []string                   `json:"tags"`
        Health          map[string]HealthCheckItem `json:"health"`
        Stats           GWStats                    `json:"stats"`
    -   HostDetails     internalmodel.HostDetails  `json:"host_details"`
    +   HostDetails     HostDetails                `json:"host_details"`
     }
    
     type NotificationsManager struct {
    buger commented 1 month ago

    I'm a bot and I ๐Ÿ‘ this PR title. ๐Ÿค–

    sonarcloud[bot] commented 1 month ago

    Quality Gate Failed Quality Gate failed

    Failed conditions
    0.0% Coverage on New Code (required โ‰ฅ 80%)
    C Reliability Rating on New Code (required โ‰ฅ A)

    See analysis details on SonarCloud

    Catch issues before they fail your Quality Gate with our IDE extension SonarLint