Re: [grpc-io] How to intercept every client request and add some attributes to it and collect at the server end

2018-08-06 Thread Josh Humphries
On Mon, Aug 6, 2018 at 3:13 PM shailendra kumar 
wrote:

> Thanks Josh.
> I tried with ClientInterceptor and ServerInterceptor.   Its working fine.
> I have implemented in java.
> Will this interceptor work for http request through postman ?
>

I assume you are using grpc-gateway (or something very similar) in front of
your service, to proxy JSON+HTTP 1.1 to gRPC. Is that correct? If so, yes,
the interceptor will be invoked for these requests.


> e.g -  for path /v1/health
> will these interceptor invoke the request ??
>

Sorry, I don't understand the question. If you are asking whether the
interceptor will be invoked for these requests, see previous answer. If
not, do you mind re-wording, perhaps adding a little more detail?

> rpc healthCheck(google.protobuf.Empty) returns (HealthCheckResponse) {
> option (google.api.http) = {
> get: "/v1/health"
> };
> }
>
>
> On Sun, Aug 5, 2018 at 5:23 PM, Josh Humphries 
> wrote:
>
>> I think several of the languages support the interceptor pattern (I am
>> quite familiar with the Java and Go runtime libraries, which do). This
>> allows you to register a client interceptor that will get to see every RPC.
>> (Intercepting streaming RPCs in Go is a bit more complicated due to having
>> a different interface than the interceptor for unary RPCs.)
>>
>> When you have cross-cutting attributes to associate with every RPC,
>> metadata is probably the way to go. So the interceptor could add the
>> attributes you mention as request metadata. For Go, you'd probably need to
>> have this data stored in a context.Context, which the interceptor will
>> query and then store in request metadata. For Java, there is also a context
>> type, but it uses thread-local storage (so it can be easier to interact
>> with and does not require you to explicitly pass the context to/through
>> every function).
>>
>> 
>> *Josh Humphries*
>> jh...@bluegosling.com
>>
>>
>>
>> On Sun, Aug 5, 2018 at 4:11 AM shailendra kumar 
>> wrote:
>>
>>>
>>> Whenever client call to server, i want to add some attribute like
>>> account, accountHolder, accountLocation  and their values along with client
>>> request. At the server side, i want to collect these info. Please suggest
>>> for grpc call as well as rest call
>>>
>>> --
>>> 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 grpc-io+unsubscr...@googlegroups.com.
>>> To post to this group, send email to grpc-io@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/grpc-io.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/grpc-io/3e68e3d6-74d2-4082-90b0-5361bd4238d0%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>

-- 
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 grpc-io+unsubscr...@googlegroups.com.
To post to this group, send email to grpc-io@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CAO78j%2BL-WPkVP23o3zaxT%3Dr9NwHB73PthdMKT2auszXtk1BWzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [grpc-io] How to intercept every client request and add some attributes to it and collect at the server end

2018-08-06 Thread shailendra kumar
Thanks Josh.
I tried with ClientInterceptor and ServerInterceptor.   Its working fine.
I have implemented in java.
Will this interceptor work for http request through postman ?
e.g -  for path /v1/health
will these interceptor invoke the request ??

rpc healthCheck(google.protobuf.Empty) returns (HealthCheckResponse) {
option (google.api.http) = {
get: "/v1/health"
};
}


On Sun, Aug 5, 2018 at 5:23 PM, Josh Humphries 
wrote:

> I think several of the languages support the interceptor pattern (I am
> quite familiar with the Java and Go runtime libraries, which do). This
> allows you to register a client interceptor that will get to see every RPC.
> (Intercepting streaming RPCs in Go is a bit more complicated due to having
> a different interface than the interceptor for unary RPCs.)
>
> When you have cross-cutting attributes to associate with every RPC,
> metadata is probably the way to go. So the interceptor could add the
> attributes you mention as request metadata. For Go, you'd probably need to
> have this data stored in a context.Context, which the interceptor will
> query and then store in request metadata. For Java, there is also a context
> type, but it uses thread-local storage (so it can be easier to interact
> with and does not require you to explicitly pass the context to/through
> every function).
>
> 
> *Josh Humphries*
> jh...@bluegosling.com
>
>
>
> On Sun, Aug 5, 2018 at 4:11 AM shailendra kumar 
> wrote:
>
>>
>> Whenever client call to server, i want to add some attribute like
>> account, accountHolder, accountLocation  and their values along with client
>> request. At the server side, i want to collect these info. Please suggest
>> for grpc call as well as rest call
>>
>> --
>> 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 grpc-io+unsubscr...@googlegroups.com.
>> To post to this group, send email to grpc-io@googlegroups.com.
>> Visit this group at https://groups.google.com/group/grpc-io.
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/grpc-io/3e68e3d6-74d2-4082-90b0-5361bd4238d0%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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 grpc-io+unsubscr...@googlegroups.com.
To post to this group, send email to grpc-io@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CABCQYsQFteoo%2BqGgZGeTLTD8e2Zfq_zTfUFPcH4iv5Jk6qsJ_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [grpc-io] How to intercept every client request and add some attributes to it and collect at the server end

2018-08-05 Thread Josh Humphries
I think several of the languages support the interceptor pattern (I am
quite familiar with the Java and Go runtime libraries, which do). This
allows you to register a client interceptor that will get to see every RPC.
(Intercepting streaming RPCs in Go is a bit more complicated due to having
a different interface than the interceptor for unary RPCs.)

When you have cross-cutting attributes to associate with every RPC,
metadata is probably the way to go. So the interceptor could add the
attributes you mention as request metadata. For Go, you'd probably need to
have this data stored in a context.Context, which the interceptor will
query and then store in request metadata. For Java, there is also a context
type, but it uses thread-local storage (so it can be easier to interact
with and does not require you to explicitly pass the context to/through
every function).


*Josh Humphries*
jh...@bluegosling.com



On Sun, Aug 5, 2018 at 4:11 AM shailendra kumar 
wrote:

>
> Whenever client call to server, i want to add some attribute like account,
> accountHolder, accountLocation  and their values along with client request.
> At the server side, i want to collect these info. Please suggest for grpc
> call as well as rest call
>
> --
> 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 grpc-io+unsubscr...@googlegroups.com.
> To post to this group, send email to grpc-io@googlegroups.com.
> Visit this group at https://groups.google.com/group/grpc-io.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/grpc-io/3e68e3d6-74d2-4082-90b0-5361bd4238d0%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 grpc-io+unsubscr...@googlegroups.com.
To post to this group, send email to grpc-io@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CAO78j%2B%2BrfODyK5-Bfn5p0HZToibFKBLPvx-Nt6a5un5%3DYsO19A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[grpc-io] How to intercept every client request and add some attributes to it and collect at the server end

2018-08-05 Thread shailendra kumar

Whenever client call to server, i want to add some attribute like account, 
accountHolder, accountLocation  and their values along with client request. 
At the server side, i want to collect these info. Please suggest for grpc 
call as well as rest call

-- 
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 grpc-io+unsubscr...@googlegroups.com.
To post to this group, send email to grpc-io@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/3e68e3d6-74d2-4082-90b0-5361bd4238d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.