diff options
author | Eric Wong <e@80x24.org> | 2021-02-18 23:22:24 +0300 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-02-18 20:02:20 -0400 |
commit | d972b6711b01500181f809ef54a08aa29cb0d4a4 (patch) | |
tree | 485a06a9bf3eef48fe1ab24f7ba6c1cac78f9df5 /lib/PublicInbox/LeiConvert.pm | |
parent | 46eac797d44b068a5e144ecc8269e9dbe878f495 (diff) | |
download | public-inbox-d972b6711b01500181f809ef54a08aa29cb0d4a4.tar.gz |
The backends for "lei add-external --mirror", "lei convert", and "lei import" all share a similar pattern for spawning background workers. Hoist out the common parts to slim down our code base a bit. The LeiXSearch and LeiToMail workers for "lei q" remains a the odd duck due to the deep pipelining and parallelization.
Diffstat (limited to 'lib/PublicInbox/LeiConvert.pm')
-rw-r--r-- | lib/PublicInbox/LeiConvert.pm | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/lib/PublicInbox/LeiConvert.pm b/lib/PublicInbox/LeiConvert.pm index 78fd5e17..ba375772 100644 --- a/lib/PublicInbox/LeiConvert.pm +++ b/lib/PublicInbox/LeiConvert.pm @@ -8,7 +8,6 @@ use v5.10.1; use parent qw(PublicInbox::IPC); use PublicInbox::Eml; use PublicInbox::InboxWritable qw(eml_from_path); -use PublicInbox::PktOp; use PublicInbox::LeiStore; use PublicInbox::LeiOverview; @@ -59,26 +58,15 @@ sub do_convert { # via wq_do delete $self->{wcb}; # commit } -sub convert_start { +sub convert_start { # LeiAuth->auth_start callback my ($lei) = @_; - my $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 ], - '' => [ $lei->can('dclose'), $lei ], - }; - ($lei->{pkt_op_c}, $lei->{pkt_op_p}) = PublicInbox::PktOp->pair($ops); my $self = $lei->{cnv}; - $self->wq_workers_start('lei_convert', 1, $lei->oldset, {lei => $lei}); - my $op = delete $lei->{pkt_op_c}; - delete $lei->{pkt_op_p}; + my $op = $lei->workers_start($self, 'lei_convert', 1, { + '' => [ $lei->can('dclose'), $lei ] + }); $self->wq_io_do('do_convert', []); $self->wq_close(1); - $lei->event_step_init; # wait for shutdowns - if ($lei->{oneshot}) { - while ($op->{sock}) { $op->event_step } - } + while ($op && $op->{sock}) { $op->event_step } } sub call { # the main "lei convert" method |