about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiP2q.pm
DateCommit message (Collapse)
2021-11-02lei: simplify common LeiInput users with ->wq1_start
This method replaces a common pattern of starting workers, preparing internal auth ops, and asynchronous waiting of command completion. It also adds missing LeiAuth support to rediff and rm which rarely need auth.
2021-10-26lei p2q: use LeiInput for multi-patch series
The LeiInput backend now allows p2q to work like any other command which reads .eml, .patch, mbox*, Maildir, IMAP, and NNTP input. Running "git format-patch --stdout -1 $COMMIT" remains supported. This is intended to allow lower memory use while parsing "git log --pretty=mboxrd -p" output. Previously, the entire output of "git log" would be slurped into memory at once. The intended use is to allow easy(-ish :P) searching for unapplied patches as documented in the new example in the manpage.
2021-10-15lei + ipc: simplify process reaping
Simplify our APIs and force dwaitpid() to work in async mode for all lei workers. This avoids having lingering zombies for parallel searches if one worker finishes soon before another. The old distinction between "old" and "new" workers was needlessly complex, error-prone, and embarrasingly bad. We also never handled v2:// writers properly before on Ctrl-C/Ctrl-Z (SIGINT/SIGTSTP), so add them to @WQ_KEYS to ensure they get handled by $lei when appropropriate.
2021-10-13lei: use standard warn() in more places
warn() is easier to augment with context information, and frankly unavoidable in the presence of 3rd-party libraries we don't control.
2021-06-08lei: generalize auxiliary WQ handling
op_wait_event is now more lei-specific since we no longer have to care about oneshot and use a synchronous loop. {ikw} (import-keywords) started a trend, but LeiPmdir (parallel Maildir) is an upcoming WQ class that will follow this idea. Eventually, {l2m} usage may be updated to follow this, too.
2021-05-03lei: simplify workers_start API
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.
2021-04-28lei: simple WQ workers use {wq1} field
This lets us share more code and reduces cognitive overhead when it comes to picking names (because {lsss} was ridiculous). We'll need to ensure the first error set in lei is the actual error we exit with, otherwise things can get confusing and errors may get lost.
2021-04-28lei: quiet down Eml-related warnings consistently
"lei import" is probably the only place where it users might care about warnings.
2021-04-28lei_p2q: add _lei_wq_eof callback
This may help with some error diagnostics.
2021-04-27lei: standardize on _lei_wq_eof callback for workers
Simplify our internals a little bit.
2021-04-26lei p2q: exit with failure if format-patch fails
Merely redirecting the failure message from git to our stderr is insufficient.
2021-03-28lei: simplify PktOp callers
Provide a consistent ->op_wait_event method instead of forcing callers to loop (or not) at each callsite. This also avoid a leak possibility by avoiding circular references.
2021-03-26lei: support /dev/fd/[0-2] inputs and outputs in daemon
Since lei-daemon won't have the same FDs as the client, we need to special-case thse mappings and won't be able to open arbitrary, non-standard FDs. We also won't attempt to support /proc/self/fd/[0-2] since that's a Linux-ism. /dev/fd/[0-2] and /dev/std{in,out,err} are portable to FreeBSD, at least. mawk(1) also supports /dev/std{out,err}, as does gawk(1) (which supports everything we can support, and arbitrary /dev/fd/$FD).
2021-03-24lei: improve management around short-lived workers
Instead of creating a short-lived circular reference, ensure they don't exist in the first place. Note the following changes to hold an extra ref to $sto: - $self->_lei_store(1)->write_prepare($self); + my $sto = $self->_lei_store(1); + $sto->write_prepare($self); I'm not a perlguts expert, but I actually wanted to switch to the one-line version for LeiImport, but xt/lei-auth-fail.t was getting stuck for some reason. It seems the extra ref to the LeiStore ($sto) object is necessary.
2021-03-24lei: hide *_atfork_child from command-line
Otherwise we could get non-sensical results if somebody tries running "lei atfork_child" from the command-line.
2021-03-23lei: simplify workers_start and callers
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.
2021-03-22lei: simplify lazy-loading
This makes it slightly easier to implement future commands, since there'll be a couple more relatively self-contained ones.
2021-03-21lei: fix some warnings in tests
And then test the contents of $lei_err to ensure it doesn't happen again. We'll also make MboxLock emit nicer warnings without the line number, since the line number is irrelevant to the user fixing an mbox lock contention problem. Finally, we'll also allow showing loud warnings via TEST_LEI_ERR_LOUD=1
2021-03-01lei p2q: fix /dev/null filenames, fix phrase quoting rules
/dev/null mis-handling was reported by Kyle Meyer. Phrases quoting rules are also refined to avoid leaving spaces unquoted when "phrase generator" characters exist. Also, context-free hunk headers no longer clobber the in_diff state of the parser, since git can still generate those. Link: https://public-inbox.org/meta/87k0qrrhve.fsf@kyleam.com/
2021-03-01lei p2q: patch-to-query generator for "lei q --stdin"
Instead of teaching the to-be-implemented "lei show" to search threads/messages based commits, this orthogonal sub-command is designed to generate queries for use with "lei q --stdin". URI-escaped query parameters may be generated with --uri for HTTP(S) public-inbox instances, but otherwise the output is designed for "lei q --stdin". To find threads for a given git commit from a git worktree: lei p2q $COMMIT_OID | lei q --stdin -t ... It can also read via --stdin|- curl $INBOX_URL/$MSGID/raw | lei p2q - | lei q --stdin -t Or from the filesystem: lei p2q $(git format-patch -1) | lei q --stdin -t This defaults to only generating "dfpost:"-prefixed terms since I've found those most useful for finding messages relating to a commit. This is subject to change. --want=s@ is a comma-separated or multi-value list of prefixes that defaults to "dfpost7". Not all are implemented, yet, but s, dfn, dfpre, and dfpost all seem to mostly work. Phrase handling may need to be tweaked to work with Xapian. OR, NEAR, ADJ, AND, NOT may be used with --want (e.g. --want=dfpost,OR,dfn) Prefixing the field prefix with '+' or '-' (e.g. --want=+dfpost) generates "+dfpost:$EXTRACTED_OID" for Xapian. For non-boolean search prefixes, wildcard (*) may also be supplied: (--want=dfn*) For boolean search prefixes, suffixing the field prefix with a digit (e.g. --want=dfpost7) provides a minimum length, allowing truncated variations to be searched. This is helpful for finding older messages as git chooses longer dfpost|dfpre abbreviations as repos get larger. Automatic date range generation is not implemented, yet.