Created
June 7, 2017 15:38
-
-
Save johnsca/a91cb5897d92dfb6741ee1a09d82b39b to your computer and use it in GitHub Desktop.
charms.reactive remote count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@when('rel.connected') | |
def handle_rel(rel): | |
hookenv.log('There are {} remote units'.format(rel.remote_count())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RelProvides(RelationBase): | |
scope = scopes.UNIT | |
@hook('{provides:rel}-relation-joined') | |
def joined(self): | |
self.set_state('{relation_name}.connected') | |
def remote_count(self): | |
return len(self.conversations()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment