Skip to content

TT-11443 Shim to keep compatibility in goplugins importing tyk redis#6096

Merged
sredxny merged 13 commits into
masterfrom
shim-for-goplugins-using-redis
Mar 7, 2024
Merged

TT-11443 Shim to keep compatibility in goplugins importing tyk redis#6096
sredxny merged 13 commits into
masterfrom
shim-for-goplugins-using-redis

Conversation

@sredxny

@sredxny sredxny commented Mar 5, 2024

Copy link
Copy Markdown
Contributor

User description

Description

In order to not break compatibility of goplugins importing the redis implementation of the last versions of gw, is required to create a bridge that translates old instructions into new redis store instructions.

Related Issue

TT-11443

Motivation and Context

How This Has Been Tested

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring or add test (improvements in base code or adds test coverage to functionality)

Checklist

  • I ensured that the documentation is up to date
  • I explained why this PR updates go.mod in detail with reasoning why it's required
  • I would like a code coverage CI quality gate exception and have explained why

Type

enhancement


Description

  • Introduced a redis_shim.go file to ensure compatibility with goplugins importing the Redis implementation from previous versions. This acts as a bridge translating old Redis instructions to new Redis store instructions, maintaining backward compatibility without breaking existing implementations.

Changes walkthrough

Relevant files
Enhancement
redis_shim.go
Introduction of Redis Shim for Go Plugins Compatibility   

