File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
main/java/io/greptime/rpc
test/java/io/greptime/rpc Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 28
28
@ SuppressWarnings ({"unchecked" , "unused" })
29
29
public class Context implements Copiable <Context > {
30
30
31
- private static final String HINT_PREFIX = "x-greptime-hint: " ;
31
+ private static final String HINT_PREFIX = "x-greptime-hint- " ;
32
32
33
33
private final Map <String , Object > ctx = new HashMap <>();
34
34
@@ -99,6 +99,17 @@ public <T> T get(String key) {
99
99
}
100
100
}
101
101
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
+
102
113
/**
103
114
* Removes the specified key and its value form this {@link Context}.
104
115
*
Original file line number Diff line number Diff line change @@ -38,7 +38,8 @@ public void ofShouldReturnContextWithOneEntryTest() {
38
38
@ Test
39
39
public void hintShouldReturnContextWithHintEntryTest () {
40
40
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" ));
42
43
}
43
44
44
45
@ Test
@@ -52,7 +53,8 @@ public void withShouldAddEntryToContextTest() {
52
53
public void withHintShouldAddHintEntryToContextTest () {
53
54
Context context = Context .newDefault ();
54
55
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" ));
56
58
Assert .assertEquals ("value" , context .get ("key2" ));
57
59
}
58
60
You can’t perform that action at this time.
0 commit comments