-
Notifications
You must be signed in to change notification settings - Fork 257
Add user-defined checker for server side #502
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
Conversation
Signed-off-by: Xintao <[email protected]>
Signed-off-by: Xintao <[email protected]>
Signed-off-by: Xintao <[email protected]>
Signed-off-by: Xintao <[email protected]>
Post the benchmark here (first is this PR, second is master):
|
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.
Looks good to me. Previously I thought we could use static dispatch (e.g. f: impl Fn(xxx) -> xxx
), but it seems not approachable.
This test add some logic to test
|
Signed-off-by: Xintao <[email protected]>
8141467
to
4b5fa1c
Compare
It seems this library is missing a middleware implementation. This patch is a very limited form of middleware where an abort can be called. The way to make it more of a full middleware is to pass the checker the payload and to allow it to modify the payload (sometimes this is achieved by passing a new payload on to a handler continuation function). |
This seems like a good enough solution until we take the time to create a proper middleware interface. |
let _ = client.say_hello(&req).unwrap(); | ||
let _ = client.say_hello(&req).unwrap(); | ||
|
||
flag_2.store(true, Ordering::Relaxed); |
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 use SeqCst order for both of the atomic operations.
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.
Address comment, BTW any ordering used here is correct.
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.
My mistake, if not use SeqSct
, flag_2.store(true, Ordering::Relaxed);
maybe be reordered behind assert.
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.
LGTM, but I'm not familiar with grpc-rs. @BusyJay can you take a look?
Signed-off-by: Xintao <[email protected]>
Signed-off-by: Xintao <[email protected]>
Signed-off-by: Xintao <[email protected]>
leave some test results with trait object version FYI:
|
Signed-off-by: Xintao <[email protected]>
I do prefer a complete interceptor implementation. But I'm also OK with current design. |
Users can provide custom checker to decide if the grpc call should be aborted in advance or be continued. For operations like check common name, a lot of redundant code can be avoided.
How to implement?
Execute the custom closure provided by the user at the
execute
function fromsrc/call/server.rs
. If the user declares that the grpc call has been aborted, then skip the subsequent grpc handler.Signed-off-by: Xintao [email protected]