about summary refs log tree commit homepage
path: root/lib/PublicInbox/ConfigIter.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-09-09 06:26:16 +0000
committerEric Wong <e@80x24.org>2020-09-10 19:45:18 +0000
commitf303b4add8ea18835f7f304910ba8fac3ee4f912 (patch)
tree037efb9de87e44433b18d535b4ed5fec03fa211b /lib/PublicInbox/ConfigIter.pm
parent081946eae235baac51987cf591e2b55e7e039b55 (diff)
downloadpublic-inbox-f303b4add8ea18835f7f304910ba8fac3ee4f912.tar.gz
By using the just-introduced ConfigIter class.
And make ManifestJsGz a subclass of it to reduce duplication.
Diffstat (limited to 'lib/PublicInbox/ConfigIter.pm')
-rw-r--r--lib/PublicInbox/ConfigIter.pm12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/PublicInbox/ConfigIter.pm b/lib/PublicInbox/ConfigIter.pm
index 26cc70e2..e6fa8172 100644
--- a/lib/PublicInbox/ConfigIter.pm
+++ b/lib/PublicInbox/ConfigIter.pm
@@ -25,4 +25,16 @@ sub event_step {
         PublicInbox::DS::requeue($self) if defined($section);
 }
 
+# for generic PSGI servers
+sub each_section {
+        my $self = shift;
+        my ($pi_cfg, $i, $cb, @arg) = @$self;
+        while (defined(my $section = $pi_cfg->{-section_order}->[$$i++])) {
+                eval { $cb->($pi_cfg, $section, @arg) };
+                warn "E: $@ in ${self}::each_section" if $@;
+        }
+        eval { $cb->($pi_cfg, undef, @arg) };
+        warn "E: $@ in ${self}::each_section" if $@;
+}
+
 1;