[katello-devel] Pre-save and post-save queues in glue layer
Ivan Nečas
inecas at redhat.com
Thu Jan 26 08:56:39 UTC 2012
Hi,
After GPG keys orchestration, I'm working on another task where we need
to do some action after saving a record to our database: we create
environment in Katello and then in Candlepin (we are sending there our
environment_id.
Like it was pointed out before, in current state all the orchestration
happens before the record is saved:
def on_save
process queue
yield if block_given?
@orchestration_for = nil
end
I suggest to rename our current queue to pre_queue (which means to
happen before saving) and post_queue (after saving). So the on_save
around filter would look like this:
def on_save
process pre_queue
yield if block_given?
process post_queue
@orchestration_for = nil
end
I've already tested it in my branch, and it looks it serves our
purposes. We don't have to worry about record being created before some
orchestrations fails: on_save runs whole in transaction and when
something is wrong, it rolls back the insertion. From my sql log after
simulating an error after saving:
SQL (6.7ms) INSERT INTO "providers" ("created_at", "updated_at",
"organization_id", "provider_type", "repository_url", "name",
"description") VALUES ('2012-01-26 08:52:44.664467', '2012-01-26
08:52:44.664467', 1, 'Custom', NULL, 'katello', NULL) RETURNING "id"
SQL (0.1ms) ROLLBACK
I would like to get some team ACK before actually implementing the whole
change, incluiding renaming the original queue. Any suggestions on
better naming etc. welcomed.
-- Ivan
More information about the katello-devel
mailing list