Skip to content
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

Implicit Context #2

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Implicit Context #2

wants to merge 10 commits into from

Conversation

gnossen
Copy link

@gnossen gnossen commented Oct 4, 2019

This PR is a an example illustrating a proposal for how to handle distributed context within the gRPC Python asyncio API.

@pfreixes
@lidizheng
@euroelessar

@gnossen
Copy link
Author

gnossen commented Oct 4, 2019

CC @liyanhui1228 For an opinion on how this looks from the perspective of a contributor to OpenCensus.
CC @rnburn For the same from Opentracing.

See #1 (comment) and the following conversation for context on this discussion.

@liyanhui1228
Copy link

CC @liyanhui1228 For an opinion on how this looks from the perspective of a contributor to OpenCensus.
CC @rnburn For the same from Opentracing.

See #1 (comment) and the following conversation for context on this discussion.

cc @c24t for OpenCensus Python

"""
# NOTE: The return type here closely mirrors the original
# GenericClientInterceptor interface. We may want to clean it up.
def intercept_call(client_call_details: grpc.aio.ClientCallDetails,
Copy link

Choose a reason for hiding this comment

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

async?

client_call_details.credentials)
return new_client_call_details, request_generator, None

return grpc.aio.generic_client_interceptor(intercept_call)
Copy link

Choose a reason for hiding this comment

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

just asking, generic_client_interceptor would provide a way for creating an interceptor without needing to implement a derivated interceptor class? does it exist in the current API?


async def CreateUser(self,
request: user_pb2.CreateUserRequest,
context: grpc.aio.ServicerContext):
Copy link

Choose a reason for hiding this comment

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

It would be nice to have also an example of how the timeout could be modified by the server evaluating the timeout provided by the context, for making a decision if the timeout needs to be modified or if it does not exist adding it.

stack from server to client. But without middleware installed, *nothing* is
propagated by default, except timeout and cancellation, which are handled by the
gRPC library itself using `ContextVar` objects managed by the `gRPC` library
itself.
Copy link

Choose a reason for hiding this comment

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

we are on the same page!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants