-
Notifications
You must be signed in to change notification settings - Fork 520
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
Invoke custom commands from custom proc/txn #597
base: main
Are you sure you want to change the base?
Conversation
c1391fc
to
f0450e4
Compare
ba58f56
to
ce69dfe
Compare
Moved custom procs, txn to test project.
5ed4735
to
3c6b5a9
Compare
@@ -12,25 +12,40 @@ internal sealed class CustomCommandManagerSession | |||
{ | |||
readonly CustomCommandManager customCommandManager; | |||
public readonly (CustomTransactionProcedure, int)[] sessionTransactionProcMap; | |||
public readonly CustomProcedure[] sessionCustomProcMap; |
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.
These 2 arrays can be made private, right? Also, might be good to add a comment that the arrays are indexed by the IDs.
|
||
public CustomProcedure GetCustomProcedure(int id, RespServerSession respServerSession) | ||
{ | ||
if (sessionCustomProcMap[id] == null) |
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.
Should we add a bounds check for the id? Also, are we sure we want to throw if the id is not found? Maybe just return null?
var sbKey = key.SpanByte; | ||
|
||
var inputArg = customCommand.expirationTicks > 0 ? DateTimeOffset.UtcNow.Ticks + customCommand.expirationTicks : customCommand.expirationTicks; | ||
var sessionParseState = new SessionParseState(); |
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.
No need to instantiate a new parse state, you can use the session's parseState field.
|
||
// Prepare input | ||
var header = new RespInputHeader(customObjCommand.GetObjectType()) { SubId = customObjCommand.subid }; | ||
var sessionParseState = new SessionParseState(); |
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.
Same here, no need to instantiate
Adds ability to invoke custom raw string commands and object commands from within custom procedures and transactions.