-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Async authorization check while creation of producer/consumer #98
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
|
CLA is valid! |
merlimat
left a comment
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, just one blocking issue on the websocket
| return; | ||
| if (service.isAuthorizationEnabled()) { | ||
| final String role = authRole; | ||
| isAuthorized(authRole).thenApply(isAuthorized -> { |
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 would be kind of different, because when the onWebSocketConnect() method completes we should have already done the authorization.
I think we need to block on the isAuhtorized() future, or find a way to have an async onWebSocketConnect()
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.
Yes.. WebSocketHandler.onWebSocketConnect() gets triggered after HttpConnection is established and as soon as HttpConnection is established : client also receives onConnect event.
So, HttpConnection.onCompleted() triggers WebSocketHandler.onWebSocketConnect().
So, by the time WebSocketHandler receives onWebSocketConnect() notification, client has already received onConnect() event.
- However, after fixing websocket-test-case, I have verified that
onWebSocketText(..)gets triggered at server only when server releases thread fromonWebSocketConnect()So, reverting back to sync-zk behavior will make sure that producer will start receiving new messages ononWebSocketText()only after completion of authorization atonWebSocketConnect().
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.
@merlimat addressed the change.
4e29e6c to
1d8dab7
Compare
merlimat
left a comment
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.
👍
* Implemented decompression on consumer side * Fixed format
Motivation
While creating producer/consumer at broker: broker performs sync authorization check (sync zk-policies checks) on client-connection which blocks broker-io threads.
Modifications
Made async-authorization check while creating producer/consumer at broker and websocket server.
Result
No functional change and it will avoid i/o thread blocking while creating producer/consumer.