grpc-dart icon indicating copy to clipboard operation
grpc-dart copied to clipboard

How to write a chain of interceptors

Open steeling opened this issue 4 years ago • 7 comments

From the comments in lib/src/server/interceptor.dart:

/// A gRPC Interceptor.
///
/// An interceptor is called before the corresponding [ServiceMethod] invocation.
/// If the interceptor returns a [GrpcError], the error will be returned as a response and [ServiceMethod] wouldn't be called.
/// If the interceptor throws [Exception], [GrpcError.internal] with exception.toString() will be returned.
/// If the interceptor returns null, the corresponding [ServiceMethod] of [Service] will be called.

How are we supposed to write interceptors? A) There's no examples, but B) these seem to differ from interceptors in other languages, particularly go.

In go, I can chain my interceptors so that i can implement generic things like logging. Since the dart version never calls the service function, I can't inspect the return result, meaning it's only good for gating functionality, and not the true interceptors provided in other languages.

steeling avatar Jan 21 '21 01:01 steeling

Looks like a dup of https://github.com/grpc/grpc-dart/issues/140

@mraleph how would you go about deprecating the other feature? Would you add a new interceptor, ie: typedef Interceptorv2? and keep both compatible for now (depreacting the original)

steeling avatar Jan 21 '21 01:01 steeling

Yes, most likely the way to roll it out is to add an API on the side and mark current API as depcrecated.

mraleph avatar Jan 22 '21 14:01 mraleph

@mraleph just to confirm I wasn’t sure reading your comment but was that something you were actively planning to do or exists on a roadmap somewhere? ✌️

mhoad avatar Jun 11 '21 06:06 mhoad

@mhoad this package does not have any roadmap or anybody working on it, it's more or less in the maintenance mode at the moment. I am happy to review and land PRs and discuss design, but I don't really have time for more than that.

mraleph avatar Jun 11 '21 07:06 mraleph

Just wanted to check back in on this. Was I correct in that this library might have a new owner at the moment as one of the new hires on the team?

mark-dropbear avatar Apr 14 '22 19:04 mark-dropbear

Just wanted to check back in on this. Was I correct in that this library might have a new owner at the moment as one of the new hires on the team?

Not yet. They are currently extinguishing fires over in the protobuf repo.

mraleph avatar Apr 19 '22 08:04 mraleph

All good! I saw some of the great work they were doing over there already. On a long enough timescale and all that :)

mark-dropbear avatar Apr 20 '22 08:04 mark-dropbear