+ $cleanup_timer ||= PublicInbox::EvCleanup::later(*cleanup_task);
+ $CLEANUP->{"$self"} = $self;
+}
+
+sub _set_uint ($$$) {
+ my ($opts, $field, $default) = @_;
+ my $val = $opts->{$field};
+ if (defined $val) {
+ $val = $val->[-1] if ref($val) eq 'ARRAY';
+ $val = undef if $val !~ /\A\d+\z/;
+ }
+ $opts->{$field} = $val || $default;
+}
+
+sub _set_limiter ($$$) {
+ my ($self, $pi_config, $pfx) = @_;
+ my $lkey = "-${pfx}_limiter";
+ $self->{$lkey} ||= eval {
+ # full key is: publicinbox.$NAME.httpbackendmax
+ my $mkey = $pfx.'max';
+ my $val = $self->{$mkey} or return;
+ my $lim;
+ if ($val =~ /\A\d+\z/) {
+ require PublicInbox::Qspawn;
+ $lim = PublicInbox::Qspawn::Limiter->new($val);
+ } elsif ($val =~ /\A[a-z][a-z0-9]*\z/) {
+ $lim = $pi_config->limiter($val);
+ warn "$mkey limiter=$val not found\n" if !$lim;
+ } else {
+ warn "$mkey limiter=$val not understood\n";
+ }
+ $lim;
+ }