On 23 April 2015 at 16:01, Vasiliy Tolstov <v.tols...@selfip.ru> wrote:
> 2015-04-23 11:00 GMT+03:00 roger peppe <roger.pe...@canonical.com>:
>> Nice start!
>>
>> As far as I can see the issue is just that there's
>> a variant syntax of a relation that's allowed in the metadata
>> (I replied in the issue itself).
>>
>> I had a brief look at your hooks.go file. I'd suggest that
>> it's probably better to register the hooks individually,
>> rather than using the switch (that way gocharm does the
>> work).
>>
>> As it happens, the gocharm hook logic emits a log message
>> anyway when a hook starts and finishes, but if you
>> *do* want to wrap other generic logic around hooks, it's
>> probably better to use a "decorator" style than to
>> introduce the switch.
>>
>> e.g.
>>
>>     func (n *mysql) registerHook(r *hook.Registry, name string, h
>> func() error) {
>>           r.RegisterHook(name, func() error {
>>                 n.ctxt.Logf("running %s", name)
>>                 return h()
>>           })
>>      }
>>
>>      ...
>>      n.registerHook(r, "install", n.install)
>>
>> Here's a paste of the code with a few suggested changes made:
>>
>>     http://paste.ubuntu.com/10870074/
>>
>> Please let me know if you have any more issues (or, even better, if
>> it all just works ok for you :-] )
>
>
> Thanks for suggestions, i'm try to write simple wordpress charm and
> check relations =)
> Last question - what benefits of using simplerelation package or
> writing own relations packages?

simplerelation is intended as a base for writing any relation
that has a simple "providers sets attributes, requirers see
them" convention.

So if the relation you want to write fits that convention, simplerelation
is probably the thing to use (if you look in the charmbits directory,
you'll see that some of the other relations already layer on top of it)

simplerelation is not really intended for using directly in a charm - the
idea is that if you want to implement a relation interface, you'll
make a package containing Provider and Requirer types and use
simplerelation to implement them if appropriate.

> Also, why in case of registered relation gocharm does not create
> symlinks for this relation?

I don't understand this question. Are you saying that you include
a relation-implementor in your type and call Register on it
but that hooks are not generated? (FWIW gocharm never makes
symlinks - it makes stub shell scripts instead)

Perhaps you could provide an example that doesn't work for you
and say what you expect it to do?

Ah! After looking at your code, I think I might know what your
question means. Do you mean "If I call RegisterRelation, why
does gocharm not generate relation hooks for that relation?".
If so, the answer is that gocharm only generates a hook stub when
you've called RegisterHook for that hook (it can't know
*which* hooks you want to be called. RegisterRelation just
registers the relation; it doesn't say that you're interested in hook
invocations
for that relation. See charmbits/httprelation for an example
of how to implement a relation.

  cheers,
    rog.

-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju

Reply via email to