下面列出了io.grpc.MethodDescriptor#isSafe ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
NettyClientStream(
TransportState state,
MethodDescriptor<?, ?> method,
Metadata headers,
Channel channel,
AsciiString authority,
AsciiString scheme,
AsciiString userAgent,
StatsTraceContext statsTraceCtx,
TransportTracer transportTracer,
CallOptions callOptions,
boolean useGetForSafeMethods) {
super(
new NettyWritableBufferAllocator(channel.alloc()),
statsTraceCtx,
transportTracer,
headers,
callOptions,
useGetForSafeMethods && method.isSafe());
this.state = checkNotNull(state, "transportState");
this.writeQueue = state.handler.getWriteQueue();
this.method = checkNotNull(method, "method");
this.authority = checkNotNull(authority, "authority");
this.scheme = checkNotNull(scheme, "scheme");
this.userAgent = userAgent;
}
CronetClientStream(
final String url,
@Nullable String userAgent,
Executor executor,
final Metadata headers,
CronetClientTransport transport,
Runnable startCallback,
Object lock,
int maxMessageSize,
boolean alwaysUsePut,
MethodDescriptor<?, ?> method,
StatsTraceContext statsTraceCtx,
CallOptions callOptions,
TransportTracer transportTracer) {
super(
new CronetWritableBufferAllocator(), statsTraceCtx, transportTracer, headers, callOptions,
method.isSafe());
this.url = Preconditions.checkNotNull(url, "url");
this.userAgent = Preconditions.checkNotNull(userAgent, "userAgent");
this.statsTraceCtx = Preconditions.checkNotNull(statsTraceCtx, "statsTraceCtx");
this.executor = Preconditions.checkNotNull(executor, "executor");
this.headers = Preconditions.checkNotNull(headers, "headers");
this.transport = Preconditions.checkNotNull(transport, "transport");
this.startCallback = Preconditions.checkNotNull(startCallback, "startCallback");
this.idempotent = method.isIdempotent() || alwaysUsePut;
// Only delay flushing header for unary rpcs.
this.delayRequestHeader = (method.getType() == MethodDescriptor.MethodType.UNARY);
this.annotation = callOptions.getOption(CronetCallOptions.CRONET_ANNOTATION_KEY);
this.annotations = callOptions.getOption(CronetCallOptions.CRONET_ANNOTATIONS_KEY);
this.state = new TransportState(maxMessageSize, statsTraceCtx, lock, transportTracer);
}
OkHttpClientStream(
MethodDescriptor<?, ?> method,
Metadata headers,
AsyncFrameWriter frameWriter,
OkHttpClientTransport transport,
OutboundFlowController outboundFlow,
Object lock,
int maxMessageSize,
int initialWindowSize,
String authority,
String userAgent,
StatsTraceContext statsTraceCtx,
TransportTracer transportTracer,
CallOptions callOptions) {
super(
new OkHttpWritableBufferAllocator(),
statsTraceCtx,
transportTracer,
headers,
callOptions,
method.isSafe());
this.statsTraceCtx = checkNotNull(statsTraceCtx, "statsTraceCtx");
this.method = method;
this.authority = authority;
this.userAgent = userAgent;
// OkHttpClientStream is only created after the transport has finished connecting,
// so it is safe to read the transport attributes.
// We make a copy here for convenience, even though we can ask the transport.
this.attributes = transport.getAttributes();
this.state =
new TransportState(
maxMessageSize,
statsTraceCtx,
lock,
frameWriter,
outboundFlow,
transport,
initialWindowSize);
}
CronetClientStream(
final String url,
@Nullable String userAgent,
Executor executor,
final Metadata headers,
CronetClientTransport transport,
Runnable startCallback,
Object lock,
int maxMessageSize,
boolean alwaysUsePut,
MethodDescriptor<?, ?> method,
StatsTraceContext statsTraceCtx,
CallOptions callOptions,
TransportTracer transportTracer,
boolean useGetForSafeMethods,
boolean usePutForIdempotentMethods) {
super(
new CronetWritableBufferAllocator(), statsTraceCtx, transportTracer, headers, callOptions,
useGetForSafeMethods && method.isSafe());
this.url = Preconditions.checkNotNull(url, "url");
this.userAgent = Preconditions.checkNotNull(userAgent, "userAgent");
this.statsTraceCtx = Preconditions.checkNotNull(statsTraceCtx, "statsTraceCtx");
this.executor = Preconditions.checkNotNull(executor, "executor");
this.headers = Preconditions.checkNotNull(headers, "headers");
this.transport = Preconditions.checkNotNull(transport, "transport");
this.startCallback = Preconditions.checkNotNull(startCallback, "startCallback");
this.idempotent = (usePutForIdempotentMethods && method.isIdempotent()) || alwaysUsePut;
// Only delay flushing header for unary rpcs.
this.delayRequestHeader = (method.getType() == MethodDescriptor.MethodType.UNARY);
this.annotation = callOptions.getOption(CRONET_ANNOTATION_KEY);
this.annotations = callOptions.getOption(CRONET_ANNOTATIONS_KEY);
this.state = new TransportState(maxMessageSize, statsTraceCtx, lock, transportTracer);
// Tests expect the "plain" deframer behavior, not MigratingDeframer
// https://github.com/grpc/grpc-java/issues/7140
optimizeForDirectExecutor();
}
private static boolean useGet(MethodDescriptor<?, ?> method) {
return method.isSafe();
}
OkHttpClientStream(
MethodDescriptor<?, ?> method,
Metadata headers,
ExceptionHandlingFrameWriter frameWriter,
OkHttpClientTransport transport,
OutboundFlowController outboundFlow,
Object lock,
int maxMessageSize,
int initialWindowSize,
String authority,
String userAgent,
StatsTraceContext statsTraceCtx,
TransportTracer transportTracer,
CallOptions callOptions,
boolean useGetForSafeMethods) {
super(
new OkHttpWritableBufferAllocator(),
statsTraceCtx,
transportTracer,
headers,
callOptions,
useGetForSafeMethods && method.isSafe());
this.statsTraceCtx = checkNotNull(statsTraceCtx, "statsTraceCtx");
this.method = method;
this.authority = authority;
this.userAgent = userAgent;
// OkHttpClientStream is only created after the transport has finished connecting,
// so it is safe to read the transport attributes.
// We make a copy here for convenience, even though we can ask the transport.
this.attributes = transport.getAttributes();
this.state =
new TransportState(
maxMessageSize,
statsTraceCtx,
lock,
frameWriter,
outboundFlow,
transport,
initialWindowSize,
method.getFullMethodName());
// TODO(#7168): fix a potential data race using MigratingThreadDeframer in OkHttp.
// disabling MigratingThreadDeframer in OkHttp due to the race
optimizeForDirectExecutor();
}