Class: Droonga::NodeRole
- Inherits:
-
Object
- Object
- Droonga::NodeRole
- Defined in:
- lib/droonga/node_role.rb
Constant Summary collapse
- SERVICE_PROVIDER =
"service-provider".downcase
- ABSORB_SOURCE =
"absorb-source".downcase
- ABSORB_DESTINATION =
"absorb-destination".downcase
- ANY =
"any".downcase
- ROLES =
XXX ANY is not a valid role for a node. It is used just for checking acceptability of messages.
[ SERVICE_PROVIDER, ABSORB_SOURCE, ABSORB_DESTINATION, ]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(role) ⇒ NodeRole
constructor
A new instance of NodeRole.
- #to_s ⇒ Object
Constructor Details
#initialize(role) ⇒ NodeRole
Returns a new instance of NodeRole.
55 56 57 |
# File 'lib/droonga/node_role.rb', line 55 def initialize(role) @role = normalize(role) end |
Class Method Details
.mine ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/droonga/node_role.rb', line 42 def mine if Path..exist? = Path..read = JSON.parse() role_from_tag = [Serf::Tag.node_role] return role_from_tag.downcase if role_from_tag end SERVICE_PROVIDER rescue Errno::ENOENT, JSON::ParserError SERVICE_PROVIDER end |
.normalize(role) ⇒ Object
38 39 40 |
# File 'lib/droonga/node_role.rb', line 38 def normalize(role) new(role).to_s end |
Instance Method Details
#to_s ⇒ Object
59 60 61 |
# File 'lib/droonga/node_role.rb', line 59 def to_s @role end |