[katello-devel] Custom callbacks for optional backend services

Justin Sherrill jsherril at redhat.com
Tue Oct 16 16:44:40 UTC 2012


On 10/16/2012 12:36 PM, Bryan Kearney wrote:
> 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.

I don't think you would use it for things that only exist in backend 
systems.  Repos actually exist in katello too, but content, packages, & 
errata are all examples.  If something just exists in a single backend 
system it wouldn't be usefull.  If it exists in more than one (or in 
katello itself) i think it might.


>
>>
>> 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?

It is, those are just callbacks defined by active record.  We would be 
extending it for custom callbacks for other types of actions.

-Justin

>
>>
>> Thoughts?
>>
>> -Justin
>>
>> _______________________________________________
>> katello-devel mailing list
>> katello-devel at redhat.com
>> https://www.redhat.com/mailman/listinfo/katello-devel
>
> _______________________________________________
> 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