storage/redis_shim.go

  • Introduced a new file redis_shim.go for creating a bridge between old
    and new Redis store instructions.
  • +1/-0     

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    API Changes

    --- prev.txt	2024-03-07 20:20:31.282396496 +0000
    +++ current.txt	2024-03-07 20:20:28.470378952 +0000
    @@ -10882,8 +10882,10 @@
     	HashKeys    bool
     	IsCache     bool
     	IsAnalytics bool
    -	// RedisController must be passed from the gateway
    +
     	ConnectionHandler *ConnectionHandler
    +	// RedisController must remain for compatibility with goplugins
    +	RedisController *RedisController
     
     	// Has unexported fields.
     }
    @@ -11007,6 +11009,40 @@
         StartPubSubHandler will listen for a signal and run the callback for every
         subscription and message event.
     
    +type RedisController struct {
    +	// Has unexported fields.
    +}
    +    RedisController acts as a shim to provide backward compatibility for Go
    +    plugins users. It facilitates connecting to Redis using Tyk's storage
    +    package in a way that doesn't break existing implementations. changes here
    +    are sensible
    +
    +func NewRedisController(ctx context.Context) *RedisController
    +    NewRedisController initializes a new RedisController. This method ensures Go
    +    plugins can connect to Redis leveraging Tyk's internal storage mechanisms
    +    with minimal changes to their code.
    +
    +func (rc *RedisController) ConnectToRedis(ctx context.Context, onReconnect func(), conf *config.Config)
    +    ConnectToRedis sets up the connection to Redis using specified
    +    configuration. It abstracts the connection logic, allowing Go plugins to
    +    seamlessly integrate without direct interaction with the underlying storage
    +    logic.
    +
    +func (rc *RedisController) Connected() bool
    +    Connected checks the current state of the Redis connection, offering a
    +    simple interface for Go plugins to verify connectivity without delving into
    +    the specifics of the storage layer.
    +
    +func (rc *RedisController) DisableRedis(setRedisDown bool)
    +    DisableRedis toggles the Redis connection's active status, providing a
    +    mechanism to dynamically manage the connection state in response to runtime
    +    conditions or configurations.
    +
    +func (rc *RedisController) WaitConnect(ctx context.Context) bool
    +    WaitConnect blocks until a Redis connection is established, enabling Go
    +    plugins to wait for connectivity before proceeding with operations that
    +    require Redis access.
    +
     # Package: ./storage/kv
     
     package kv // import "github.com/TykTechnologies/tyk/storage/kv"

    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    PR Description updated to latest commit (f05bee6)

    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    PR Review

    ⏱️ Estimated effort to review [1-5]

    1, because the PR contains a very small change, adding only a package declaration in a new file. The review effort is minimal due to the simplicity and size of the change.

    🧪 Relevant tests

    No

    🔍 Possible issues

    No

    🔒 Security concerns

    No

    Code feedback:

    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
    When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:

    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    

    With a configuration file, use the following template:

    [pr_reviewer]
    some_config1=...
    some_config2=...
    
    Utilizing extra instructions

    The review tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize.

    Examples for extra instructions:

    [pr_reviewer] # /review #
    extra_instructions="""
    In the 'possible issues' section, emphasize the following:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    How to enable\disable automation
    • When you first install PR-Agent app, the default mode for the review tool is:
    pr_commands = ["/review", ...]
    

    meaning the review tool will run automatically on every PR, with the default configuration.
    Edit this field to enable/disable the tool, or to change the used configurations

    Auto-labels

    The review tool can auto-generate two specific types of labels for a PR:

    • a possible security issue label, that detects possible security issues (enable_review_labels_security flag)
    • a Review effort [1-5]: x label, where x is the estimated effort to review the PR (enable_review_labels_effort flag)
    Extra sub-tools

    The review tool provides a collection of possible feedbacks about a PR.
    It is recommended to review the possible options, and choose the ones relevant for your use case.
    Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example:
    require_score_review, require_soc2_ticket, and more.

    Auto-approve PRs

    By invoking:

    /review auto_approve
    

    The tool will automatically approve the PR, and add a comment with the approval.

    To ensure safety, the auto-approval feature is disabled by default. To enable auto-approval, you need to actively set in a pre-defined configuration file the following:

    [pr_reviewer]
    enable_auto_approval = true
    

    (this specific flag cannot be set with a command line argument, only in the configuration file, committed to the repository)

    You can also enable auto-approval only if the PR meets certain requirements, such as that the estimated_review_effort is equal or below a certain threshold, by adjusting the flag:

    [pr_reviewer]
    maximal_review_effort = 5
    
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the review usage page for a comprehensive guide on using this tool.

    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Best practice
    Add a package comment for clarity and documentation purposes.

    It's a good practice to add a package comment that provides an overview of the package's
    purpose, especially for public packages. This helps other developers understand the intent
    and scope of the package at a glance. Consider adding a package comment above the package
    storage declaration. For example:
    go
    // Package storage provides abstractions and
    implementations for storage mechanisms, including Redis.
    package storage

    storage/redis_shim.go [1]

    +// Package storage provides abstractions and implementations for storage mechanisms, including Redis.
     package storage
     

    ✨ Improve tool usage guide:

    Overview:
    The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.
    When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:

    /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
    

    With a configuration file, use the following template:

    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    
    Enabling\disabling automation

    When you first install the app, the default mode for the improve tool is:

    pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...]
    

    meaning the improve tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.

    Utilizing extra instructions

    Extra instructions are very important for the improve tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on.

    Examples for extra instructions:

    [pr_code_suggestions] # /improve #
    extra_instructions="""
    Emphasize the following aspects:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    A note on code suggestions quality
    • While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically.
    • Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base.
    • Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the custom suggestions 💎 tool
    • With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the improve usage page for a more comprehensive guide on using this tool.

    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    diff --git a/storage/redis_shim.go b/storage/redis_shim.go
    index 97760b3..5ec38ff 100644
    --- a/storage/redis_shim.go
    +++ b/storage/redis_shim.go
    @@ -2,6 +2,7 @@ package storage
     
     import (
     	"context"
    +
     	"github.com/TykTechnologies/tyk/config"
     )
     

    Please look at the run or in the Checks tab.

    1 similar comment
    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    diff --git a/storage/redis_shim.go b/storage/redis_shim.go
    index 97760b3..5ec38ff 100644
    --- a/storage/redis_shim.go
    +++ b/storage/redis_shim.go
    @@ -2,6 +2,7 @@ package storage
     
     import (
     	"context"
    +
     	"github.com/TykTechnologies/tyk/config"
     )
     

    Please look at the run or in the Checks tab.

    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    @buger

    buger commented Mar 5, 2024

    Copy link
    Copy Markdown
    Member

    API tests result - mongo44-sha256 env: success
    Branch used: refs/heads/master
    Commit: 33ebe8b TT-11443 Shim to keep compatibility in goplugins importing tyk redis (#6096)

    User description

    Description

    In order to not break compatibility of goplugins importing the redis
    implementation of the last versions of gw, is required to create a
    bridge that translates old instructions into new redis store
    instructions.

    Related Issue

    TT-11443

    Motivation and Context

    How This Has Been Tested

    Screenshots (if appropriate)

    Types of changes

    • Bug fix (non-breaking change which fixes an issue)
    • New feature (non-breaking change which adds functionality)
    • Breaking change (fix or feature that would cause existing
      functionality to change)
    • Refactoring or add test (improvements in base code or adds test
      coverage to functionality)

    Checklist

    • I ensured that the documentation is up to date
    • I explained why this PR updates go.mod in detail with reasoning
      why it's required
    • I would like a code coverage CI quality gate exception and have
      explained why

    Type

    enhancement


    Description

    • Introduced a redis_shim.go file to ensure compatibility with
      goplugins importing the Redis implementation from previous versions.
      This acts as a bridge translating old Redis instructions to new Redis
      store instructions, maintaining backward compatibility without breaking
      existing implementations.

    Changes walkthrough

    Relevant files
    Enhancement
    redis_shim.go
    Introduction of Redis Shim for Go Plugins Compatibility   

    storage/redis_shim.go

  • Introduced a new file redis_shim.go for creating a bridge between old
    and new Redis store instructions.
  • +1/-0     

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools
    and their descriptions
    Triggered by: push (@sredxny)
    Execution page

    @buger

    buger commented Mar 5, 2024

    Copy link
    Copy Markdown
    Member

    API tests result - postgres15-sha256 env: success
    Branch used: refs/heads/master
    Commit: 33ebe8b TT-11443 Shim to keep compatibility in goplugins importing tyk redis (#6096)

    User description

    Description

    In order to not break compatibility of goplugins importing the redis
    implementation of the last versions of gw, is required to create a
    bridge that translates old instructions into new redis store
    instructions.

    Related Issue

    TT-11443

    Motivation and Context

    How This Has Been Tested

    Screenshots (if appropriate)

    Types of changes

    • Bug fix (non-breaking change which fixes an issue)
    • New feature (non-breaking change which adds functionality)
    • Breaking change (fix or feature that would cause existing
      functionality to change)
    • Refactoring or add test (improvements in base code or adds test
      coverage to functionality)

    Checklist

    • I ensured that the documentation is up to date
    • I explained why this PR updates go.mod in detail with reasoning
      why it's required
    • I would like a code coverage CI quality gate exception and have
      explained why

    Type

    enhancement


    Description

    • Introduced a redis_shim.go file to ensure compatibility with
      goplugins importing the Redis implementation from previous versions.
      This acts as a bridge translating old Redis instructions to new Redis
      store instructions, maintaining backward compatibility without breaking
      existing implementations.

    Changes walkthrough

    Relevant files
    Enhancement
    redis_shim.go
    Introduction of Redis Shim for Go Plugins Compatibility   

    storage/redis_shim.go

  • Introduced a new file redis_shim.go for creating a bridge between old
    and new Redis store instructions.
  • +1/-0     

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools
    and their descriptions
    Triggered by: push (@sredxny)
    Execution page

    @sredxny sredxny changed the title started shim started shim to keep compatibility in golugins importing tyk redis Mar 5, 2024
    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    diff --git a/storage/redis_shim.go b/storage/redis_shim.go
    index 97760b3..5ec38ff 100644
    --- a/storage/redis_shim.go
    +++ b/storage/redis_shim.go
    @@ -2,6 +2,7 @@ package storage
     
     import (
     	"context"
    +
     	"github.com/TykTechnologies/tyk/config"
     )
     

    Please look at the run or in the Checks tab.

    @sredxny
    sredxny requested review from buger, mativm02 and padiazg March 5, 2024 15:33
    @github-actions

    github-actions Bot commented Mar 5, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    @sredxny sredxny changed the title started shim to keep compatibility in golugins importing tyk redis TT-11443 Shim to keep compatibility in goplugins importing tyk redis Mar 5, 2024
    @sredxny
    sredxny requested a review from titpetric March 5, 2024 16:13

    @padiazg padiazg left a comment

    Copy link
    Copy Markdown
    Contributor

    Choose a reason for hiding this comment

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

    LGTM

    @buger

    buger commented Mar 7, 2024

    Copy link
    Copy Markdown
    Member

    API tests result - postgres15-murmur64 env: success
    Branch used: refs/heads/master
    Commit: 33ebe8b TT-11443 Shim to keep compatibility in goplugins importing tyk redis (#6096)

    User description

    Description

    In order to not break compatibility of goplugins importing the redis
    implementation of the last versions of gw, is required to create a
    bridge that translates old instructions into new redis store
    instructions.

    Related Issue

    TT-11443

    Motivation and Context

    How This Has Been Tested

    Screenshots (if appropriate)

    Types of changes

    • Bug fix (non-breaking change which fixes an issue)
    • New feature (non-breaking change which adds functionality)
    • Breaking change (fix or feature that would cause existing
      functionality to change)
    • Refactoring or add test (improvements in base code or adds test
      coverage to functionality)

    Checklist

    • I ensured that the documentation is up to date
    • I explained why this PR updates go.mod in detail with reasoning
      why it's required
    • I would like a code coverage CI quality gate exception and have
      explained why

    Type

    enhancement


    Description

    • Introduced a redis_shim.go file to ensure compatibility with
      goplugins importing the Redis implementation from previous versions.
      This acts as a bridge translating old Redis instructions to new Redis
      store instructions, maintaining backward compatibility without breaking
      existing implementations.

    Changes walkthrough

    Relevant files
    Enhancement
    redis_shim.go
    Introduction of Redis Shim for Go Plugins Compatibility   

    storage/redis_shim.go

  • Introduced a new file redis_shim.go for creating a bridge between old
    and new Redis store instructions.
  • +1/-0     

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools
    and their descriptions
    Triggered by: push (@sredxny)
    Execution page

    @buger

    buger commented Mar 7, 2024

    Copy link
    Copy Markdown
    Member

    API tests result - mongo44-murmur64 env: success
    Branch used: refs/heads/master
    Commit: 33ebe8b TT-11443 Shim to keep compatibility in goplugins importing tyk redis (#6096)

    User description

    Description

    In order to not break compatibility of goplugins importing the redis
    implementation of the last versions of gw, is required to create a
    bridge that translates old instructions into new redis store
    instructions.

    Related Issue

    TT-11443

    Motivation and Context

    How This Has Been Tested

    Screenshots (if appropriate)

    Types of changes

    • Bug fix (non-breaking change which fixes an issue)
    • New feature (non-breaking change which adds functionality)
    • Breaking change (fix or feature that would cause existing
      functionality to change)
    • Refactoring or add test (improvements in base code or adds test
      coverage to functionality)

    Checklist

    • I ensured that the documentation is up to date
    • I explained why this PR updates go.mod in detail with reasoning
      why it's required
    • I would like a code coverage CI quality gate exception and have
      explained why

    Type

    enhancement


    Description

    • Introduced a redis_shim.go file to ensure compatibility with
      goplugins importing the Redis implementation from previous versions.
      This acts as a bridge translating old Redis instructions to new Redis
      store instructions, maintaining backward compatibility without breaking
      existing implementations.

    Changes walkthrough

    Relevant files
    Enhancement
    redis_shim.go
    Introduction of Redis Shim for Go Plugins Compatibility   

    storage/redis_shim.go

  • Introduced a new file redis_shim.go for creating a bridge between old
    and new Redis store instructions.
  • +1/-0     

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools
    and their descriptions
    Triggered by: push (@sredxny)
    Execution page

    @github-actions

    github-actions Bot commented Mar 7, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    diff --git a/storage/redis_shim_test.go b/storage/redis_shim_test.go
    index 8ff72dc..f0f1f6d 100644
    --- a/storage/redis_shim_test.go
    +++ b/storage/redis_shim_test.go
    @@ -5,8 +5,9 @@ import (
     	"testing"
     	"time"
     
    -	"github.com/TykTechnologies/tyk/config"
     	"github.com/stretchr/testify/assert"
    +
    +	"github.com/TykTechnologies/tyk/config"
     )
     
     func TestNewRedisController(t *testing.T) {

    Please look at the run or in the Checks tab.

    1 similar comment
    @github-actions

    github-actions Bot commented Mar 7, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    diff --git a/storage/redis_shim_test.go b/storage/redis_shim_test.go
    index 8ff72dc..f0f1f6d 100644
    --- a/storage/redis_shim_test.go
    +++ b/storage/redis_shim_test.go
    @@ -5,8 +5,9 @@ import (
     	"testing"
     	"time"
     
    -	"github.com/TykTechnologies/tyk/config"
     	"github.com/stretchr/testify/assert"
    +
    +	"github.com/TykTechnologies/tyk/config"
     )
     
     func TestNewRedisController(t *testing.T) {

    Please look at the run or in the Checks tab.

    @github-actions

    github-actions Bot commented Mar 7, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    diff --git a/storage/redis_shim_test.go b/storage/redis_shim_test.go
    index 8ff72dc..f0f1f6d 100644
    --- a/storage/redis_shim_test.go
    +++ b/storage/redis_shim_test.go
    @@ -5,8 +5,9 @@ import (
     	"testing"
     	"time"
     
    -	"github.com/TykTechnologies/tyk/config"
     	"github.com/stretchr/testify/assert"
    +
    +	"github.com/TykTechnologies/tyk/config"
     )
     
     func TestNewRedisController(t *testing.T) {

    Please look at the run or in the Checks tab.

    1 similar comment
    @github-actions

    github-actions Bot commented Mar 7, 2024

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    diff --git a/storage/redis_shim_test.go b/storage/redis_shim_test.go
    index 8ff72dc..f0f1f6d 100644
    --- a/storage/redis_shim_test.go
    +++ b/storage/redis_shim_test.go
    @@ -5,8 +5,9 @@ import (
     	"testing"
     	"time"
     
    -	"github.com/TykTechnologies/tyk/config"
     	"github.com/stretchr/testify/assert"
    +
    +	"github.com/TykTechnologies/tyk/config"
     )
     
     func TestNewRedisController(t *testing.T) {

    Please look at the run or in the Checks tab.

    @sredxny
    sredxny enabled auto-merge (squash) March 7, 2024 20:06
    @sonarqubecloud

    sonarqubecloud Bot commented Mar 7, 2024

    Copy link
    Copy Markdown

    @sredxny
    sredxny merged commit 33ebe8b into master Mar 7, 2024
    @sredxny
    sredxny deleted the shim-for-goplugins-using-redis branch March 7, 2024 20:43
    @sredxny

    sredxny commented Mar 7, 2024

    Copy link
    Copy Markdown
    Contributor Author

    /release to release-5.3

    @tykbot

    tykbot Bot commented Mar 7, 2024

    Copy link
    Copy Markdown

    Working on it! Note that it can take a few minutes.

    @tykbot

    tykbot Bot commented Mar 7, 2024

    Copy link
    Copy Markdown

    Still working...

    tykbot Bot pushed a commit that referenced this pull request Mar 7, 2024
    …6096)
    
    ## **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
    In order to not break compatibility of goplugins importing the redis
    implementation of the last versions of gw, is required to create a
    bridge that translates old instructions into new redis store
    instructions.
    
    ## Related Issue
    
    TT-11443
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- Please describe in detail how you tested your changes -->
    <!-- Include details of your testing environment, and the tests -->
    <!-- you ran to see how your change affects other areas of the code,
    etc. -->
    <!-- This information is helpful for reviewers and QA. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- What types of changes does your code introduce? Put an `x` in all
    the boxes that apply: -->
    
    - [ ] Bug fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to change)
    - [ ] Refactoring or add test (improvements in base code or adds test
    coverage to functionality)
    
    ## Checklist
    
    <!-- Go over all the following points, and put an `x` in all the boxes
    that apply -->
    <!-- If there are no documentation updates required, mark the item as
    checked. -->
    <!-- Raise up any additional concerns not covered by the checklist. -->
    
    - [ ] I ensured that the documentation is up to date
    - [ ] I explained why this PR updates go.mod in detail with reasoning
    why it's required
    - [ ] I would like a code coverage CI quality gate exception and have
    explained why
    
    
    ___
    
    ## **Type**
    enhancement
    
    
    ___
    
    ## **Description**
    - Introduced a `redis_shim.go` file to ensure compatibility with
    goplugins importing the Redis implementation from previous versions.
    This acts as a bridge translating old Redis instructions to new Redis
    store instructions, maintaining backward compatibility without breaking
    existing implementations.
    
    
    ___
    
    
    
    ## **Changes walkthrough**
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>redis_shim.go</strong><dd><code>Introduction of Redis
    Shim for Go Plugins Compatibility</code>&nbsp; &nbsp; </dd></summary>
    <hr>
    
    storage/redis_shim.go
    <li>Introduced a new file <code>redis_shim.go</code> for creating a
    bridge between old <br>and new Redis store instructions.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6096/files#diff-b175b26ea2c5bc6f5eb907f40acdaea3f4d100a2bbbf50a12fdb64abdb57a040">+1/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr></tr></tbody></table>
    
    ___
    
    > ✨ **PR-Agent usage**:
    >Comment `/help` on the PR to get a list of all available PR-Agent tools
    and their descriptions
    
    (cherry picked from commit 33ebe8b)
    @sredxny

    sredxny commented Mar 7, 2024

    Copy link
    Copy Markdown
    Contributor Author

    /release to release-5.3.0

    @tykbot

    tykbot Bot commented Mar 7, 2024

    Copy link
    Copy Markdown

    @sredxny Seems like there is conflict and it require manual merge.

    @tykbot

    tykbot Bot commented Mar 7, 2024

    Copy link
    Copy Markdown

    Working on it! Note that it can take a few minutes.

    tykbot Bot pushed a commit that referenced this pull request Mar 7, 2024
    …6096)
    
    ## **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
    In order to not break compatibility of goplugins importing the redis
    implementation of the last versions of gw, is required to create a
    bridge that translates old instructions into new redis store
    instructions.
    
    ## Related Issue
    
    TT-11443
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- Please describe in detail how you tested your changes -->
    <!-- Include details of your testing environment, and the tests -->
    <!-- you ran to see how your change affects other areas of the code,
    etc. -->
    <!-- This information is helpful for reviewers and QA. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- What types of changes does your code introduce? Put an `x` in all
    the boxes that apply: -->
    
    - [ ] Bug fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to change)
    - [ ] Refactoring or add test (improvements in base code or adds test
    coverage to functionality)
    
    ## Checklist
    
    <!-- Go over all the following points, and put an `x` in all the boxes
    that apply -->
    <!-- If there are no documentation updates required, mark the item as
    checked. -->
    <!-- Raise up any additional concerns not covered by the checklist. -->
    
    - [ ] I ensured that the documentation is up to date
    - [ ] I explained why this PR updates go.mod in detail with reasoning
    why it's required
    - [ ] I would like a code coverage CI quality gate exception and have
    explained why
    
    
    ___
    
    ## **Type**
    enhancement
    
    
    ___
    
    ## **Description**
    - Introduced a `redis_shim.go` file to ensure compatibility with
    goplugins importing the Redis implementation from previous versions.
    This acts as a bridge translating old Redis instructions to new Redis
    store instructions, maintaining backward compatibility without breaking
    existing implementations.
    
    
    ___
    
    
    
    ## **Changes walkthrough**
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>redis_shim.go</strong><dd><code>Introduction of Redis
    Shim for Go Plugins Compatibility</code>&nbsp; &nbsp; </dd></summary>
    <hr>
    
    storage/redis_shim.go
    <li>Introduced a new file <code>redis_shim.go</code> for creating a
    bridge between old <br>and new Redis store instructions.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6096/files#diff-b175b26ea2c5bc6f5eb907f40acdaea3f4d100a2bbbf50a12fdb64abdb57a040">+1/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr></tr></tbody></table>
    
    ___
    
    > ✨ **PR-Agent usage**:
    >Comment `/help` on the PR to get a list of all available PR-Agent tools
    and their descriptions
    
    (cherry picked from commit 33ebe8b)
    buger added a commit that referenced this pull request Mar 7, 2024
    …ugins importing tyk redis (#6096)
    
    TT-11443 Shim to keep compatibility in goplugins importing tyk redis (#6096)
    
    ## **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
    In order to not break compatibility of goplugins importing the redis
    implementation of the last versions of gw, is required to create a
    bridge that translates old instructions into new redis store
    instructions.
    
    ## Related Issue
    
    TT-11443
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- Please describe in detail how you tested your changes -->
    <!-- Include details of your testing environment, and the tests -->
    <!-- you ran to see how your change affects other areas of the code,
    etc. -->
    <!-- This information is helpful for reviewers and QA. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- What types of changes does your code introduce? Put an `x` in all
    the boxes that apply: -->
    
    - [ ] Bug fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to change)
    - [ ] Refactoring or add test (improvements in base code or adds test
    coverage to functionality)
    
    ## Checklist
    
    <!-- Go over all the following points, and put an `x` in all the boxes
    that apply -->
    <!-- If there are no documentation updates required, mark the item as
    checked. -->
    <!-- Raise up any additional concerns not covered by the checklist. -->
    
    - [ ] I ensured that the documentation is up to date
    - [ ] I explained why this PR updates go.mod in detail with reasoning
    why it's required
    - [ ] I would like a code coverage CI quality gate exception and have
    explained why
    
    
    ___
    
    ## **Type**
    enhancement
    
    
    ___
    
    ## **Description**
    - Introduced a `redis_shim.go` file to ensure compatibility with
    goplugins importing the Redis implementation from previous versions.
    This acts as a bridge translating old Redis instructions to new Redis
    store instructions, maintaining backward compatibility without breaking
    existing implementations.
    
    
    ___
    
    
    
    ## **Changes walkthrough**
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>redis_shim.go</strong><dd><code>Introduction of Redis
    Shim for Go Plugins Compatibility</code>&nbsp; &nbsp; </dd></summary>
    <hr>
    
    storage/redis_shim.go
    <li>Introduced a new file <code>redis_shim.go</code> for creating a
    bridge between old <br>and new Redis store instructions.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6096/files#diff-b175b26ea2c5bc6f5eb907f40acdaea3f4d100a2bbbf50a12fdb64abdb57a040">+1/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr></tr></tbody></table>
    
    ___
    
    > ✨ **PR-Agent usage**:
    >Comment `/help` on the PR to get a list of all available PR-Agent tools
    and their descriptions
    @tykbot

    tykbot Bot commented Mar 7, 2024

    Copy link
    Copy Markdown

    Still working...

    @tykbot

    tykbot Bot commented Mar 7, 2024

    Copy link
    Copy Markdown

    @sredxny Succesfully merged PR

    sredxny added a commit that referenced this pull request Mar 7, 2024
    …ins importing tyk redis (#6096) (#6121)
    
    ## **User description**
    TT-11443 Shim to keep compatibility in goplugins importing tyk redis
    (#6096)
    
    ## **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
    In order to not break compatibility of goplugins importing the redis
    implementation of the last versions of gw, is required to create a
    bridge that translates old instructions into new redis store
    instructions.
    
    ## Related Issue
    
    TT-11443
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- Please describe in detail how you tested your changes -->
    <!-- Include details of your testing environment, and the tests -->
    <!-- you ran to see how your change affects other areas of the code,
    etc. -->
    <!-- This information is helpful for reviewers and QA. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- What types of changes does your code introduce? Put an `x` in all
    the boxes that apply: -->
    
    - [ ] Bug fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to change)
    - [ ] Refactoring or add test (improvements in base code or adds test
    coverage to functionality)
    
    ## Checklist
    
    <!-- Go over all the following points, and put an `x` in all the boxes
    that apply -->
    <!-- If there are no documentation updates required, mark the item as
    checked. -->
    <!-- Raise up any additional concerns not covered by the checklist. -->
    
    - [ ] I ensured that the documentation is up to date
    - [ ] I explained why this PR updates go.mod in detail with reasoning
    why it's required
    - [ ] I would like a code coverage CI quality gate exception and have
    explained why
    
    
    ___
    
    ## **Type**
    enhancement
    
    
    ___
    
    ## **Description**
    - Introduced a `redis_shim.go` file to ensure compatibility with
    goplugins importing the Redis implementation from previous versions.
    This acts as a bridge translating old Redis instructions to new Redis
    store instructions, maintaining backward compatibility without breaking
    existing implementations.
    
    
    ___
    
    
    
    ## **Changes walkthrough**
    <table><thead><tr><th></th><th align="left">Relevant
    
    files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>redis_shim.go</strong><dd><code>Introduction of Redis
    Shim for Go Plugins Compatibility</code>&nbsp; &nbsp; </dd></summary>
    <hr>
    
    storage/redis_shim.go
    <li>Introduced a new file <code>redis_shim.go</code> for creating a
    bridge between old <br>and new Redis store instructions.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6096/files#diff-b175b26ea2c5bc6f5eb907f40acdaea3f4d100a2bbbf50a12fdb64abdb57a040">+1/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr></tr></tbody></table>
    
    ___
    
    > ✨ **PR-Agent usage**:
    >Comment `/help` on the PR to get a list of all available PR-Agent tools
    and their descriptions
    
    
    ___
    
    ## **Type**
    enhancement
    
    
    ___
    
    ## **Description**
    - Introduced `RedisController` to ensure backward compatibility for Go
    plugins using Tyk's Redis connections.
    - Abstracted the retrieval of the connection handler in `RedisCluster`
    to support both `ConnectionHandler` and `RedisController`.
    - Added new tests for the abstracted connection handler retrieval and
    `RedisController` methods.
    
    
    ___
    
    
    
    ## **Changes walkthrough**
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>connection_handler_test.go</strong><dd><code>Refactor
    TestNewConnectionHandler with Helper Function</code>&nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    storage/connection_handler_test.go
    <li>Added a new test helper function
    <code>RunNewConnectionHandlerTest</code> to <br>facilitate testing the
    <code>ConnectionHandler</code>.<br> <li> Modified
    <code>TestNewConnectionHandler</code> to use the new test helper
    function.<br> <br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6121/files#diff-e62d696f1dffcbc88a14ce32af4f6da99f75d2f650020d2efebb0d39bcc97beb">+6/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>redis_cluster.go</strong><dd><code>Abstract Connection
    Handler Retrieval in RedisCluster</code>&nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    storage/redis_cluster.go
    <li>Added a new method <code>getConnectionHandler</code> to abstract the
    retrieval of <br>the connection handler, supporting both
    <code>ConnectionHandler</code> and <br><code>RedisController</code>.<br>
    <li> Modified various methods to use <code>getConnectionHandler</code>
    instead of <br>directly accessing <code>ConnectionHandler</code>.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6121/files#diff-c6add7945790067ff72a544d688ebe904c14ad5b9a522d986aee7c54b1760100">+20/-11</a>&nbsp;
    </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>redis_shim.go</strong><dd><code>Implement
    RedisController for Backward Compatibility</code>&nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    storage/redis_shim.go
    <li>Introduced <code>RedisController</code> struct to act as a shim for
    backward <br>compatibility with Go plugins.<br> <li> Implemented methods
    <code>NewRedisController</code>, <code>ConnectToRedis</code>,
    <code>DisableRedis</code>, <br><code>Connected</code>, and
    <code>WaitConnect</code> in <code>RedisController</code> for managing
    Redis <br>connections.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6121/files#diff-b175b26ea2c5bc6f5eb907f40acdaea3f4d100a2bbbf50a12fdb64abdb57a040">+46/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>redis_cluster_test.go</strong><dd><code>Test for
    Abstracted Connection Handler Retrieval</code>&nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    storage/redis_cluster_test.go
    <li>Added new tests <code>TestRedisClusterGetConnectionHandler</code> to
    verify the <br>correct retrieval of the connection handler through the
    new <br><code>getConnectionHandler</code> method.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6121/files#diff-6881545acab41fff3221454e0efb16302c696ea1217da926f80332a62ef51c71">+31/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>redis_shim_test.go</strong><dd><code>Test Coverage for
    RedisController Methods</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    storage/redis_shim_test.go
    <li>Added tests for <code>RedisController</code> methods including
    <br><code>TestNewRedisController</code>, <code>TestDisableRedis</code>,
    and <code>TestConnectToRedis</code>.<br> <li> Utilized the
    <code>RunNewConnectionHandlerTest</code> helper function in
    <br><code>TestNewRedisController</code>.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6121/files#diff-a2d171e2fb81d93dfafccc4f195ddcccd1faf252b273d1872173012360932bc5">+58/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></td></tr></tr></tbody></table>
    
    ___
    
    > ✨ **PR-Agent usage**:
    >Comment `/help` on the PR to get a list of all available PR-Agent tools
    and their descriptions
    
    Co-authored-by: Sredny M <[email protected]>
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    4 participants