Skip to content

Instantly share code, notes, and snippets.

@johnsca
Created June 7, 2017 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnsca/a91cb5897d92dfb6741ee1a09d82b39b to your computer and use it in GitHub Desktop.
Save johnsca/a91cb5897d92dfb6741ee1a09d82b39b to your computer and use it in GitHub Desktop.
charms.reactive remote count
@when('rel.connected')
def handle_rel(rel):
hookenv.log('There are {} remote units'.format(rel.remote_count()))
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