I am creating an RPC service and I want to know how I would declare an RPC
method that returns (in my case) an optional response. The way the rpc is
defined below means that it always returns a PageResponse. I suppose I
could check to see if the page_title in the response has not been set but I
am sure that there is a more elegant solution to this (probably a
combination of 'empty' and 'oneof'?
Also in a somewhat related question, Is it possible to change the rpc to
support some sort of push data? I have a cache managed by a GWService and
I would like the grpc client to act like a listener for updates to this
cache - other than polling for changes, I am not sure how I would do this.
Is that what streaming is for?
Thanks in advance
John
//! Request a page object from the cache
message PageRequest {
string page_title = 1;
}
//! cache page wrapper
message PageResponse {
// embed the page title in case we decide to stream
// many of these back to back using the streaming API
string page_title = 1;
Page page_data = 2;
}
//! Gateway Service.
service GWService {
. . .
// request a specific
rpc GetPage(PageRequest) returns (PageResponse) {}
}
--
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 post to this group, send email to [email protected].
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/4e8ac2d7-2811-4098-af3a-c8ea34cb04bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.