]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: simplify workers_start API
authorEric Wong <e@80x24.org>
Sun, 2 May 2021 06:05:40 +0000 (06:05 +0000)
committerEric Wong <e@80x24.org>
Mon, 3 May 2021 18:45:26 +0000 (18:45 +0000)
In most cases, we just name the worker process based
on the command.  The only change is for LeiMirror
vs "lei add-external --mirror", but I doubt it matters.

lib/PublicInbox/LEI.pm
lib/PublicInbox/LeiBlob.pm
lib/PublicInbox/LeiConvert.pm
lib/PublicInbox/LeiImport.pm
lib/PublicInbox/LeiLsSearch.pm
lib/PublicInbox/LeiMirror.pm
lib/PublicInbox/LeiP2q.pm
lib/PublicInbox/LeiTag.pm

index 5d701d5e14e817ac0b5120eb5ed10bab28608c05..d5c6bd525621be299bfe1d362b65f1f9426a0e3e 100644 (file)
@@ -542,7 +542,7 @@ sub pkt_op_pair {
 }
 
 sub workers_start {
 }
 
 sub workers_start {
-       my ($lei, $wq, $ident, $jobs, $ops) = @_;
+       my ($lei, $wq, $jobs, $ops) = @_;
        $ops = {
                '!' => [ \&fail_handler, $lei ],
                '|' => [ \&sigpipe_handler, $lei ],
        $ops = {
                '!' => [ \&fail_handler, $lei ],
                '|' => [ \&sigpipe_handler, $lei ],
@@ -552,6 +552,7 @@ sub workers_start {
        };
        $ops->{''} //= [ $wq->can('_lei_wq_eof') || \&wq_eof, $lei ];
        my $end = $lei->pkt_op_pair;
        };
        $ops->{''} //= [ $wq->can('_lei_wq_eof') || \&wq_eof, $lei ];
        my $end = $lei->pkt_op_pair;
+       my $ident = $wq->{-wq_ident} // "lei-$lei->{cmd} worker";
        $wq->wq_workers_start($ident, $jobs, $lei->oldset, { lei => $lei });
        delete $lei->{pkt_op_p};
        my $op_c = delete $lei->{pkt_op_c};
        $wq->wq_workers_start($ident, $jobs, $lei->oldset, { lei => $lei });
        delete $lei->{pkt_op_p};
        my $op_c = delete $lei->{pkt_op_c};
index 0a9573589a29711630dbb631cdb6ec1f6ab87cf4..710430a2c1981e2170c607d83a4cb0c782c54996 100644 (file)
@@ -151,7 +151,7 @@ EOM
        }
        require PublicInbox::SolverGit;
        my $self = bless { lxs => $lxs, oid_b => $blob }, __PACKAGE__;
        }
        require PublicInbox::SolverGit;
        my $self = bless { lxs => $lxs, oid_b => $blob }, __PACKAGE__;
-       my ($op_c, $ops) = $lei->workers_start($self, 'lei-blob', 1);
+       my ($op_c, $ops) = $lei->workers_start($self, 1);
        $lei->{wq1} = $self;
        $self->wq_io_do('do_solve_blob', []);
        $self->wq_close(1);
        $lei->{wq1} = $self;
        $self->wq_io_do('do_solve_blob', []);
        $self->wq_close(1);
