services: allow config str to be passed into binlog object (#4919)

Do not require binlog str to be defined by env var.

This allows --flag=value styled configuration, which is more common
internally.
This commit is contained in:
zpencer 2018-10-08 15:44:18 -07:00 committed by GitHub
parent fc908e2dcc
commit f10676c2b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -38,6 +38,10 @@ class BinaryLogProviderImpl extends BinaryLogProvider {
this(new TempFileSink(), System.getenv("GRPC_BINARY_LOG_CONFIG"));
}
/**
* Deprecated and will be removed in a future version of gRPC.
*/
@Deprecated
public BinaryLogProviderImpl(BinaryLogSink sink) throws IOException {
this(sink, System.getenv("GRPC_BINARY_LOG_CONFIG"));
}
@ -48,7 +52,7 @@ class BinaryLogProviderImpl extends BinaryLogProvider {
* @param configStr config string to parse to determine logged methods and msg size limits.
* @throws IOException if initialization failed.
*/
BinaryLogProviderImpl(BinaryLogSink sink, String configStr) throws IOException {
public BinaryLogProviderImpl(BinaryLogSink sink, String configStr) throws IOException {
this.sink = Preconditions.checkNotNull(sink);
try {
factory = new BinlogHelper.FactoryImpl(sink, configStr);

View File

@ -32,11 +32,22 @@ public final class BinaryLogs {
}
/**
* Creates a binary log with a custom {@link BinaryLogSink} for receiving the logged data.
* Deprecated and will be removed in a future version of gRPC.
*/
@Deprecated
public static BinaryLog createBinaryLog(BinaryLogSink sink) throws IOException {
return new BinaryLogProviderImpl(sink);
}
/**
* Creates a binary log with a custom {@link BinaryLogSink} for receiving the logged data,
* and a config string as defined by
* <a href="https://github.com/grpc/proposal/blob/master/A16-binary-logging.md">
* A16-binary-logging</a>.
*/
public static BinaryLog createBinaryLog(BinaryLogSink sink, String configStr) throws IOException {
return new BinaryLogProviderImpl(sink, configStr);
}
private BinaryLogs() {}
}