Do states have namespace?

fengxia fxia1 at lenovo.com
Tue Apr 18 20:56:34 UTC 2017


I see. Thanks for the pointer. This is very helpful in our design.


On 04/18/2017 09:30 AM, Marco Ceppi wrote:
> On Tue, Apr 18, 2017 at 8:57 AM Alex Kavanagh 
> <alex.kavanagh at canonical.com <mailto:alex.kavanagh at canonical.com>> wrote:
>
>     Hi
>
>
>     On Tue, Apr 18, 2017 at 1:50 PM, fengxia <fxia1 at lenovo.com
>     <mailto:fxia1 at lenovo.com>> wrote:
>
>         I did a quick experiment:
>
>         1. Created two layers in one charm, each layer has a few
>         states, set_state() can trigger @when defined in other layers.
>
>         2. Use the same set of states, now splitting them in two
>         charms => @when don't trigger anymore.
>
>         So does this mean states have a namespace by the charm it belongs?
>
>
>     States are stored on the individual instance of the charm.  They
>     are private and no other charm can see those states.
>
>
> More directly, states are private per unit of a charm. Layers 
> namespace by convention rather than implicitly. For example, layer foo 
> should set states as follows:
>
> set_state('foo.state-name')
>
> That state, as you've seen, can be responded to by any other layer in 
> that charm, in that deployed unit. As such, if you have two units of 
> charm bar, bar/0 can not see or set states for bar/1 and vice versa.
>
> If you need to transfer state between charms, that's what Juju 
> Relations are for. They provide the ability to transfer key/vals 
> between one or more connected item: 
> https://jujucharms.com/docs/stable/developer-layers-interfaces
>
> Thanks,
> Marco Ceppi

-- 
Feng xia
Engineer
Lenovo USA

Phone: 5088011794
fxia1 at lenovo.com
  	
Lenovo.com
Twitter | Facebook | Instagram | Blogs | Forums

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20170418/ce88204d/attachment.html>


More information about the Juju mailing list