index 5b27ec2d4dc7bbfbae4ea75e6ddba762c7d9fa47..395a80f8adee44cb1a5d49f776f1573d174d3395 100644 (file)
@@ -55,7 +55,7 @@ sub lei_convert { # the main "lei convert" method
        my $devfd = $lei->path_to_fd($ovv->{dst}) // return;
        $lei->{opt}->{augment} = 1 if $devfd < 0;
        $self->prepare_inputs($lei, \@inputs) or return;
        my $devfd = $lei->path_to_fd($ovv->{dst}) // return;
        $lei->{opt}->{augment} = 1 if $devfd < 0;
        $self->prepare_inputs($lei, \@inputs) or return;
-       my ($op_c, $ops) = $lei->workers_start($self, 'lei-convert', 1);
+       my ($op_c, $ops) = $lei->workers_start($self, 1);
        $lei->{wq1} = $self;
        $self->wq_io_do('process_inputs', []);
        $self->wq_close(1);
        $lei->{wq1} = $self;
        $self->wq_io_do('process_inputs', []);
        $self->wq_close(1);
index 394138b49c41be27af34fe9078aca180be5805f4..6a57df47758f2ee195af84dbed09bac47532b147 100644 (file)
@@ -76,7 +76,7 @@ sub lei_import { # the main "lei import" method
        $lei->{auth}->op_merge($ops, $self) if $lei->{auth};
        $self->{-wq_nr_workers} = $j // 1; # locked
        $lei->{-eml_noisy} = 1;
        $lei->{auth}->op_merge($ops, $self) if $lei->{auth};
        $self->{-wq_nr_workers} = $j // 1; # locked
        $lei->{-eml_noisy} = 1;
-       (my $op_c, $ops) = $lei->workers_start($self, 'lei-import', $j, $ops);
+       (my $op_c, $ops) = $lei->workers_start($self, $j, $ops);
        $lei->{wq1} = $self;
        $lei->{-err_type} = 'non-fatal';
        net_merge_all_done($self) unless $lei->{auth};
        $lei->{wq1} = $self;
        $lei->{-err_type} = 'non-fatal';
        net_merge_all_done($self) unless $lei->{auth};
index a00e78fcc96834a74ad6a2e1ad55c19647e79595..6cea6ae88089935d4f31a69bf9845ef8dad39dc4 100644 (file)
@@ -72,7 +72,7 @@ sub do_ls_search_long {
 sub bg_worker ($$$) {
        my ($lei, $pfx, $json) = @_;
        my $self = bless { -wq_nr_workers => 1, json => $json }, __PACKAGE__;
 sub bg_worker ($$$) {
        my ($lei, $pfx, $json) = @_;
        my $self = bless { -wq_nr_workers => 1, json => $json }, __PACKAGE__;
-       my ($op_c, $ops) = $lei->workers_start($self, 'ls-search', 1);
+       my ($op_c, $ops) = $lei->workers_start($self, 1);
        $lei->{wq1} = $self;
        $self->wq_io_do('do_ls_search_long', [], $pfx);
        $self->wq_close(1);
        $lei->{wq1} = $self;
        $self->wq_io_do('do_ls_search_long', [], $pfx);
        $self->wq_close(1);
index db97b98c8dfed69f1dabb78c207998c1317034ba..a37e1d5c626cdfe35398b354a22a686a48e8e679 100644 (file)
@@ -282,7 +282,7 @@ sub start {
        require PublicInbox::Inbox;
        require PublicInbox::Admin;
        require PublicInbox::InboxWritable;
        require PublicInbox::Inbox;
        require PublicInbox::Admin;
        require PublicInbox::InboxWritable;
-       my ($op, $ops) = $lei->workers_start($self, 'lei_mirror', 1);
+       my ($op, $ops) = $lei->workers_start($self, 1);
        $lei->{wq1} = $self;
        $self->wq_io_do('do_mirror', []);
        $self->wq_close(1);
        $lei->{wq1} = $self;
        $self->wq_io_do('do_mirror', []);
        $self->wq_close(1);
index b48934898db916b9f2a7a4bbd8dc859138477510..f381a31c543be181b18f4b595e6a0201758c0aaa 100644 (file)
@@ -188,7 +188,7 @@ sub lei_p2q { # the "lei patch-to-query" entry point
        } else {
                $self->{input} = $input;
        }
        } else {
                $self->{input} = $input;
        }
-       my ($op, $ops) = $lei->workers_start($self, 'lei-p2q', 1);
+       my ($op, $ops) = $lei->workers_start($self, 1);
        $lei->{wq1} = $self;
        $self->wq_io_do('do_p2q', []);
        $self->wq_close(1);
        $lei->{wq1} = $self;
        $self->wq_io_do('do_p2q', []);
        $self->wq_close(1);
index 6025c93e0b94675e65bed876c688425b42f84eb2..c650e88633c999c430ab4f86a7a220d78878544d 100644 (file)
@@ -44,7 +44,7 @@ sub lei_tag { # the "lei tag" method
        $lei->{auth}->op_merge($ops, $self) if $lei->{auth};
        $self->{vmd_mod} = $vmd_mod;
        my $j = $self->{-wq_nr_workers} = 1; # locked for now
        $lei->{auth}->op_merge($ops, $self) if $lei->{auth};
        $self->{vmd_mod} = $vmd_mod;
        my $j = $self->{-wq_nr_workers} = 1; # locked for now
-       (my $op_c, $ops) = $lei->workers_start($self, 'lei-tag', $j, $ops);
+       (my $op_c, $ops) = $lei->workers_start($self, $j, $ops);
        $lei->{wq1} = $self;
        $lei->{-err_type} = 'non-fatal';
        net_merge_all_done($self) unless $lei->{auth};
        $lei->{wq1} = $self;
        $lei->{-err_type} = 'non-fatal';
        net_merge_all_done($self) unless $lei->{auth};