On Sat Apr 07, 2012 at 09:43:32 -0700, Michael Papet wrote: > Is there an elegant way to chain queue plugins together this way?
Use notes. At the point you make a decision you would set a note to record which option you wish to go for, something like: ... $transaction->notes( "delivery", "forward" ); or $transaction->notes( "delivery", "locally" ); Then in the two queue handlers you'd update their hook routines as follows: queue/smtp-forward: sub hook_queue { my ($self, $transaction) = @_; # add something like this to terminate this plugin if the # mail is not to be forwarded my $delivery =$transaction->notes("delivery") || "unknown"; return DECLINED unless( $delivery =~ /forward/i ); ... } Ditto for queue/maildir: sub hook_queue { my ($self, $transaction) = @_; # add something like this to terminate this plugin if the # mail is not to be delivered locally my $delivery = $transaction->notes("delivery") || "unknown"; return DECLINED unless( $delivery =~ /locally/i ); ... } Passing notes in the transaction objects seems like it makes the most sense because they are designed to maintain state across related/unrelated plugin calls - and as you can see the changes you'll need to make to the existing plugins is pretty minimal. Steve --