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

knowledgepixels / nanopub-query / 24888210076

24 Apr 2026 11:55AM UTC coverage: 64.515% (+5.3%) from 59.265%
24888210076

push

github

web-flow
Merge pull request #79 from knowledgepixels/feature/62-spaces-extraction-v2

feat: v2 spaces extraction layer (#62)

381 of 670 branches covered (56.87%)

Branch coverage included in aggregate %.

1028 of 1514 relevant lines covered (67.9%)

10.25 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: space-relevant
42
     * nanopubs are not extracted into {@code npa:spacesGraph}, the {@code spaces}
43
     * repo is never auto-created, and no space-state materialization runs.
44
     *
45
     * <p>Controlled by the {@code NANOPUB_QUERY_ENABLE_SPACES} environment
46
     * variable. Default: {@code true}.
47
     *
48
     * @return {@code true} if spaces processing is enabled
49
     */
50
    public static boolean spacesEnabled() {
51
        return "true".equalsIgnoreCase(
15✔
52
                Utils.getEnvString("NANOPUB_QUERY_ENABLE_SPACES", "true"));
3✔
53
    }
54

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

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

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

110
    private FeatureFlags() {
111
    }
112

113
}
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