Skip to content

Conversation

Jozott00
Copy link

@Jozott00 Jozott00 commented Sep 18, 2025

Subsystem
gRPC

Problem Description
A main feature of all gRPC libraries is their interceptor API.
We want a Kotlin idiomatic simple-to-use interceptor API (for client and server) that allows users to implement things like authentication, logging or tracing.

Solution
This PR adds a convenient Kotlin idiomatic interceptor API.

E.g. a (over-simplified) server-side authorization interceptor could look like this

val myAuthInterceptor = object : ServerInterceptor {
    override fun <Request, Response> ServerCallScope<Request, Response>.intercept(request: Flow<Request>): Flow<Response> =
        flow {
            val authorized = mySuspendAuth(requestHeaders)
            if (!authorized) {
                close(Status(StatusCode.PERMISSION_DENIED, "Not authorized"))
            }

            proceedUnmodified(request)
        }
     }

@Jozott00 Jozott00 self-assigned this Sep 18, 2025
@Jozott00 Jozott00 added the feature New feature or request label Sep 18, 2025
@Jozott00 Jozott00 requested a review from Mr3zee September 18, 2025 13:31
@Jozott00 Jozott00 marked this pull request as ready for review September 18, 2025 13:31
Copy link
Member

@Mr3zee Mr3zee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I have some comments nitpicking some details, mostly DSL, but everything else is well designed

and btw kDocs are really good there, quite easy to read and understand

@Jozott00 Jozott00 requested a review from Mr3zee September 19, 2025 17:45
Copy link
Member

@Mr3zee Mr3zee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@morki
Copy link

morki commented Sep 22, 2025

Will there be an interceptor feature in KRPC too? It would be really handy for the same use cases as presented here.

@Mr3zee
Copy link
Member

Mr3zee commented Sep 22, 2025

@morki in some sort, yes, though later, we only maintain kRPC now, until we finish with gRPC (which is not much else to do, but still will take a couple of months)

Signed-off-by: Johannes Zottele <[email protected]>
Signed-off-by: Johannes Zottele <[email protected]>
Signed-off-by: Johannes Zottele <[email protected]>
Signed-off-by: Johannes Zottele <[email protected]>
Signed-off-by: Johannes Zottele <[email protected]>
Signed-off-by: Johannes Zottele <[email protected]>
Signed-off-by: Johannes Zottele <[email protected]>
Signed-off-by: Johannes Zottele <[email protected]>
Signed-off-by: Johannes Zottele <[email protected]>
Signed-off-by: Johannes Zottele <[email protected]>
Signed-off-by: Johannes Zottele <[email protected]>
Signed-off-by: Johannes Zottele <[email protected]>
@Jozott00 Jozott00 merged commit aec6379 into grpc-common Sep 29, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants