• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanopub-query / 24669686981

20 Apr 2026 01:37PM UTC coverage: 60.242% (+0.3%) from 59.905%
24669686981

push

github

web-flow
Merge pull request #76 from knowledgepixels/feat/optional-repo-disables

feat: change 9 — optional per-instance disable of full/text/last30d repo writes

293 of 544 branches covered (53.86%)

Branch coverage included in aggregate %.

851 of 1355 relevant lines covered (62.8%)

8.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

40.0
src/main/java/com/knowledgepixels/query/FeatureFlags.java
1
package com.knowledgepixels.query;
2

3
/**
4
 * Operator-controlled feature flags, read from the environment on each call. Kept
5
 * as a central table so operator-controlled features have consistent naming and a
6
 * single place to audit. Both flags default to {@code true}, i.e. the feature is
7
 * enabled unless explicitly disabled.
8
 *
9
 * <p>Disabling a flag makes the corresponding feature's entry points no-op:
10
 * polling, materialisation, and auxiliary repo creation are all skipped. Callers
11
 * don't need individual guards — the gated methods handle the check internally.
12
 *
13
 * <p>{@link MainVerticle#start(io.vertx.core.Promise)} logs a WARN at startup
14
 * whenever either flag is {@code false}, so an accidentally-flagged production
15
 * image is never silent.
16
 *
17
 * <p>Flags are re-read on each call rather than cached in {@code static final}
18
 * fields — the per-call overhead is a single map lookup in
19
 * {@link Utils#getEnvString(String, String)}, and call-time evaluation avoids
20
 * awkward interactions with {@link org.mockito.Mockito#mockStatic} in tests.
21
 */
22
public final class FeatureFlags {
23

24
    /**
25
     * When {@code false}, the trust-state mirror is disabled:
26
     * {@link TrustStateLoader#bootstrap()} and
27
     * {@link TrustStateLoader#maybeUpdate(String)} become no-ops. The {@code trust}
28
     * repo is never auto-created and no trust-state snapshot is ever fetched.
29
     *
30
     * <p>Controlled by the {@code NANOPUB_QUERY_ENABLE_TRUST_STATE} environment
31
     * variable. Default: {@code true}.
32
     *
33
     * @return {@code true} if the trust-state mirror is enabled
34
     */
35
    public static boolean trustStateEnabled() {
36
        return "true".equalsIgnoreCase(
15✔
37
                Utils.getEnvString("NANOPUB_QUERY_ENABLE_TRUST_STATE", "true"));
3✔
38
    }
39

40
    /**
41
     * When {@code false}, all spaces-related work is disabled:
42
     * {@link NanopubLoader#detectAndRegisterSpaces},
43
     * {@link SpacesAdminStore#bootstrap},
44
     * {@link SpacesAdminStore#scanExistingSpaces}, and
45
     * {@link SpacesAdminStore#persistSpace} become no-ops. The {@code spaces} repo
46
     * is never auto-created and no space state is ever registered.
47
     *
48
     * <p>Controlled by the {@code NANOPUB_QUERY_ENABLE_SPACES} environment
49
     * variable. Default: {@code true}.
50
     *
51
     * @return {@code true} if spaces processing is enabled
52
     */
53
    public static boolean spacesEnabled() {
54
        return "true".equalsIgnoreCase(
15✔
55
                Utils.getEnvString("NANOPUB_QUERY_ENABLE_SPACES", "true"));
3✔
56
    }
57

58
    /**
59
     * When {@code false}, per-nanopub writes to the {@code full} repo are skipped
60
     * in {@link NanopubLoader#executeLoading}. The {@code full} repo is the
61
     * catch-all endpoint for generic SPARQL queries that aren't scoped by pubkey
62
     * or type; disabling it breaks those queries but removes one of the heavier
63
     * per-nanopub write targets. {@code pubkey_*} and {@code type_*} still get
64
     * the same {@code allStatements}, so per-pubkey / per-type queries still work.
65
     *
66
     * <p>Intended both as a throughput-measurement lever on a test instance and
67
     * as a deliberate per-instance production option for deployments that don't
68
     * need generic SPARQL.
69
     *
70
     * <p>Controlled by the {@code NANOPUB_QUERY_ENABLE_FULL_REPO} environment
71
     * variable. Default: {@code true}.
72
     *
73
     * @return {@code true} if writes to the {@code full} repo are enabled
74
     */
75
    public static boolean fullRepoEnabled() {
76
        return "true".equalsIgnoreCase(
×
77
                Utils.getEnvString("NANOPUB_QUERY_ENABLE_FULL_REPO", "true"));
×
78
    }
79

80
    /**
81
     * When {@code false}, per-nanopub writes to the {@code text} repo are skipped.
82
     * The {@code text} repo is Lucene-backed and supports full-text search via
83
     * {@code npa:hasFilterLiteral}; disabling it removes Lucene from the write
84
     * path entirely (the single largest per-nanopub cost in the repo fan-out),
85
     * at the price of breaking full-text search.
86
     *
87
     * <p>Controlled by the {@code NANOPUB_QUERY_ENABLE_TEXT_REPO} environment
88
     * variable. Default: {@code true}.
89
     *
90
     * @return {@code true} if writes to the {@code text} repo are enabled
91
     */
92
    public static boolean textRepoEnabled() {
93
        return "true".equalsIgnoreCase(
×
94
                Utils.getEnvString("NANOPUB_QUERY_ENABLE_TEXT_REPO", "true"));
×
95
    }
96

97
    /**
98
     * When {@code false}, per-nanopub writes to the {@code last30d} repo are
99
     * skipped, along with its hourly cleanup SPARQL. The repo serves recent-
100
     * nanopub queries; when disabled, the same queries can be expressed against
101
     * the {@code full} repo with a date filter on {@code dcterms:created}.
102
     *
103
     * <p>Controlled by the {@code NANOPUB_QUERY_ENABLE_LAST30D_REPO} environment
104
     * variable. Default: {@code true}.
105
     *
106
     * @return {@code true} if writes to the {@code last30d} repo are enabled
107
     */
108
    public static boolean last30dRepoEnabled() {
109
        return "true".equalsIgnoreCase(
×
110
                Utils.getEnvString("NANOPUB_QUERY_ENABLE_LAST30D_REPO", "true"));
×
111
    }
112

113
    private FeatureFlags() {
114
    }
115

116
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc