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

How do I understand sent or recieved message on streaming? #762

Closed
blackmarllbor0 opened this issue Jul 1, 2024 · 3 comments
Closed

How do I understand sent or recieved message on streaming? #762

blackmarllbor0 opened this issue Jul 1, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@blackmarllbor0
Copy link

En interceptor necesito entender si un mensaje está siendo enviado o recibido, pero realmente no he descubierto cómo. He visto tipos StreaminType, pero estos, según tengo entendido, se encargan de saber de dónde viene el mensaje, no si se envía o no. ¿Alguien sabe cómo obtener esta información?

@blackmarllbor0 blackmarllbor0 added the enhancement New feature or request label Jul 1, 2024
@jhump
Copy link
Member

jhump commented Jul 2, 2024

In an interceptor I need to understand if a message is being sent or received, but I haven't really figured out how. I have seen StreamingType types, but these, as I understand it, are responsible for knowing where the message comes from, not whether it is sent or not. Does anyone know how to obtain this information?

In an interceptor, you can look at request.Spec().IsClient to see if the interceptor is called in a client (if false, the interceptor is being called in a server handler). In a client, the request message is being "sent" and the response is "received". In a server handler, it's the opposite: the request message is "received" and the response is "sent".

For the stream interceptor functions, you'll have (and can wrap) a StreamingClientConn or StreamingHandlerConn (depending on whether the interceptor is being called in a client or a server handler). These have methods named Send and Receive which make the transmission direction very clear.

@blackmarllbor0
Copy link
Author

@jhump can you please elaborate on what exactly you meant by streamin?

@jhump
Copy link
Member

jhump commented Jul 3, 2024

@jhump can you please elaborate on what exactly you meant by streamin?

When I say "stream interceptor functions", I am referring to the WrapStreamingClient and WrapStreamingHandler methods of Interceptor.

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

No branches or pull requests

2 participants