From dccfcde0cd7e8c7340be0d976ee46ff563b58de0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 7 Jan 2017 01:44:45 +0000 Subject: config: always use namespaced "publicinboxlimiter" I'm not sure if we'll ever support sharing a config file with other tools, but maybe we will, and "limiter" is too generic. --- t/config_limiter.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/config_limiter.t b/t/config_limiter.t index 3c7ec557..486bfbe9 100644 --- a/t/config_limiter.t +++ b/t/config_limiter.t @@ -25,7 +25,7 @@ my $cfgpfx = "publicinbox.test"; { my $config = PublicInbox::Config->new({ - 'limiter.named.max' => 3, + 'publicinboxlimiter.named.max' => 3, "$cfgpfx.address" => 'test@example.com', "$cfgpfx.mainrepo" => '/path/to/non/existent', "$cfgpfx.httpbackendmax" => 'named', -- cgit v1.2.3-24-ge0c7 From 37415497e02c3cacdd70060acddc2604342b66e5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 7 Jan 2017 01:44:48 +0000 Subject: inbox: eliminate weaken usage entirely We can do a better job initializing the data structure so we no longer need to rely on weak references to cleanup when we ditch the config on reload. --- t/config.t | 19 +++++++++++++++++-- t/config_limiter.t | 9 ++++----- 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 't') diff --git a/t/config.t b/t/config.t index 7271351b..040e9fb2 100644 --- a/t/config.t +++ b/t/config.t @@ -31,7 +31,8 @@ my $tmpdir = tempdir('pi-config-XXXXXX', TMPDIR => 1, CLEANUP => 1); -primary_address => 'meta@public-inbox.org', 'name' => 'meta', feedmax => 25, - -pi_config => $cfg, + -httpbackend_limiter => undef, + nntpserver => undef, }, "lookup matches expected output"); is($cfg->lookup('blah@example.com'), undef, @@ -48,7 +49,8 @@ my $tmpdir = tempdir('pi-config-XXXXXX', TMPDIR => 1, CLEANUP => 1); 'name' => 'test', feedmax => 25, 'url' => 'http://example.com/test', - -pi_config => $cfg, + -httpbackend_limiter => undef, + nntpserver => undef, }, "lookup matches expected output for test"); } @@ -65,4 +67,17 @@ my $tmpdir = tempdir('pi-config-XXXXXX', TMPDIR => 1, CLEANUP => 1); is_deeply($ibx->{altid}, [ @altid ]); } +{ + my $pfx = "publicinbox.test"; + my %h = ( + "$pfx.address" => 'test@example.com', + "$pfx.mainrepo" => '/path/to/non/existent', + "publicinbox.nntpserver" => 'news.example.com', + ); + my %tmp = %h; + my $cfg = PublicInbox::Config->new(\%tmp); + my $ibx = $cfg->lookup_name('test'); + is($ibx->{nntpserver}, 'news.example.com', 'global NNTP server'); +} + done_testing(); diff --git a/t/config_limiter.t b/t/config_limiter.t index 486bfbe9..f0b65281 100644 --- a/t/config_limiter.t +++ b/t/config_limiter.t @@ -37,12 +37,11 @@ my $cfgpfx = "publicinbox.test"; my $lim = $git->{-httpbackend_limiter}; ok($lim, 'Limiter exists'); is($lim->{max}, 3, 'limiter has expected slots'); - $git = undef; $ibx->{git} = undef; - PublicInbox::Inbox::weaken_task; - $git = $ibx->git; - isnt($old, "$git", 'got new Git object'); - is("$git->{-httpbackend_limiter}", "$lim", 'same limiter'); + PublicInbox::Inbox::cleanup_task; + my $new = $ibx->git; + isnt($old, "$new", 'got new Git object'); + is("$new->{-httpbackend_limiter}", "$lim", 'same limiter'); is($lim->{max}, 3, 'limiter has expected slots'); } -- cgit v1.2.3-24-ge0c7 From b6de8d4f10aaca3f02707be45b4cd2dc04f48a1f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 7 Jan 2017 01:44:49 +0000 Subject: config: allow per-inbox nntpserver This allows certain inboxes to override the global nntpserver (perhaps under a different domain). --- t/config.t | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 't') diff --git a/t/config.t b/t/config.t index 040e9fb2..3ba61119 100644 --- a/t/config.t +++ b/t/config.t @@ -78,6 +78,12 @@ my $tmpdir = tempdir('pi-config-XXXXXX', TMPDIR => 1, CLEANUP => 1); my $cfg = PublicInbox::Config->new(\%tmp); my $ibx = $cfg->lookup_name('test'); is($ibx->{nntpserver}, 'news.example.com', 'global NNTP server'); + + delete $h{'publicinbox.nntpserver'}; + $h{"$pfx.nntpserver"} = 'news.alt.example.com'; + $cfg = PublicInbox::Config->new(\%h); + $ibx = $cfg->lookup_name('test'); + is($ibx->{nntpserver}, 'news.alt.example.com','per-inbox NNTP server'); } done_testing(); -- cgit v1.2.3-24-ge0c7 From f74b64dbe75226b996367a6049ebd00a3e39ba49 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 7 Jan 2017 01:44:52 +0000 Subject: search: remove subject_summary Apparently it never actually got used, and the world seems fine without it, so we can drop it. While we're at it, consider removing our subject_path usage from existence, too. We are not using fancy subject-line based URLs, here. --- t/search.t | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 't') diff --git a/t/search.t b/t/search.t index c16811d8..c9c4e346 100644 --- a/t/search.t +++ b/t/search.t @@ -15,23 +15,6 @@ is(0, system(qw(git init -q --bare), $git_dir), "git init (main)"); eval { PublicInbox::Search->new($git_dir) }; ok($@, "exception raised on non-existent DB"); -{ - my $orig = "FOO " x 30; - my $summ = PublicInbox::Search::subject_summary($orig); - - $summ = length($summ); - $orig = length($orig); - ok($summ < $orig && $summ > 0, "summary shortened ($orig => $summ)"); - - $orig = "FOO" x 30; - $summ = PublicInbox::Search::subject_summary($orig); - - $summ = length($summ); - $orig = length($orig); - ok($summ < $orig && $summ > 0, - "summary shortened but not empty: $summ"); -} - my $rw = PublicInbox::SearchIdx->new($git_dir, 1); $rw->_xdb_acquire; $rw->_xdb_release; -- cgit v1.2.3-24-ge0c7