]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/ConfigIter.pm
No ext_urls
[public-inbox.git] / lib / PublicInbox / ConfigIter.pm
index 26cc70e28ce5094254a0df4c1e518fe603cb1c04..14fcef83f2293d85e3798bc47e43736052823209 100644 (file)
@@ -1,7 +1,7 @@
-# Copyright (C) 2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
-# Intended for PublicInbox::DS->EventLoop in read-only daemons
+# Intended for PublicInbox::DS::event_loop in read-only daemons
 # to avoid each_inbox() monopolizing the event loop when hundreds/thousands
 # of inboxes are in play.
 package PublicInbox::ConfigIter;
@@ -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;