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

nats-io / nats.java / #2109

15 Aug 2025 04:51PM UTC coverage: 95.404% (-0.05%) from 95.457%
#2109

push

github

web-flow
Merge pull request #1395 from nats-io/header-nullability

Header nullability

3 of 3 new or added lines in 1 file covered. (100.0%)

14 existing lines in 7 files now uncovered.

11915 of 12489 relevant lines covered (95.4%)

0.95 hits per line

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

96.43
/src/main/java/io/nats/client/api/KeyValueStatus.java
1
// Copyright 2021 The NATS Authors
2
// Licensed under the Apache License, Version 2.0 (the "License");
3
// you may not use this file except in compliance with the License.
4
// You may obtain a copy of the License at:
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software
9
// distributed under the License is distributed on an "AS IS" BASIS,
10
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
// See the License for the specific language governing permissions and
12
// limitations under the License.
13
package io.nats.client.api;
14

15
import io.nats.client.support.JsonValueUtils;
16
import org.jspecify.annotations.NonNull;
17
import org.jspecify.annotations.Nullable;
18

19
import java.time.Duration;
20
import java.util.Map;
21

22
/**
23
 * The KeyValueStatus class contains information about a Key Value Bucket.
24
 */
25
public class KeyValueStatus {
26

27
    private final StreamInfo streamInfo;
28
    private final KeyValueConfiguration config;
29

30
    public KeyValueStatus(StreamInfo si) {
1✔
31
        streamInfo = si;
1✔
32
        config = new KeyValueConfiguration(streamInfo.getConfiguration());
1✔
33
    }
1✔
34

35
    /**
36
     * Get the name of the bucket
37
     * @return the name
38
     */
39
    @NonNull
40
    public String getBucketName() {
41
        return config.getBucketName();
1✔
42
    }
43

44
    /**
45
     * Gets the description of this bucket.
46
     * @return the description of the bucket.
47
     */
48
    @Nullable
49
    public String getDescription() {
50
        return config.getDescription();
1✔
51
    }
52

53
    /**
54
     * Gets the info for the stream which backs the bucket. Valid for BackingStore "JetStream"
55
     * @return the stream info
56
     */
57
    @NonNull
58
    public StreamInfo getBackingStreamInfo() {
59
        return streamInfo;
1✔
60
    }
61

62
    /**
63
     * Gets the configuration object directly
64
     * @return the configuration.
65
     */
66
    @NonNull
67
    public KeyValueConfiguration getConfiguration() {
68
        return config;
1✔
69
    }
70

71
    /**
72
     * Get the number of total entries in the bucket, including historical entries
73
     * @return the count of entries
74
     */
75
    public long getEntryCount() {
76
        return streamInfo.getStreamState().getMsgCount();
1✔
77
    }
78

79
    /**
80
     * Get the size of the bucket in bytes
81
     * @return the number of bytes
82
     */
83
    public long getByteCount() {
84
        return streamInfo.getStreamState().getByteCount();
1✔
85
    }
86

87
    /**
88
     * Gets the maximum number of history for any one key. Includes the current value.
89
     * @return the maximum number of values for any one key.
90
     */
91
    public long getMaxHistoryPerKey() {
92
        return config.getMaxHistoryPerKey();
1✔
93
    }
94

95
    /**
96
     * Gets the maximum number of bytes for this bucket.
97
     * @return the maximum number of bytes for this bucket.
98
     */
99
    public long getMaxBucketSize() {
100
        return config.getMaxBucketSize();
1✔
101
    }
102

103
    /**
104
     * Gets the maximum size for an individual value in the bucket.
105
     * @deprecated the server value is a 32-bit signed value. Use {@link #getMaximumValueSize()} instead.
106
     * @return the maximum size a value.
107
     */
108
    @Deprecated
109
    public long getMaxValueSize() {
110
        return config.getMaximumValueSize();
1✔
111
    }
112

113
    /**
114
     * Gets the maximum size for an individual value in the bucket.
115
     * @return the maximum size a value.
116
     */
117
    public int getMaximumValueSize() {
118
        return config.getMaximumValueSize();
1✔
119
    }
120

121
    /**
122
     * Gets the maximum age for a value in this bucket.
123
     * @return the maximum age.
124
     */
125
    @Nullable
126
    public Duration getTtl() {
127
        return config.getTtl();
1✔
128
    }
129

130
    /**
131
     * Gets the storage type for this bucket.
132
     * @return the storage type for this stream.
133
     */
134
    @NonNull
135
    public StorageType getStorageType() {
136
        return config.getStorageType();
1✔
137
    }
138

139
    /**
140
     * Gets the number of replicas for this bucket.
141
     * @return the number of replicas
142
     */
143
    public int getReplicas() {
144
        return config.getReplicas();
1✔
145
    }
146

147
    /**
148
     * Gets the placement directive for the store.
149
     * @return the placement
150
     */
151
    @Nullable
152
    public Placement getPlacement() {
153
        return config.getPlacement();
1✔
154
    }
155

156
    /**
157
     * Gets the republish configuration
158
     * @return the republish object
159
     */
160
    @Nullable
161
    public Republish getRepublish() {
162
        return config.getRepublish();
1✔
163
    }
164

165
    /**
166
     * Gets the state of compression
167
     * @return true if compression is used
168
     */
169
    public boolean isCompressed() {
170
        return config.isCompressed();
1✔
171
    }
172

173
    /**
174
     * Get the metadata for the store
175
     * @return the metadata map. Might be null.
176
     */
177
    @Nullable
178
    public Map<String, String> getMetadata() {
179
        return config.getMetadata();
1✔
180
    }
181

182
    /**
183
     * Get the Limit Marker TTL duration or null if configured.
184
     * @return the duration.
185
     */
186
    @Nullable
187
    public Duration getLimitMarkerTtl() {
UNCOV
188
        return streamInfo.getConfig().getSubjectDeleteMarkerTtl();
×
189
    }
190

191
    /**
192
     * Gets the name of the type of backing store, currently only "JetStream"
193
     * @return the name of the store, currently only "JetStream"
194
     */
195
    @NonNull
196
    public String getBackingStore() {
197
        return "JetStream";
1✔
198
    }
199

200
    @Override
201
    public String toString() {
202
        JsonValueUtils.MapBuilder mb = new JsonValueUtils.MapBuilder();
1✔
203
        mb.put("entryCount", getEntryCount());
1✔
204
        mb.put("byteCount", getByteCount());
1✔
205
        mb.put("config", config);
1✔
206
        return "KeyValueStatus" + mb.toJsonValue().toJson();
1✔
207
    }
208
}
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