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 2828@ SuppressWarnings ({"unchecked" , "unused" })
2929public 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 *
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments