]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/ExtSearch.pm
extsearch: wire up remaining Inbox-like methods for WWW
[public-inbox.git] / lib / PublicInbox / ExtSearch.pm
1 # Copyright (C) 2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3
4 # Read-only external (detached) index for cross inbox search.
5 # This is a read-only counterpart to PublicInbox::ExtSearchIdx
6 # and behaves like PublicInbox::Inbox AND PublicInbox::Search
7 package PublicInbox::ExtSearch;
8 use strict;
9 use v5.10.1;
10 use PublicInbox::Over;
11 use PublicInbox::Inbox;
12
13 # for ->reopen, ->mset, ->mset_to_artnums
14 use parent qw(PublicInbox::Search);
15
16 sub new {
17         my (undef, $topdir) = @_;
18         bless {
19                 topdir => $topdir,
20                 # xpfx => 'ei15'
21                 xpfx => "$topdir/ei".PublicInbox::Search::SCHEMA_VERSION
22         }, __PACKAGE__;
23 }
24
25 sub search { $_[0] } # self
26
27 # overrides PublicInbox::Search::_xdb
28 sub _xdb {
29         my ($self) = @_;
30         $self->xdb_sharded;
31 }
32
33 # same as per-inbox ->over, for now...
34 sub over {
35         my ($self) = @_;
36         $self->{over} //= PublicInbox::Over->new("$self->{xpfx}/over.sqlite3");
37 }
38
39 sub git {
40         my ($self) = @_;
41         $self->{git} //= PublicInbox::Git->new("$self->{topdir}/ALL.git");
42 }
43
44 sub mm { undef }
45
46 sub altid_map { {} }
47
48 sub description {
49         my ($self) = @_;
50         ($self->{description} //=
51                 PublicInbox::Inbox::cat_desc("$self->{topdir}/description")) //
52                 '$EINDEX_DIR/description missing';
53 }
54
55 sub cloneurl { [] } # TODO
56
57 sub base_url { 'https://example.com/TODO/' }
58 sub nntp_url { [] }
59
60 no warnings 'once';
61 *smsg_eml = \&PublicInbox::Inbox::smsg_eml;
62 *smsg_by_mid = \&PublicInbox::Inbox::smsg_by_mid;
63 *msg_by_mid = \&PublicInbox::Inbox::msg_by_mid;
64 *modified = \&PublicInbox::Inbox::modified;
65 *recent = \&PublicInbox::Inbox::recent;
66
67 *max_git_epoch = *nntp_usable = *msg_by_path = \&mm; # undef
68
69 1;