[katello-devel] Custom callbacks for optional backend services

Bryan Kearney bkearney at redhat.com
Tue Oct 16 16:36:43 UTC 2012


On 10/16/2012 11:13 AM, Justin Sherrill wrote:
>
>
>
> While we are working on the pulpv2 stuff, we are breaking apart our
> models a bit more and trying separate duties out more.  As part of this
> we should expect models to be able to operate on their own when backend
> services are disabled (even if they dont' do a whole lot).

What about items which only exist in the backend system? Repos is an 
example I think.

>
> One such example where this breaks is in Systems and System Groups:
>
>
> https://github.com/jlsherrill/katello/blob/pulpv2/src/app/models/system_group.rb#L24
>
>
> You can see here that we've broken up System even more, splitting out
> the elastic search code and authorization (in addition to the glue
> modules).  That specific line though will not function properly without
> Pulp and Elastic search being present.  You will get an error trying to
> add a system to a system group because "add_pulp_consumer_group" will
> have not been defined.  Since SAM is talking about adding system this
> will become more of a problem.
>
> An interesting solution would be to use custom callbacks:
>
> http://www.intridea.com/blog/2012/3/22/define-custom-callbacks-for-activerecord-and-more#
>
>
> So we could define our own events that get triggered (for example
> 'before_system_group_added')  and pulp glue layer could simply define a
> trigger on that callback.  In the SAM case that trigger'd method would
> never be defined, so it could go on its way happily.


Isnt that what the glue code does today with before_save and before 
create? Are you just thinking of extending that?

>
> Thoughts?
>
> -Justin
>
> _______________________________________________
> katello-devel mailing list
> katello-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/katello-devel




More information about the katello-devel mailing list