Created
October 29, 2019 19:58
-
-
Save carlosalberto/6e8cee95f59c7f65714bf69bb6972644 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------- Context API -------------- | |
// Based on top of grpc.Context | |
// (We could also use it directly and add the automatic Scope handling). | |
// Note: Cannot use String directly for the keys, as an imposition done | |
// by grpc.Context. | |
// Questions: | |
// - Should we allow some form of extensibility to allow | |
// users to provide logic/storage? | |
public final class Context { | |
public static Context current(); | |
public static Scope setCurrent(Context ctx); | |
public static Context getEmptyContext(); | |
public static <V> Context.Key<V> createKey(String name); | |
public <V> Context setValue(Context.Key<V>, V value); | |
public V getValue(Context.Key<V> key); | |
} | |
// ------------- Propagation API -------------- | |
public interface HttpInjector { | |
<C> void inject(Context ctx, C carrier, Setter<C> setter); | |
} | |
public interface HttpExtractor { | |
<C> Context extract(C carrrier, Getter<C> getter); | |
} | |
// ------------- Baggage API -------------- | |
// Questions: | |
// - Should we allow values other than String? | |
public interface BaggageSetter { | |
public Context setValue(Context ctx, String key, String value); | |
public Context setValue(String key, String value); // Context.current() | |
public String getValue(Context ctx, String key); | |
public String getValue(String key); // Context.current() | |
public void removeValue(Context ctx, String key); | |
public void removeValue(String key); // Context.current() | |
public void clear(Context ctx); | |
public void clear(); // Context.current() | |
public HttpInjector getHttpInjector(); | |
public HttpExtractor getHttpExtractor(); | |
} | |
// ------------- Observability API -------------- | |
public interface CorrelationSetter { | |
public Context setValue(Context ctx, <List>CorrelationLabel labels, HopLimit hopLimit); | |
public Context setValue(<List>CorrelationLabel labels, HopLimit hopLimit); // Context.current() | |
public HttpInjector getHttpInjector(); | |
public HttpExtractor getHttpExtractor(); | |
} | |
public CorrelationLabel { | |
public String key(); | |
public String value(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment