Sorry for pushing up manually, but I really want to know if there's method to do it like in Python.
Yes I can do it by wrapping a `ClientStream`, however it create a new instance in every call that I needs to use a pointer or somehow to manage together with my `ClientInterceptor`, which seems a bit dirty thanks. 温明浩 在 2022年4月6日 星期三上午11:03:45 [UTC+8] 的信中寫道: > Hi amits, > > Sorry for the late replay. > I have write a minimal example to express my question. > https://gist.github.com/codingbaobao/f89291866024a97c1b476a682f82c029 > > The main purpose is trying to manage request&response header in > interceptor, in order to share come context or status. > I have try metadata.FromIncomingContext() and seems empty. > Is there have any method to send request header first without sending > payload? > Since this concept is documented in here: > https://grpc.io/docs/what-is-grpc/core-concepts/#unary-rpc > Or, any method that can let me access response header without wrapping a > ClientStream? > thanks! > [email protected] 在 2022年4月1日 星期五上午5:49:54 [UTC+8] 的信中寫道: > >> Have you tried the metadata.FromIncomingContext() function? >> >> You haven't shared your example code - i think that will be useful for >> others to help you. >> >> >> >> >> >> On Thursday, March 31, 2022 at 3:44:02 PM UTC+11 [email protected] wrote: >> >>> Hi all, >>> >>> Currently I have a rpc like this: >>> *rpc SayHello (HelloRequest) returns (stream HelloReply) {}* >>> >>> Now I add a StreamClientInterceptor to catch response initial metadata, >>> but it block forever, and server shows that no request get, at least not >>> into the rpc function. >>> >>> The interceptor is similar to this example: >>> >>> https://github.com/grpc/grpc-go/blob/master/examples/features/interceptor/client/main.go#L90 >>> and I just add a line under L107 : >>> *responseMeta, err := s.Header() //<-- block here* >>> >>> Im sure that I can done in Python code, which is implement similar to: >>> >>> https://github.com/grpc/grpc/blob/master/examples/python/interceptors/headers/generic_client_interceptor.py#L33 >>> and adds code under L37: >>> *print(response_it.initial_metadata())* >>> >>> Can anyone tell me what is wrong of my Golang code? >>> Actually I can get header by wrapping grpc.ClientStream and received in >>> RecvMsg() >>> and I observed that I can only get header after SendMsg, but it doesn't >>> make sense :( >>> >> -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/cc019314-f724-415b-b4b5-176c02b24837n%40googlegroups.com.
