You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by Alexander Rukletsov <ru...@gmail.com> on 2015/09/01 16:18:34 UTC
Re: Review Request 37826: Introduced conversion of JSON arrays to
repeated protobufs.
> On Aug. 31, 2015, 6:20 p.m., Michael Park wrote:
> > What do you think of the following API?
> >
> > ```
> > JSON::Value value = ...;
> > auto message = protobuf::parse<T>(value); // message has type Try<T>.
> > auto repeated = protobuf::parse<google::protobuf::RepeatedPtrField<T>>(value); // repeated has type google::protobuf::RepeatedPtrField<T>.
> > ```
> >
> > This makes it so that `parse<T>` always returns `Try<T>`, which I think enables the use of `auto` for the result under our style guide.
> > I think this is a simpler pattern to remember than `parse<T>` -> `Try<T>` and `parseRepeated<T>` -> `Try<google::protobuf::RepeatedPtrField<T>>`.
> >
> > It would take `JSON::Value` rather than `JSON::Array` but check that it is indeed an instance of `JSON::Array`,
> > the same way the existing version takes `JSON::Value` and checks that it's an instance of `JSON::Object`.
> >
> > It also makes the API symmetric with `read()`. We simply do `read<T>` or `read<google::protobuf::RepeatedPtrField<T>>` and it does the right thing.
>
> Michael Park wrote:
> __NOTE:__ `parseRepeated` is actually @joseph's suggestion in the subsequent patch.
>
> In this patch, `parse<T>(value)` returns `Try<T>` and `parse<T>(array)` returns `Try<google::protobuf::RepeatedPtrField<T>>`,
> which I think is just as hard if not harder to intuitively deduce.
>
> What do you think?
>
> Joseph Wu wrote:
> I think that would be good. It seems more verbose, but also a lot more explicit.
>
> (But I can imagine that it might not fit in 80 characters in some places...)
>
> Michael Park wrote:
> > (But I can imagine that it might not fit in 80 characters in some places...)
>
> Yeah, but I think that's fine. It's the case with most uses of `google::protobuf::RepeatedPtrField` across the codebase currently.
> We can also do `using google::protobuf::RepeatedPtrField;` in places where possible.
I think it's a great idea, I'll go for the partial specialization trick.
- Alexander
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/37826/#review97110
-----------------------------------------------------------
On Aug. 27, 2015, 3:38 a.m., Alexander Rukletsov wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/37826/
> -----------------------------------------------------------
>
> (Updated Aug. 27, 2015, 3:38 a.m.)
>
>
> Review request for mesos and Michael Park.
>
>
> Bugs: MESOS-3312
> https://issues.apache.org/jira/browse/MESOS-3312
>
>
> Repository: mesos
>
>
> Description
> -------
>
> See summary.
>
>
> Diffs
> -----
>
> 3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp 57d5fdf45273c620655b44b5f5572290cffa4bf6
>
> Diff: https://reviews.apache.org/r/37826/diff/
>
>
> Testing
> -------
>
> make check (Mac OS 10.10.4)
>
>
> Thanks,
>
> Alexander Rukletsov
>
>