# Copyright (c) 2005-2011 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: FailoverWorkQueue.pm,v 1.1 2011/12/01 13:42:56 andrews Exp $ package Bivio::Biz::FailoverWorkQueue; use strict; use Bivio::Base 'Bivio.UNIVERSAL'; b_use('IO.Trace'); our($VERSION) = sprintf('%d.%02d', q$Revision: 1.1 $ =~ /\d+/g); our($_TRACE); my($_C) = b_use('IO.Config'); my($_FWQO) = b_use('Type.FailoverWorkQueueOperation'); $_C->register(my $_CFG = { enable => 0, }); sub create_file { my($proto, $file_name) = @_; _insert_into_work_queue($file_name, $_FWQO->CREATE_FILE->as_sql_param); return; } sub delete_file { my($proto, $file_name) = @_; _insert_into_work_queue($file_name, $_FWQO->DELETE_FILE->as_sql_param); return; } sub handle_config { my(undef, $cfg) = @_; $_CFG = $cfg; return; } sub _insert_into_work_queue { my($file_name, $operation) = @_; return unless $_CFG->{enable}; _trace($file_name, $operation) if $_TRACE; b_use('SQL.Connection')->execute( q{INSERT INTO failover_work_queue_t (entry_id, operation, file_name) VALUES (nextval('failover_work_queue_s'), ?, ?)}, [$operation, $file_name]); return; } 1;