TT-11443 Shim to keep compatibility in goplugins importing tyk redis#6096
Conversation
|
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" |
|
PR Description updated to latest commit (f05bee6) |
PR Review
Code feedback:✨ Review tool usage guide:Overview: With a configuration file, use the following template:
See the review usage page for a comprehensive guide on using this tool. |
PR Code Suggestions
✨ Improve tool usage guide:Overview: With a configuration file, use the following template:
See the improve usage page for a more comprehensive guide on using this tool. |
💥 CI tests failed 🙈git-statediff --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
💥 CI tests failed 🙈git-statediff --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. |
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
|
API tests result - mongo44-sha256 env: success ✅ User descriptionDescriptionIn order to not break compatibility of goplugins importing the redis Related IssueTT-11443 Motivation and ContextHow This Has Been TestedScreenshots (if appropriate)Types of changes
Checklist
Typeenhancement Description
Changes walkthrough
|
|
API tests result - postgres15-sha256 env: success ✅ User descriptionDescriptionIn order to not break compatibility of goplugins importing the redis Related IssueTT-11443 Motivation and ContextHow This Has Been TestedScreenshots (if appropriate)Types of changes
Checklist
Typeenhancement Description
Changes walkthrough
|
💥 CI tests failed 🙈git-statediff --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. |
…logies/tyk into shim-for-goplugins-using-redis
💥 CI tests failed 🙈git-stateall okPlease look at the run or in the Checks tab. |
|
API tests result - postgres15-murmur64 env: success ✅ User descriptionDescriptionIn order to not break compatibility of goplugins importing the redis Related IssueTT-11443 Motivation and ContextHow This Has Been TestedScreenshots (if appropriate)Types of changes
Checklist
Typeenhancement Description
Changes walkthrough
|
|
API tests result - mongo44-murmur64 env: success ✅ User descriptionDescriptionIn order to not break compatibility of goplugins importing the redis Related IssueTT-11443 Motivation and ContextHow This Has Been TestedScreenshots (if appropriate)Types of changes
Checklist
Typeenhancement Description
Changes walkthrough
|
💥 CI tests failed 🙈git-statediff --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
💥 CI tests failed 🙈git-statediff --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. |
💥 CI tests failed 🙈git-statediff --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
💥 CI tests failed 🙈git-statediff --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. |
|
|
/release to release-5.3 |
|
Working on it! Note that it can take a few minutes. |
|
Still working... |
…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> </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> </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)
|
/release to release-5.3.0 |
|
@sredxny Seems like there is conflict and it require manual merge. |
|
Working on it! Note that it can take a few minutes. |
…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> </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> </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)
…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> </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> </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
|
Still working... |
|
@sredxny Succesfully merged PR |
…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> </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> </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> </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> </td> </tr> <tr> <td> <details> <summary><strong>redis_cluster.go</strong><dd><code>Abstract Connection Handler Retrieval in RedisCluster</code> </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> </td> </tr> <tr> <td> <details> <summary><strong>redis_shim.go</strong><dd><code>Implement RedisController for Backward Compatibility</code> </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> </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> </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> </td> </tr> <tr> <td> <details> <summary><strong>redis_shim_test.go</strong><dd><code>Test Coverage for RedisController Methods</code> </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> </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]>



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
Checklist
Type
enhancement
Description
redis_shim.gofile 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
redis_shim.go
Introduction of Redis Shim for Go Plugins Compatibilitystorage/redis_shim.go
redis_shim.gofor creating a bridge between oldand new Redis store instructions.