mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Park" <mcyp...@gmail.com>
Subject Re: Review Request 37826: Introduced conversion of JSON arrays to repeated protobufs.
Date Mon, 31 Aug 2015 18:20:58 GMT

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/37826/#review97110
-----------------------------------------------------------


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


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
> 
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message