-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Spring Data and update Lettuce support #8
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome change! 💯
|
||
class LettucePublisher(private val connection: StatefulRedisConnection<Any, Any>) : RedisPublisher { | ||
class LettucePublisher(private val commands: RedisCommands<String, String>) : RedisPublisher { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just wondering if the key/value is always String?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For lettuce, the consumer can pass in a Codec
that encodes and decodes what is sent to redis. So you could also have e.g. RedisCommands<ByteArray, ByteArray>
. When using the instance, we need to know what the types are though so we now what we can send and we request an instance that handles Strings. I think it will be that anyways in almost all cases since all default APIs return that.
* Returns the first message published on the given [channel] of the redis available under the [redisURI]. Waits for at | ||
* most five seconds after executing [body] for the message to arrive. | ||
*/ | ||
fun awaitRedisMessage(redisURI: String, channel: String, body: () -> Unit): RedisMessage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! 🤩
This adds support for publishing via the
RedisTemplate
from Spring Data Redis.spring-boot-starter-data-redis
is added as acompileOnly
dependency and thus is not required by consumers which do not use it.Additionally, the
LettucePublisher
now takesRedisCommands
instead of aStatefulRedisConnection
. That is better from what I understand since that is what you actually are supposed to run api calls on.StatefulRedisConnection
is one of multiple options depending on the type of redis instance you are connecting to (there also existsStatefulRedisClusterConnection
for example). This is a breaking change but you couldn't use the publisher before anyways since the generics were<Any, Any>
which is impossible to satisfy so it should be fine.Lastly, I added tests for all publishers with a real redis instance using testcontainers.