* exit codes [was: [PATCH 5/9] lei q: honor --no-local to force remote searches]
2021-01-24 11:46 6% ` [PATCH 5/9] lei q: honor --no-local to force remote searches Eric Wong
@ 2021-01-24 12:31 7% ` Eric Wong
0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2021-01-24 12:31 UTC (permalink / raw)
To: meta
Eric Wong <e@80x24.org> wrote:
> --- 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');
I'm wondering if BSD EX_* constants from sysexits.h makes sense
for lei and if users will care, but keep in mind git doesn't use
them. But they may conflict with curl(1) exit codes which we
propagate back to the user.
public-inbox-mda uses those codes because MTAs understand them;
but I'm not sure if lei will be invoked by MTAs via procmail
and what not...
sysexits.ph is distributed with Debian and FreeBSD Perl,
but not CentOS7. However, the codes are stable across
architectures and OSes (AFAIK), unlike syscall numbers.
^ permalink raw reply [relevance 7%]
* [PATCH 5/9] lei q: honor --no-local to force remote searches
2021-01-24 11:46 6% [PATCH 0/9] lei remotes fixes and updates Eric Wong
@ 2021-01-24 11:46 6% ` Eric Wong
2021-01-24 12:31 7% ` exit codes [was: [PATCH 5/9] lei q: honor --no-local to force remote searches] Eric Wong
0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2021-01-24 11:46 UTC (permalink / raw)
To: meta
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)))],
^ permalink raw reply related [relevance 6%]
* [PATCH 0/9] lei remotes fixes and updates
@ 2021-01-24 11:46 6% Eric Wong
2021-01-24 11:46 6% ` [PATCH 5/9] lei q: honor --no-local to force remote searches Eric Wong
0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2021-01-24 11:46 UTC (permalink / raw)
To: meta
Eric Wong (9):
lei q: limit concurrency to 4 remote connections
ipc: wq supports arbitrarily large payloads
ipc: get rid of wq_set_recv_modes
lei q: disable remote externals if locals exist
lei q: honor --no-local to force remote searches
lei_xsearch: use curl -d '' for nginx compatibility
lei q: fix JSON overview with remote externals
smsg: make parse_references an object method
smsg: parse_references: micro-optimization to avoid ++
lib/PublicInbox/IPC.pm | 85 +++++++++++++++++----------
lib/PublicInbox/LEI.pm | 9 ++-
lib/PublicInbox/LeiOverview.pm | 2 +-
lib/PublicInbox/LeiQuery.pm | 13 ++++-
lib/PublicInbox/LeiToMail.pm | 7 +--
lib/PublicInbox/LeiXSearch.pm | 101 ++++++++++++++++++---------------
lib/PublicInbox/OverIdx.pm | 22 +------
lib/PublicInbox/SearchIdx.pm | 2 +-
lib/PublicInbox/Smsg.pm | 22 ++++++-
script/lei | 11 ++--
t/cmd_ipc.t | 16 ++++++
t/ipc.t | 21 ++++++-
t/lei.t | 3 +
13 files changed, 196 insertions(+), 118 deletions(-)
^ permalink raw reply [relevance 6%]
Results 1-3 of 3 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-01-24 11:46 6% [PATCH 0/9] lei remotes fixes and updates Eric Wong
2021-01-24 11:46 6% ` [PATCH 5/9] lei q: honor --no-local to force remote searches Eric Wong
2021-01-24 12:31 7% ` exit codes [was: [PATCH 5/9] lei q: honor --no-local to force remote searches] Eric Wong
Code repositories for project(s) associated with this public 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).