Hi all

Sending this email because I really like the new Endpoints pattern and
because Cory is underselling the changes of this release. 😉

This version adds the `all_departed_units
<https://charmsreactive.readthedocs.io/en/latest/charms.reactive.relations.html#charms.reactive.endpoints.Endpoint.all_departed_units>`
collection: a list of all units that have departed. The list is persistent
and mutable, so a handler can use this list to keep track of which departed
units still have to be cleaned up. Each time a unit is cleaned up, the
handler removes that unit from `all_departed_units`, and this removal will
be persisted.


An example: you need to run a command each time a unit departs the relation.

@when('endpoint.{endpoint_name}.departed')
def handle_departed_unit(self):
for name, unit in self.departed_units.items():
# run the command to remove `unit` from the cluster
# ..
self.departed_units.clear()
clear_flag(self.expand_name('departed'))


This is how the flags relate

[image: Inline afbeelding 1]

Basically, the "joined" flag represents the state of the relationship and
will be automatically cleared when all units are gone. "changed" and
"departed" represents relationship events and have to be cleared manually
by the handler

This is a good example of why we switched from "state" to "flag": 'changed'
and 'departed' make no sense as a state, they are events that need to be
handled.



Regards
Merlijn


2018-02-20 22:21 GMT+01:00 Cory Johns <cory.jo...@canonical.com>:

> Greetings,
>
> Today we released version 0.6.1 of charms.reactive.  The full changelog
> can be found at https://charmsreactive.readthedocs.io/en/latest/changelog
> .html with the changes from this release being:
>
> * Separate departed units from joined in Endpoint (#153)
> * Add deprecated placeholder for RelationBase.from_state (#148)
>
> --
> Juju mailing list
> Juju@lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailm
> an/listinfo/juju
>
>
-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju

Reply via email to