Async authorization check while creation of producer/consumer - #98
Conversation
|
CLA is valid! |
merlimat
left a comment
There was a problem hiding this comment.
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.
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.
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().
4e29e6c to
1d8dab7
Compare
* 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.