You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mesos.apache.org by "Benjamin Mahler (JIRA)" <ji...@apache.org> on 2016/04/19 03:06:25 UTC

[jira] [Updated] (MESOS-2638) Add support for Optional parameters to protobuf handlers to wrap option fields

     [ https://issues.apache.org/jira/browse/MESOS-2638?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Mahler updated MESOS-2638:
-----------------------------------
    Description: 
We currently don't have a way to install a protobuf handler for an option field where the handler takes an Optional parameter of the 'option' field in the protobuf message. The goal is to be able to do:
{code:title=example|borderStyle=solid}
message Person {
  required string name = 1;
  option uint32_t age = 2; 
}

void person(const std::string& name, const Option<uint32_t>& age) 
{
  if (age.isSome()) { ... }
}

install<Person>(
    person, 
    &Person::name,
    &Person::age); 
{code}
We can then use this to test whether the field was provided, as opposed to capturing a reference to a default constructed value of the the type.

For now, the workaround is to use the take the entire message in the handler:

{code}
void person(const Person& person)
{
  if (person.has_age()) { ... }
}

install<Person>(person);
{code}

  was:
We currently don't have a way to install a protobuf handler for an option field where the handler takes an Optional parameter of the 'option' field in the protobuf message. The goal is to be able to do:
{code:title=example|borderStyle=solid}
message Person {
  required string name = 1;
  option uint32_t age = 2; 
}

void person(const std::string& name, const Option<uint32_t>& age) 
{
  if (age.isKnown()) {
    ...
  }
}

install<Person>(person,
  &Person::name,
  &Person::age); 
{code}
We can then use this to test whether the field was provided, as opposed to capturing a reference to a default constructed value of the the type.


> Add support for Optional parameters to protobuf handlers to wrap option fields
> ------------------------------------------------------------------------------
>
>                 Key: MESOS-2638
>                 URL: https://issues.apache.org/jira/browse/MESOS-2638
>             Project: Mesos
>          Issue Type: Improvement
>          Components: libprocess
>            Reporter: Joris Van Remoortere
>
> We currently don't have a way to install a protobuf handler for an option field where the handler takes an Optional parameter of the 'option' field in the protobuf message. The goal is to be able to do:
> {code:title=example|borderStyle=solid}
> message Person {
>   required string name = 1;
>   option uint32_t age = 2; 
> }
> void person(const std::string& name, const Option<uint32_t>& age) 
> {
>   if (age.isSome()) { ... }
> }
> install<Person>(
>     person, 
>     &Person::name,
>     &Person::age); 
> {code}
> We can then use this to test whether the field was provided, as opposed to capturing a reference to a default constructed value of the the type.
> For now, the workaround is to use the take the entire message in the handler:
> {code}
> void person(const Person& person)
> {
>   if (person.has_age()) { ... }
> }
> install<Person>(person);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)