-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add overloads for XAddOptions in StreamOperations #2936
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 overloads for XAddOptions in StreamOperations #2936
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.
please review this pr and if this needs some changes, I will be happy to amend it!
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.
the reason why I wrote somewhat verbose method in here is
unlike JedisStreamCommands
or LettuceStreamCommands
which both have a method accepting (MapRecord<byte[], byte[], byte[]> record, XAddOptions options)
xAdd(Publisher commands) in LettuceReactiveStreamCommands
expects that Publisher already has variables of XAddOptions
.
ex) maxlen, isApproxiateTrimming...
so I placed the decapsulation of XAddOptions here.
I thought of changing AddStreamRecord to have variable priavte final XAddOptions options
so that LettuceReactiveStreamCommands
can delegate the decapsulation to other class
but I thought this exceeds the scope of this issue.
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.
removed typo
5b50789
to
f4755e5
Compare
I have a question regarding XAddOptions. While I was writing tests, I found out that
XAddOptions options = XAddOptions.maxlen(-1); redisTemplate.opsForStream("myStream", Map.of("key", "value), options);
this executes and the result being maxlen option just not applied.
This is becasue in XAddOptions
in RedisStreamCommands
's hasMaxlen() method.
public boolean hasMaxlen() { return maxlen != null && maxlen > 0; }
also same with AddStreamRecord
in ReactiveStreamCommands
.
this method just ignores minus value of maxlen.
As for redis, if user makes maxlen -1, An error occurs.
image
If we make hasMaxlen()
public boolean hasMaxlen() { return maxlen != null }
image
For Lettuce, Lettuce’s XAddArgs has LettuceAssert which asserts the value of maxlen.
image
For Jedis, Jedis’s XAddParams doesn’t have assertions. So redis server throws an exception.
IMO, it is better to alert user by throwing exception than the result just not applied because it is hard to find and also realise the problem.
The reason why I'm asking this question, instead incorporating into PR I created was I was not sure if this is intended.
If this needs to be fixed, I will make adjustment in this PR and push it again. If not, please let me know. Thank you.
e667f58
to
3130562
Compare
3130562
to
f320d66
Compare
kkocel
commented
Jul 31, 2024
@jinkshower looks good to me :)
Hello, @christophstrobl. Could you please take some time to review this PR when you have a moment? I'm not entirely confident about some of the changes I've made, and your feedback would be incredibly valuable to me.
@jinkshower thanks for the heads up.
Add new method to BoundStreamOperations and remove add accepting a Publisher. Original Pull Request: #2936
@jinkshower thank you for your contribution. Merged to main development line.
Regarding the maxlen please open a new issue.
Uh oh!
There was an error while loading. Please reload this page.
Closes #2915
After this change, the client can use
XAddOptions
as an additional parameter foropsForStream.add()
TO-BE