Skip to content

Commit 1da56f5

Browse files
authored
chore: change hint prexfix to x-greptime-hint- (#44)
1 parent 83096a0 commit 1da56f5

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

ingester-rpc/src/main/java/io/greptime/rpc/Context.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
@SuppressWarnings({"unchecked", "unused"})
2929
public class Context implements Copiable<Context> {
3030

31-
private static final String HINT_PREFIX = "x-greptime-hint:";
31+
private static final String HINT_PREFIX = "x-greptime-hint-";
3232

3333
private final Map<String, Object> ctx = new HashMap<>();
3434

@@ -99,6 +99,17 @@ public <T> T get(String key) {
9999
}
100100
}
101101

102+
/**
103+
* Gets the value of the specified hint key.
104+
*
105+
* @param key the hint key
106+
* @return the value
107+
* @param <T> the type of the value
108+
*/
109+
public <T> T getHint(String key) {
110+
return get(HINT_PREFIX + key);
111+
}
112+
102113
/**
103114
* Removes the specified key and its value form this {@link Context}.
104115
*

ingester-rpc/src/test/java/io/greptime/rpc/ContextTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public void ofShouldReturnContextWithOneEntryTest() {
3838
@Test
3939
public void hintShouldReturnContextWithHintEntryTest() {
4040
Context context = Context.hint("key", "value");
41-
Assert.assertEquals("value", context.get("x-greptime-hint:key"));
41+
Assert.assertEquals("value", context.getHint("key"));
42+
Assert.assertEquals("value", context.get("x-greptime-hint-key"));
4243
}
4344

4445
@Test
@@ -52,7 +53,8 @@ public void withShouldAddEntryToContextTest() {
5253
public void withHintShouldAddHintEntryToContextTest() {
5354
Context context = Context.newDefault();
5455
context.withHint("key", "value").with("key2", "value");
55-
Assert.assertEquals("value", context.get("x-greptime-hint:key"));
56+
Assert.assertEquals("value", context.get("x-greptime-hint-key"));
57+
Assert.assertEquals("value", context.getHint("key"));
5658
Assert.assertEquals("value", context.get("key2"));
5759
}
5860

0 commit comments

Comments
 (0)