Uploaded image for project: 'Mesos'
  1. Mesos
  2. MESOS-2638

Add support for Optional parameters to protobuf handlers to wrap option fields

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • libprocess
    • None

    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:

      example
      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); 
      

      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:

      void person(const Person& person)
      {
        if (person.has_age()) { ... }
      }
      
      install<Person>(person);
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            jvanremoortere Joris Van Remoortere
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: