* [PATCH 4/8] lei: simplify workers_start and callers
2021-03-22 7:53 6% [PATCH 0/8] lei input handling improvements Eric Wong
@ 2021-03-22 7:53 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-03-22 7:53 UTC (permalink / raw)
To: meta
Since workers_start is in the common PublicInbox::LEI
package, we can just use \&METHOD_NAME instead of relying
on UNIVERSAL->can to avoid a method dispatch.
Most of our worker code can just use lei->dclose, so default
to doing that unless it's been overridden.
---
lib/PublicInbox/LEI.pm | 11 ++++++-----
lib/PublicInbox/LeiConvert.pm | 4 +---
lib/PublicInbox/LeiP2q.pm | 4 +---
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 0bd52a46..1e720b89 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -481,12 +481,13 @@ sub lei_atfork_child {
sub workers_start {
my ($lei, $wq, $ident, $jobs, $ops) = @_;
$ops = {
- '!' => [ $lei->can('fail_handler'), $lei ],
- '|' => [ $lei->can('sigpipe_handler'), $lei ],
- 'x_it' => [ $lei->can('x_it'), $lei ],
- 'child_error' => [ $lei->can('child_error'), $lei ],
- %$ops
+ '!' => [ \&fail_handler, $lei ],
+ '|' => [ \&sigpipe_handler, $lei ],
+ 'x_it' => [ \&x_it, $lei ],
+ 'child_error' => [ \&child_error, $lei ],
+ ($ops ? %$ops : ()),
};
+ $ops->{''} //= [ \&dclose, $lei ];
require PublicInbox::PktOp;
($lei->{pkt_op_c}, $lei->{pkt_op_p}) = PublicInbox::PktOp->pair($ops);
$wq->wq_workers_start($ident, $jobs, $lei->oldset, { lei => $lei });
diff --git a/lib/PublicInbox/LeiConvert.pm b/lib/PublicInbox/LeiConvert.pm
index 0aa13229..8685c194 100644
--- a/lib/PublicInbox/LeiConvert.pm
+++ b/lib/PublicInbox/LeiConvert.pm
@@ -87,9 +87,7 @@ sub lei_convert { # the main "lei convert" method
$lei->fail("output not specified or is not a mail destination");
$lei->{opt}->{augment} = 1 unless $ovv->{dst} eq '/dev/stdout';
$self->prepare_inputs($lei, \@inputs) or return;
- my $op = $lei->workers_start($self, 'lei_convert', 1, {
- '' => [ $lei->can('dclose'), $lei ]
- });
+ my $op = $lei->workers_start($self, 'lei_convert', 1);
$self->wq_io_do('do_convert', []);
$self->wq_close(1);
while ($op && $op->{sock}) { $op->event_step }
diff --git a/lib/PublicInbox/LeiP2q.pm b/lib/PublicInbox/LeiP2q.pm
index 302d7864..4abe1345 100644
--- a/lib/PublicInbox/LeiP2q.pm
+++ b/lib/PublicInbox/LeiP2q.pm
@@ -182,9 +182,7 @@ sub lei_p2q { # the "lei patch-to-query" entry point
} else {
$self->{input} = $input;
}
- my $op = $lei->workers_start($self, 'lei patch2query', 1, {
- '' => [ $lei->{p2q_done} // $lei->can('dclose'), $lei ]
- });
+ my $op = $lei->workers_start($self, 'lei patch2query', 1);
$self->wq_io_do('do_p2q', []);
$self->wq_close(1);
while ($op && $op->{sock}) { $op->event_step }
^ permalink raw reply related [relevance 7%]
* [PATCH 0/8] lei input handling improvements
@ 2021-03-22 7:53 6% Eric Wong
2021-03-22 7:53 7% ` [PATCH 4/8] lei: simplify workers_start and callers Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-03-22 7:53 UTC (permalink / raw)
To: meta
lei <convert|import> share a bit more code, now; and being
able to set "-c imap.debug" on the command-line should make
future work easier.
All this should set us up nicely for implementing "lei mark"
to add/remove keywords and labels.
Eric Wong (8):
lei: support -c <name>=<value> to overrides
net_reader: escape nasty chars from Net::NNTP->message
lei: share input code between convert and import
lei: simplify workers_start and callers
mbox_reader: add ->reads method to avoid nonsensical formats
lei_input: common filehandle reader for eml + mbox
lei_input: drop "From " line on single "eml" (message/rfc822)
lei import: ignore Status headers in "eml" messages
MANIFEST | 1 +
lib/PublicInbox/InboxWritable.pm | 2 +-
lib/PublicInbox/LEI.pm | 137 ++++++++++++++++++-------------
lib/PublicInbox/LeiConvert.pm | 94 ++++-----------------
lib/PublicInbox/LeiExternal.pm | 2 +-
lib/PublicInbox/LeiImport.pm | 107 +++++-------------------
lib/PublicInbox/LeiInput.pm | 106 ++++++++++++++++++++++++
lib/PublicInbox/LeiP2q.pm | 4 +-
lib/PublicInbox/MboxReader.pm | 5 ++
lib/PublicInbox/NetReader.pm | 10 ++-
t/lei-import.t | 37 +++++++--
t/lei.t | 9 ++
12 files changed, 278 insertions(+), 236 deletions(-)
create mode 100644 lib/PublicInbox/LeiInput.pm
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-03-22 7:53 6% [PATCH 0/8] lei input handling improvements Eric Wong
2021-03-22 7:53 7% ` [PATCH 4/8] lei: simplify workers_start and callers 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).