grpc::ServerUnaryReactor - Callback processing

583 views
Skip to first unread message

Brent Edwards

unread,
Jan 26, 2022, 5:29:01 PM1/26/22
to grpc.io
I am trying to implement grpc callback service and have derived my callback handler class from ServerUnaryReactor.

class AuthorisationCallbackHandler : public grpc::ServerUnaryReactor

As part of request processing we return grpc::ServerUnaryReactor to grpc server/service.

The destructor for AuthorisationCallbackHandler is never called so I assume we are still responsible for its clean up.

Is this correct and how to we know grpc is finished with it?

Is that what grpc::ServerUnaryReactor::OnDone is for?

Viktor Khristenko

unread,
Jan 27, 2022, 4:16:12 PM1/27/22
to grpc.io
Hi ,

It's for streaming, but the same idea applies. 

Also note that you could use default reactor for unary calls (unless you really need to impl your own one).
`ctx->DefaultReactor()`, then you do not have to worry about this clean up. Although this applies only for unary calls, but this is what you are asking for...

In short, you can delete after OnDone was triggered for server reactor

Hope that helps!

VK

Reply all
Reply to author
Forward
0 new messages