diff options
author | Eric Wong <e@80x24.org> | 2016-07-09 03:18:35 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-07-09 03:20:25 +0000 |
commit | 2c972f3d70caf99488fff300341450e48be6ebf1 (patch) | |
tree | 066ba4c048b2fb64c271de1bc8096cdca46551ec /lib/PublicInbox/Config.pm | |
parent | f89bd1444a595b569606679293d2d01b0b7a049e (diff) | |
download | public-inbox-2c972f3d70caf99488fff300341450e48be6ebf1.tar.gz |
Currently only for git-http-backend use, this allows limiting the number of spawned processes per-inbox or by group, if there are multiple large inboxes amidst a sea of small ones. For example, a "big" repo limiter could be used for big inboxes: which would be shared between multiple repos: [limiter "big"] max = 4 [publicinbox "git"] address = git@vger.kernel.org mainrepo = /path/to/git.git ; shared limiter with giant: httpbackendmax = big [publicinbox "giant"] address = giant@project.org mainrepo = /path/to/giant.git ; shared limiter with git: httpbackendmax = big ; This is a tiny inbox, use the default limiter with 32 slots: [publicinbox "meta"] address = meta@public-inbox.org mainrepo = /path/to/meta.git
Diffstat (limited to 'lib/PublicInbox/Config.pm')
-rw-r--r-- | lib/PublicInbox/Config.pm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index d34d11ad..d7eaa3e8 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -20,6 +20,7 @@ sub new { $self->{-by_addr} ||= {}; $self->{-by_name} ||= {}; $self->{-by_newsgroup} ||= {}; + $self->{-limiters} ||= {}; $self; } @@ -85,6 +86,15 @@ sub lookup_newsgroup { undef; } +sub limiter { + my ($self, $name) = @_; + $self->{-limiters}->{$name} ||= do { + require PublicInbox::Qspawn; + my $key = "limiter.$name.max"; + PublicInbox::Qspawn::Limiter->new($self->{$key}); + }; +} + sub get { my ($self, $inbox, $key) = @_; @@ -131,7 +141,7 @@ sub _fill { my $rv = {}; foreach my $k (qw(mainrepo address filter url newsgroup - watch watchheader)) { + watch watchheader httpbackendmax)) { my $v = $self->{"$pfx.$k"}; $rv->{$k} = $v if defined $v; } @@ -139,6 +149,7 @@ sub _fill { my $name = $pfx; $name =~ s/\Apublicinbox\.//; $rv->{name} = $name; + $rv->{-pi_config} = $self; $rv = PublicInbox::Inbox->new($rv); my $v = $rv->{address}; if (ref($v) eq 'ARRAY') { |