From: Eric Wong <e@80x24.org> To: meta@public-inbox.org Subject: [PATCH 5/9] lei q: honor --no-local to force remote searches Date: Sun, 24 Jan 2021 04:46:51 -0700 [thread overview] Message-ID: <20210124114655.12815-6-e@80x24.org> (raw) In-Reply-To: <20210124114655.12815-1-e@80x24.org> This can be useful for testing remote behavior, or for augmenting local results. It'll also be possible to explicitly include/exclude externals via CLI switches (once names are decided). --- lib/PublicInbox/LeiQuery.pm | 9 ++++++++- lib/PublicInbox/LeiXSearch.pm | 2 +- t/lei.t | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm index 7713902b..953d1fc2 100644 --- a/lib/PublicInbox/LeiQuery.pm +++ b/lib/PublicInbox/LeiQuery.pm @@ -26,7 +26,14 @@ sub lei_q { my $cb = $lxs->can('prepare_external'); my $ne = $self->_externals_each($cb, $lxs); $opt->{remote} //= $ne == $lxs->remotes; - delete($lxs->{remotes}) if !$opt->{remote}; + if ($opt->{'local'}) { + delete($lxs->{remotes}) if !$opt->{remote}; + } else { + delete($lxs->{locals}); + } + } + unless ($lxs->locals || $lxs->remotes) { + return $self->fail('no local or remote inboxes to search'); } my $xj = $lxs->concurrency($opt); my $ovv = PublicInbox::LeiOverview->new($self) or return; diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index c396c597..0417db24 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -311,7 +311,7 @@ sub start_query { # always runs in main (lei-daemon) process for my $ibxish (locals($self)) { $self->wq_do('query_thread_mset', $io, $lei, $ibxish); } - } else { + } elsif (locals($self)) { $self->wq_do('query_mset', $io, $lei); } my $i = 0; diff --git a/t/lei.t b/t/lei.t index 60ca75c5..3fd1d1fe 100644 --- a/t/lei.t +++ b/t/lei.t @@ -277,6 +277,9 @@ my $test_external = sub { } ok(!$lei->('q', '-o', "$home/mbox", 's:nope'), 'fails if mbox format unspecified'); + ok(!$lei->(qw(q --no-local s:see)), '--no-local'); + is($? >> 8, 1, 'proper exit code'); + like($err, qr/no local or remote.+? to search/, 'no inbox'); my %e = ( TEST_LEI_EXTERNAL_HTTPS => 'https://public-inbox.org/meta/', TEST_LEI_EXTERNAL_ONION => $onions[int(rand(scalar(@onions)))],
next prev parent reply other threads:[~2021-01-24 11:46 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-24 11:46 [PATCH 0/9] lei remotes fixes and updates Eric Wong 2021-01-24 11:46 ` [PATCH 1/9] lei q: limit concurrency to 4 remote connections Eric Wong 2021-01-24 11:46 ` [PATCH 2/9] ipc: wq supports arbitrarily large payloads Eric Wong 2021-01-24 11:46 ` [PATCH 3/9] ipc: get rid of wq_set_recv_modes Eric Wong 2021-01-24 11:46 ` [PATCH 4/9] lei q: disable remote externals if locals exist Eric Wong 2021-01-24 11:46 ` Eric Wong [this message] 2021-01-24 12:31 ` exit codes [was: [PATCH 5/9] lei q: honor --no-local to force remote searches] Eric Wong 2021-01-24 11:46 ` [PATCH 6/9] lei_xsearch: use curl -d '' for nginx compatibility Eric Wong 2021-01-24 11:46 ` [PATCH 7/9] lei q: fix JSON overview with remote externals Eric Wong 2021-01-24 12:37 ` Eric Wong 2021-01-24 11:46 ` [PATCH 8/9] smsg: make parse_references an object method Eric Wong 2021-01-24 11:46 ` [PATCH 9/9] smsg: parse_references: micro-optimization Eric Wong
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://public-inbox.org/README * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210124114655.12815-6-e@80x24.org \ --to=e@80x24.org \ --cc=meta@public-inbox.org \ --subject='Re: [PATCH 5/9] lei q: honor --no-local to force remote searches' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this inbox: https://80x24.org/public-inbox.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).