Apache Mesos
Functions
mesos::roles Namespace Reference

Functions

bool isStrictSubroleOf (const std::string &left, const std::string &right)
 Returns true iff left is a strict subrole of right. More...
 
Try< std::vector< std::string > > parse (const std::string &text)
 Parses Roles from text in the form "role1,role2,role3". More...
 
std::vector< std::string > ancestors (const std::string &role)
 Returns the ancestor roles for the role. More...
 
Option< Errorvalidate (const std::string &role)
 Validates the given role name. More...
 
Option< Errorvalidate (const std::vector< std::string > &roles)
 Validates the given list of roles. More...
 

Function Documentation

std::vector<std::string> mesos::roles::ancestors ( const std::string &  role)

Returns the ancestor roles for the role.

E.g. "a/b/c/d" returns ["a/b/c", "a/b", "a"].

Assumes the provided role is valid.

TODO(bmahler): Use string_view to avoid copying, this requires overloading to ensure that the argument is not an rvalue.

bool mesos::roles::isStrictSubroleOf ( const std::string &  left,
const std::string &  right 
)

Returns true iff left is a strict subrole of right.

left is a strict subrole of right if left is not equal to right, and left is a descendant of right in the role hierarchy.

Examples:

  • foo is not a strict subrole of foo.
  • foo/bar is a strict subrole of foo.
  • foobar is not a strict subrole of foo.
Try<std::vector<std::string> > mesos::roles::parse ( const std::string &  s)
inline

Parses Roles from text in the form "role1,role2,role3".

Parameters
textString to be parsed
Returns
Error if validation fails, otherwise a list of role names.

Parses Roles from text in the form "role1,role2,role3".

Option<Error> mesos::roles::validate ( const std::string &  role)

Validates the given role name.

A role name must be a valid directory name, so it cannot:

  • Be an empty string
  • Be . or ..
  • Start with -
  • Contain invalid characters (slash, backspace, or whitespace).
Parameters
roleRole name to be validated
Returns
Error if validation fails for any role, None otherwise.
Option<Error> mesos::roles::validate ( const std::vector< std::string > &  roles)

Validates the given list of roles.

Returns Error if any role is invalid.

Parameters
rolesList of role names to be validated
Returns
Error if validation fails, None otherwise.