mirror of https://github.com/grpc/grpc.git
commit
4dc3c0bdd3
172 changed files with 12343 additions and 2018 deletions
@ -0,0 +1,36 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_IMPL_CODEGEN_SYNC_CUSTOM_H |
||||
#define GRPC_IMPL_CODEGEN_SYNC_CUSTOM_H |
||||
|
||||
#include <grpc/impl/codegen/sync_generic.h> |
||||
|
||||
/* Users defining GPR_CUSTOM_SYNC need to define the following macros. */ |
||||
|
||||
#ifdef GPR_CUSTOM_SYNC |
||||
|
||||
typedef GPR_CUSTOM_MU_TYPE gpr_mu; |
||||
typedef GPR_CUSTOM_CV_TYPE gpr_cv; |
||||
typedef GPR_CUSTOM_ONCE_TYPE gpr_once; |
||||
|
||||
#define GPR_ONCE_INIT GPR_CUSTOM_ONCE_INIT |
||||
|
||||
#endif |
||||
|
||||
#endif /* GRPC_IMPL_CODEGEN_SYNC_CUSTOM_H */ |
@ -0,0 +1,67 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#include "src/core/lib/debug/stats.h" |
||||
|
||||
#include <inttypes.h> |
||||
#include <string.h> |
||||
|
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/string_util.h> |
||||
#include <grpc/support/useful.h> |
||||
|
||||
#include "src/core/lib/support/string.h" |
||||
|
||||
grpc_stats_data *grpc_stats_per_cpu_storage = NULL; |
||||
static size_t g_num_cores; |
||||
|
||||
void grpc_stats_init(void) { |
||||
g_num_cores = GPR_MAX(1, gpr_cpu_num_cores()); |
||||
grpc_stats_per_cpu_storage = |
||||
gpr_zalloc(sizeof(grpc_stats_data) * g_num_cores); |
||||
} |
||||
|
||||
void grpc_stats_shutdown(void) { gpr_free(grpc_stats_per_cpu_storage); } |
||||
|
||||
void grpc_stats_collect(grpc_stats_data *output) { |
||||
memset(output, 0, sizeof(*output)); |
||||
for (size_t core = 0; core < g_num_cores; core++) { |
||||
for (size_t i = 0; i < GRPC_STATS_COUNTER_COUNT; i++) { |
||||
output->counters[i] += gpr_atm_no_barrier_load( |
||||
&grpc_stats_per_cpu_storage[core].counters[i]); |
||||
} |
||||
} |
||||
} |
||||
|
||||
char *grpc_stats_data_as_json(const grpc_stats_data *data) { |
||||
gpr_strvec v; |
||||
char *tmp; |
||||
bool is_first = true; |
||||
gpr_strvec_init(&v); |
||||
gpr_strvec_add(&v, gpr_strdup("{")); |
||||
for (size_t i = 0; i < GRPC_STATS_COUNTER_COUNT; i++) { |
||||
gpr_asprintf(&tmp, "%s\"%s\": %" PRIdPTR, is_first ? "" : ", ", |
||||
grpc_stats_counter_name[i], data->counters[i]); |
||||
gpr_strvec_add(&v, tmp); |
||||
is_first = false; |
||||
} |
||||
gpr_strvec_add(&v, gpr_strdup("}")); |
||||
tmp = gpr_strvec_flatten(&v, NULL); |
||||
gpr_strvec_destroy(&v); |
||||
return tmp; |
||||
} |
@ -0,0 +1,44 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_LIB_DEBUG_STATS_H |
||||
#define GRPC_CORE_LIB_DEBUG_STATS_H |
||||
|
||||
#include <grpc/support/atm.h> |
||||
#include "src/core/lib/debug/stats_data.h" |
||||
#include "src/core/lib/iomgr/exec_ctx.h" |
||||
|
||||
typedef struct grpc_stats_data { |
||||
gpr_atm counters[GRPC_STATS_COUNTER_COUNT]; |
||||
} grpc_stats_data; |
||||
|
||||
extern grpc_stats_data *grpc_stats_per_cpu_storage; |
||||
|
||||
#define GRPC_THREAD_STATS_DATA(exec_ctx) \ |
||||
(&grpc_stats_per_cpu_storage[(exec_ctx)->starting_cpu]) |
||||
|
||||
#define GRPC_STATS_INC_COUNTER(exec_ctx, ctr) \ |
||||
(gpr_atm_no_barrier_fetch_add( \
|
||||
&GRPC_THREAD_STATS_DATA((exec_ctx))->counters[(ctr)], 1)) |
||||
|
||||
void grpc_stats_init(void); |
||||
void grpc_stats_shutdown(void); |
||||
void grpc_stats_collect(grpc_stats_data *output); |
||||
char *grpc_stats_data_as_json(const grpc_stats_data *data); |
||||
|
||||
#endif |
@ -0,0 +1,25 @@ |
||||
/*
|
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
/*
|
||||
* Automatically generated by tools/codegen/core/gen_stats_data.py |
||||
*/ |
||||
|
||||
#include "src/core/lib/debug/stats_data.h" |
||||
const char *grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT] = { |
||||
"client_calls_created", "server_calls_created", "syscall_write", |
||||
"syscall_read", "syscall_poll", "syscall_wait", |
||||
}; |
@ -0,0 +1,47 @@ |
||||
/*
|
||||
* Copyright 2017 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
/*
|
||||
* Automatically generated by tools/codegen/core/gen_stats_data.py |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_LIB_DEBUG_STATS_DATA_H |
||||
#define GRPC_CORE_LIB_DEBUG_STATS_DATA_H |
||||
|
||||
typedef enum { |
||||
GRPC_STATS_COUNTER_CLIENT_CALLS_CREATED, |
||||
GRPC_STATS_COUNTER_SERVER_CALLS_CREATED, |
||||
GRPC_STATS_COUNTER_SYSCALL_WRITE, |
||||
GRPC_STATS_COUNTER_SYSCALL_READ, |
||||
GRPC_STATS_COUNTER_SYSCALL_POLL, |
||||
GRPC_STATS_COUNTER_SYSCALL_WAIT, |
||||
GRPC_STATS_COUNTER_COUNT |
||||
} grpc_stats_counters; |
||||
#define GRPC_STATS_INC_CLIENT_CALLS_CREATED(exec_ctx) \ |
||||
GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_CLIENT_CALLS_CREATED) |
||||
#define GRPC_STATS_INC_SERVER_CALLS_CREATED(exec_ctx) \ |
||||
GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SERVER_CALLS_CREATED) |
||||
#define GRPC_STATS_INC_SYSCALL_WRITE(exec_ctx) \ |
||||
GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_WRITE) |
||||
#define GRPC_STATS_INC_SYSCALL_READ(exec_ctx) \ |
||||
GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_READ) |
||||
#define GRPC_STATS_INC_SYSCALL_POLL(exec_ctx) \ |
||||
GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_POLL) |
||||
#define GRPC_STATS_INC_SYSCALL_WAIT(exec_ctx) \ |
||||
GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_WAIT) |
||||
extern const char *grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT]; |
||||
|
||||
#endif /* GRPC_CORE_LIB_DEBUG_STATS_DATA_H */ |
@ -0,0 +1,9 @@ |
||||
# Stats data declaration |
||||
# use tools/codegen/core/gen_stats_data.py to turn this into stats_data.h |
||||
|
||||
- counter: client_calls_created |
||||
- counter: server_calls_created |
||||
- counter: syscall_write |
||||
- counter: syscall_read |
||||
- counter: syscall_poll |
||||
- counter: syscall_wait |
@ -0,0 +1,20 @@ |
||||
# Copyright 2017 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
from grpc_testing._server import _server |
||||
|
||||
|
||||
def server_from_dictionary(descriptors_to_servicers, time): |
||||
return _server.server_from_descriptor_to_servicers( |
||||
descriptors_to_servicers, time) |
@ -0,0 +1,215 @@ |
||||
# Copyright 2017 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
import abc |
||||
import threading |
||||
|
||||
import grpc |
||||
from grpc_testing import _common |
||||
|
||||
_CLIENT_INACTIVE = object() |
||||
|
||||
|
||||
class Handler(_common.ServerRpcHandler): |
||||
|
||||
@abc.abstractmethod |
||||
def initial_metadata(self): |
||||
raise NotImplementedError() |
||||
|
||||
@abc.abstractmethod |
||||
def add_request(self, request): |
||||
raise NotImplementedError() |
||||
|
||||
@abc.abstractmethod |
||||
def take_response(self): |
||||
raise NotImplementedError() |
||||
|
||||
@abc.abstractmethod |
||||
def requests_closed(self): |
||||
raise NotImplementedError() |
||||
|
||||
@abc.abstractmethod |
||||
def cancel(self): |
||||
raise NotImplementedError() |
||||
|
||||
@abc.abstractmethod |
||||
def unary_response_termination(self): |
||||
raise NotImplementedError() |
||||
|
||||
@abc.abstractmethod |
||||
def stream_response_termination(self): |
||||
raise NotImplementedError() |
||||
|
||||
|
||||
class _Handler(Handler): |
||||
|
||||
def __init__(self, requests_closed): |
||||
self._condition = threading.Condition() |
||||
self._requests = [] |
||||
self._requests_closed = requests_closed |
||||
self._initial_metadata = None |
||||
self._responses = [] |
||||
self._trailing_metadata = None |
||||
self._code = None |
||||
self._details = None |
||||
self._unary_response = None |
||||
self._expiration_future = None |
||||
self._termination_callbacks = [] |
||||
|
||||
def send_initial_metadata(self, initial_metadata): |
||||
with self._condition: |
||||
self._initial_metadata = initial_metadata |
||||
self._condition.notify_all() |
||||
|
||||
def take_request(self): |
||||
with self._condition: |
||||
while True: |
||||
if self._code is None: |
||||
if self._requests: |
||||
request = self._requests.pop(0) |
||||
self._condition.notify_all() |
||||
return _common.ServerRpcRead(request, False, False) |
||||
elif self._requests_closed: |
||||
return _common.REQUESTS_CLOSED |
||||
else: |
||||
self._condition.wait() |
||||
else: |
||||
return _common.TERMINATED |
||||
|
||||
def is_active(self): |
||||
with self._condition: |
||||
return self._code is None |
||||
|
||||
def add_response(self, response): |
||||
with self._condition: |
||||
self._responses.append(response) |
||||
self._condition.notify_all() |
||||
|
||||
def send_termination(self, trailing_metadata, code, details): |
||||
with self._condition: |
||||
self._trailing_metadata = trailing_metadata |
||||
self._code = code |
||||
self._details = details |
||||
if self._expiration_future is not None: |
||||
self._expiration_future.cancel() |
||||
self._condition.notify_all() |
||||
|
||||
def add_termination_callback(self, termination_callback): |
||||
with self._condition: |
||||
if self._code is None: |
||||
self._termination_callbacks.append(termination_callback) |
||||
return True |
||||
else: |
||||
return False |
||||
|
||||
def initial_metadata(self): |
||||
with self._condition: |
||||
while True: |
||||
if self._initial_metadata is None: |
||||
if self._code is None: |
||||
self._condition.wait() |
||||
else: |
||||
raise ValueError( |
||||
'No initial metadata despite status code!') |
||||
else: |
||||
return self._initial_metadata |
||||
|
||||
def add_request(self, request): |
||||
with self._condition: |
||||
self._requests.append(request) |
||||
self._condition.notify_all() |
||||
|
||||
def take_response(self): |
||||
with self._condition: |
||||
while True: |
||||
if self._responses: |
||||
response = self._responses.pop(0) |
||||
self._condition.notify_all() |
||||
return response |
||||
elif self._code is None: |
||||
self._condition.wait() |
||||
else: |
||||
raise ValueError('No more responses!') |
||||
|
||||
def requests_closed(self): |
||||
with self._condition: |
||||
self._requests_closed = True |
||||
self._condition.notify_all() |
||||
|
||||
def cancel(self): |
||||
with self._condition: |
||||
if self._code is None: |
||||
self._code = _CLIENT_INACTIVE |
||||
termination_callbacks = self._termination_callbacks |
||||
self._termination_callbacks = None |
||||
if self._expiration_future is not None: |
||||
self._expiration_future.cancel() |
||||
self._condition.notify_all() |
||||
for termination_callback in termination_callbacks: |
||||
termination_callback() |
||||
|
||||
def unary_response_termination(self): |
||||
with self._condition: |
||||
while True: |
||||
if self._code is _CLIENT_INACTIVE: |
||||
raise ValueError('Huh? Cancelled but wanting status?') |
||||
elif self._code is None: |
||||
self._condition.wait() |
||||
else: |
||||
if self._unary_response is None: |
||||
if self._responses: |
||||
self._unary_response = self._responses.pop(0) |
||||
return ( |
||||
self._unary_response, self._trailing_metadata, |
||||
self._code, self._details,) |
||||
|
||||
|
||||
def stream_response_termination(self): |
||||
with self._condition: |
||||
while True: |
||||
if self._code is _CLIENT_INACTIVE: |
||||
raise ValueError('Huh? Cancelled but wanting status?') |
||||
elif self._code is None: |
||||
self._condition.wait() |
||||
else: |
||||
return self._trailing_metadata, self._code, self._details, |
||||
|
||||
def expire(self): |
||||
with self._condition: |
||||
if self._code is None: |
||||
if self._initial_metadata is None: |
||||
self._initial_metadata = _common.FUSSED_EMPTY_METADATA |
||||
self._trailing_metadata = _common.FUSSED_EMPTY_METADATA |
||||
self._code = grpc.StatusCode.DEADLINE_EXCEEDED |
||||
self._details = 'Took too much time!' |
||||
termination_callbacks = self._termination_callbacks |
||||
self._termination_callbacks = None |
||||
self._condition.notify_all() |
||||
for termination_callback in termination_callbacks: |
||||
termination_callback() |
||||
|
||||
def set_expiration_future(self, expiration_future): |
||||
with self._condition: |
||||
self._expiration_future = expiration_future |
||||
|
||||
|
||||
def handler_without_deadline(requests_closed): |
||||
return _Handler(requests_closed) |
||||
|
||||
|
||||
def handler_with_deadline(requests_closed, time, deadline): |
||||
handler = _Handler(requests_closed) |
||||
expiration_future = time.call_at(handler.expire, deadline) |
||||
handler.set_expiration_future(expiration_future) |
||||
return handler |
@ -0,0 +1,153 @@ |
||||
# Copyright 2017 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
import logging |
||||
import threading |
||||
|
||||
import grpc |
||||
from grpc_testing import _common |
||||
|
||||
|
||||
class Rpc(object): |
||||
|
||||
def __init__(self, handler, invocation_metadata): |
||||
self._condition = threading.Condition() |
||||
self._handler = handler |
||||
self._invocation_metadata = invocation_metadata |
||||
self._initial_metadata_sent = False |
||||
self._pending_trailing_metadata = None |
||||
self._pending_code = None |
||||
self._pending_details = None |
||||
self._callbacks = [] |
||||
self._active = True |
||||
self._rpc_errors = [] |
||||
|
||||
def _ensure_initial_metadata_sent(self): |
||||
if not self._initial_metadata_sent: |
||||
self._handler.send_initial_metadata(_common.FUSSED_EMPTY_METADATA) |
||||
self._initial_metadata_sent = True |
||||
|
||||
def _call_back(self): |
||||
callbacks = tuple(self._callbacks) |
||||
self._callbacks = None |
||||
|
||||
def call_back(): |
||||
for callback in callbacks: |
||||
try: |
||||
callback() |
||||
except Exception: # pylint: disable=broad-except |
||||
logging.exception('Exception calling server-side callback!') |
||||
|
||||
callback_calling_thread = threading.Thread(target=call_back) |
||||
callback_calling_thread.start() |
||||
|
||||
def _terminate(self, trailing_metadata, code, details): |
||||
if self._active: |
||||
self._active = False |
||||
self._handler.send_termination(trailing_metadata, code, details) |
||||
self._call_back() |
||||
self._condition.notify_all() |
||||
|
||||
def _complete(self): |
||||
if self._pending_trailing_metadata is None: |
||||
trailing_metadata = _common.FUSSED_EMPTY_METADATA |
||||
else: |
||||
trailing_metadata = self._pending_trailing_metadata |
||||
if self._pending_code is None: |
||||
code = grpc.StatusCode.OK |
||||
else: |
||||
code = self._pending_code |
||||
details = '' if self._pending_details is None else self._pending_details |
||||
self._terminate(trailing_metadata, code, details) |
||||
|
||||
def _abort(self, code, details): |
||||
self._terminate(_common.FUSSED_EMPTY_METADATA, code, details) |
||||
|
||||
def add_rpc_error(self, rpc_error): |
||||
with self._condition: |
||||
self._rpc_errors.append(rpc_error) |
||||
|
||||
def application_cancel(self): |
||||
with self._condition: |
||||
self._abort( |
||||
grpc.StatusCode.CANCELLED, |
||||
'Cancelled by server-side application!') |
||||
|
||||
def application_exception_abort(self, exception): |
||||
with self._condition: |
||||
if exception not in self._rpc_errors: |
||||
logging.exception('Exception calling application!') |
||||
self._abort( |
||||
grpc.StatusCode.UNKNOWN, |
||||
'Exception calling application: {}'.format(exception)) |
||||
|
||||
def extrinsic_abort(self): |
||||
with self._condition: |
||||
if self._active: |
||||
self._active = False |
||||
self._call_back() |
||||
self._condition.notify_all() |
||||
|
||||
def unary_response_complete(self, response): |
||||
with self._condition: |
||||
self._ensure_initial_metadata_sent() |
||||
self._handler.add_response(response) |
||||
self._complete() |
||||
|
||||
def stream_response(self, response): |
||||
with self._condition: |
||||
self._ensure_initial_metadata_sent() |
||||
self._handler.add_response(response) |
||||
|
||||
def stream_response_complete(self): |
||||
with self._condition: |
||||
self._ensure_initial_metadata_sent() |
||||
self._complete() |
||||
|
||||
def send_initial_metadata(self, initial_metadata): |
||||
with self._condition: |
||||
if self._initial_metadata_sent: |
||||
return False |
||||
else: |
||||
self._handler.send_initial_metadata(initial_metadata) |
||||
self._initial_metadata_sent = True |
||||
return True |
||||
|
||||
def is_active(self): |
||||
with self._condition: |
||||
return self._active |
||||
|
||||
def add_callback(self, callback): |
||||
with self._condition: |
||||
if self._callbacks is None: |
||||
return False |
||||
else: |
||||
self._callbacks.append(callback) |
||||
return True |
||||
|
||||
def invocation_metadata(self): |
||||
with self._condition: |
||||
return self._invocation_metadata |
||||
|
||||
def set_trailing_metadata(self, trailing_metadata): |
||||
with self._condition: |
||||
self._pending_trailing_metadata = trailing_metadata |
||||
|
||||
def set_code(self, code): |
||||
with self._condition: |
||||
self._pending_code = code |
||||
|
||||
def set_details(self, details): |
||||
with self._condition: |
||||
self._pending_details = details |
@ -0,0 +1,149 @@ |
||||
# Copyright 2017 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
import threading |
||||
|
||||
import grpc_testing |
||||
from grpc_testing import _common |
||||
from grpc_testing._server import _handler |
||||
from grpc_testing._server import _rpc |
||||
from grpc_testing._server import _server_rpc |
||||
from grpc_testing._server import _service |
||||
from grpc_testing._server import _servicer_context |
||||
|
||||
|
||||
def _implementation(descriptors_to_servicers, method_descriptor): |
||||
servicer = descriptors_to_servicers[method_descriptor.containing_service] |
||||
return getattr(servicer, method_descriptor.name) |
||||
|
||||
|
||||
def _unary_unary_service(request): |
||||
def service(implementation, rpc, servicer_context): |
||||
_service.unary_unary( |
||||
implementation, rpc, request, servicer_context) |
||||
return service |
||||
|
||||
|
||||
def _unary_stream_service(request): |
||||
def service(implementation, rpc, servicer_context): |
||||
_service.unary_stream( |
||||
implementation, rpc, request, servicer_context) |
||||
return service |
||||
|
||||
|
||||
def _stream_unary_service(handler): |
||||
def service(implementation, rpc, servicer_context): |
||||
_service.stream_unary(implementation, rpc, handler, servicer_context) |
||||
return service |
||||
|
||||
|
||||
def _stream_stream_service(handler): |
||||
def service(implementation, rpc, servicer_context): |
||||
_service.stream_stream(implementation, rpc, handler, servicer_context) |
||||
return service |
||||
|
||||
|
||||
class _Serverish(_common.Serverish): |
||||
|
||||
def __init__(self, descriptors_to_servicers, time): |
||||
self._descriptors_to_servicers = descriptors_to_servicers |
||||
self._time = time |
||||
|
||||
def _invoke( |
||||
self, service_behavior, method_descriptor, handler, |
||||
invocation_metadata, deadline): |
||||
implementation = _implementation( |
||||
self._descriptors_to_servicers, method_descriptor) |
||||
rpc = _rpc.Rpc(handler, invocation_metadata) |
||||
if handler.add_termination_callback(rpc.extrinsic_abort): |
||||
servicer_context = _servicer_context.ServicerContext( |
||||
rpc, self._time, deadline) |
||||
service_thread = threading.Thread( |
||||
target=service_behavior, |
||||
args=(implementation, rpc, servicer_context,)) |
||||
service_thread.start() |
||||
|
||||
def invoke_unary_unary( |
||||
self, method_descriptor, handler, invocation_metadata, request, |
||||
deadline): |
||||
self._invoke( |
||||
_unary_unary_service(request), method_descriptor, handler, |
||||
invocation_metadata, deadline) |
||||
|
||||
def invoke_unary_stream( |
||||
self, method_descriptor, handler, invocation_metadata, request, |
||||
deadline): |
||||
self._invoke( |
||||
_unary_stream_service(request), method_descriptor, handler, |
||||
invocation_metadata, deadline) |
||||
|
||||
def invoke_stream_unary( |
||||
self, method_descriptor, handler, invocation_metadata, deadline): |
||||
self._invoke( |
||||
_stream_unary_service(handler), method_descriptor, handler, |
||||
invocation_metadata, deadline) |
||||
|
||||
def invoke_stream_stream( |
||||
self, method_descriptor, handler, invocation_metadata, deadline): |
||||
self._invoke( |
||||
_stream_stream_service(handler), method_descriptor, handler, |
||||
invocation_metadata, deadline) |
||||
|
||||
|
||||
def _deadline_and_handler(requests_closed, time, timeout): |
||||
if timeout is None: |
||||
return None, _handler.handler_without_deadline(requests_closed) |
||||
else: |
||||
deadline = time.time() + timeout |
||||
handler = _handler.handler_with_deadline(requests_closed, time, deadline) |
||||
return deadline, handler |
||||
|
||||
|
||||
class _Server(grpc_testing.Server): |
||||
|
||||
def __init__(self, serverish, time): |
||||
self._serverish = serverish |
||||
self._time = time |
||||
|
||||
def invoke_unary_unary( |
||||
self, method_descriptor, invocation_metadata, request, timeout): |
||||
deadline, handler = _deadline_and_handler(True, self._time, timeout) |
||||
self._serverish.invoke_unary_unary( |
||||
method_descriptor, handler, invocation_metadata, request, deadline) |
||||
return _server_rpc.UnaryUnaryServerRpc(handler) |
||||
|
||||
def invoke_unary_stream( |
||||
self, method_descriptor, invocation_metadata, request, timeout): |
||||
deadline, handler = _deadline_and_handler(True, self._time, timeout) |
||||
self._serverish.invoke_unary_stream( |
||||
method_descriptor, handler, invocation_metadata, request, deadline) |
||||
return _server_rpc.UnaryStreamServerRpc(handler) |
||||
|
||||
def invoke_stream_unary( |
||||
self, method_descriptor, invocation_metadata, timeout): |
||||
deadline, handler = _deadline_and_handler(False, self._time, timeout) |
||||
self._serverish.invoke_stream_unary( |
||||
method_descriptor, handler, invocation_metadata, deadline) |
||||
return _server_rpc.StreamUnaryServerRpc(handler) |
||||
|
||||
def invoke_stream_stream( |
||||
self, method_descriptor, invocation_metadata, timeout): |
||||
deadline, handler = _deadline_and_handler(False, self._time, timeout) |
||||
self._serverish.invoke_stream_stream( |
||||
method_descriptor, handler, invocation_metadata, deadline) |
||||
return _server_rpc.StreamStreamServerRpc(handler) |
||||
|
||||
|
||||
def server_from_descriptor_to_servicers(descriptors_to_servicers, time): |
||||
return _Server(_Serverish(descriptors_to_servicers, time), time) |
@ -0,0 +1,93 @@ |
||||
# Copyright 2017 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
import grpc_testing |
||||
|
||||
|
||||
class UnaryUnaryServerRpc(grpc_testing.UnaryUnaryServerRpc): |
||||
|
||||
def __init__(self, handler): |
||||
self._handler = handler |
||||
|
||||
def initial_metadata(self): |
||||
return self._handler.initial_metadata() |
||||
|
||||
def cancel(self): |
||||
self._handler.cancel() |
||||
|
||||
def termination(self): |
||||
return self._handler.unary_response_termination() |
||||
|
||||
|
||||
class UnaryStreamServerRpc(grpc_testing.UnaryStreamServerRpc): |
||||
|
||||
def __init__(self, handler): |
||||
self._handler = handler |
||||
|
||||
def initial_metadata(self): |
||||
return self._handler.initial_metadata() |
||||
|
||||
def take_response(self): |
||||
return self._handler.take_response() |
||||
|
||||
def cancel(self): |
||||
self._handler.cancel() |
||||
|
||||
def termination(self): |
||||
return self._handler.stream_response_termination() |
||||
|
||||
|
||||
class StreamUnaryServerRpc(grpc_testing.StreamUnaryServerRpc): |
||||
|
||||
def __init__(self, handler): |
||||
self._handler = handler |
||||
|
||||
def initial_metadata(self): |
||||
return self._handler.initial_metadata() |
||||
|
||||
def send_request(self, request): |
||||
self._handler.add_request(request) |
||||
|
||||
def requests_closed(self): |
||||
self._handler.requests_closed() |
||||
|
||||
def cancel(self): |
||||
self._handler.cancel() |
||||
|
||||
def termination(self): |
||||
return self._handler.unary_response_termination() |
||||
|
||||
|
||||
class StreamStreamServerRpc(grpc_testing.StreamStreamServerRpc): |
||||
|
||||
def __init__(self, handler): |
||||
self._handler = handler |
||||
|
||||
def initial_metadata(self): |
||||
return self._handler.initial_metadata() |
||||
|
||||
def send_request(self, request): |
||||
self._handler.add_request(request) |
||||
|
||||
def requests_closed(self): |
||||
self._handler.requests_closed() |
||||
|
||||
def take_response(self): |
||||
return self._handler.take_response() |
||||
|
||||
def cancel(self): |
||||
self._handler.cancel() |
||||
|
||||
def termination(self): |
||||
return self._handler.stream_response_termination() |
@ -0,0 +1,88 @@ |
||||
# Copyright 2017 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
import grpc |
||||
|
||||
|
||||
class _RequestIterator(object): |
||||
|
||||
def __init__(self, rpc, handler): |
||||
self._rpc = rpc |
||||
self._handler = handler |
||||
|
||||
def _next(self): |
||||
read = self._handler.take_request() |
||||
if read.requests_closed: |
||||
raise StopIteration() |
||||
elif read.terminated: |
||||
rpc_error = grpc.RpcError() |
||||
self._rpc.add_rpc_error(rpc_error) |
||||
raise rpc_error |
||||
else: |
||||
return read.request |
||||
|
||||
def __iter__(self): |
||||
return self |
||||
|
||||
def __next__(self): |
||||
return self._next() |
||||
|
||||
def next(self): |
||||
return self._next() |
||||
|
||||
|
||||
def _unary_response(argument, implementation, rpc, servicer_context): |
||||
try: |
||||
response = implementation(argument, servicer_context) |
||||
except Exception as exception: # pylint: disable=broad-except |
||||
rpc.application_exception_abort(exception) |
||||
else: |
||||
rpc.unary_response_complete(response) |
||||
|
||||
|
||||
def _stream_response(argument, implementation, rpc, servicer_context): |
||||
try: |
||||
response_iterator = implementation(argument, servicer_context) |
||||
except Exception as exception: # pylint: disable=broad-except |
||||
rpc.application_exception_abort(exception) |
||||
else: |
||||
while True: |
||||
try: |
||||
response = next(response_iterator) |
||||
except StopIteration: |
||||
rpc.stream_response_complete() |
||||
break |
||||
except Exception as exception: # pylint: disable=broad-except |
||||
rpc.application_exception_abort(exception) |
||||
break |
||||
else: |
||||
rpc.stream_response(response) |
||||
|
||||
|
||||
def unary_unary(implementation, rpc, request, servicer_context): |
||||
_unary_response(request, implementation, rpc, servicer_context) |
||||
|
||||
|
||||
def unary_stream(implementation, rpc, request, servicer_context): |
||||
_stream_response(request, implementation, rpc, servicer_context) |
||||
|
||||
|
||||
def stream_unary(implementation, rpc, handler, servicer_context): |
||||
_unary_response( |
||||
_RequestIterator(rpc, handler), implementation, rpc, servicer_context) |
||||
|
||||
|
||||
def stream_stream(implementation, rpc, handler, servicer_context): |
||||
_stream_response( |
||||
_RequestIterator(rpc, handler), implementation, rpc, servicer_context) |
@ -0,0 +1,74 @@ |
||||
# Copyright 2017 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
import grpc |
||||
from grpc_testing import _common |
||||
|
||||
|
||||
class ServicerContext(grpc.ServicerContext): |
||||
|
||||
def __init__(self, rpc, time, deadline): |
||||
self._rpc = rpc |
||||
self._time = time |
||||
self._deadline = deadline |
||||
|
||||
def is_active(self): |
||||
return self._rpc.is_active() |
||||
|
||||
def time_remaining(self): |
||||
if self._rpc.is_active(): |
||||
if self._deadline is None: |
||||
return None |
||||
else: |
||||
return max(0.0, self._deadline - self._time.time()) |
||||
else: |
||||
return 0.0 |
||||
|
||||
def cancel(self): |
||||
self._rpc.application_cancel() |
||||
|
||||
def add_callback(self, callback): |
||||
return self._rpc.add_callback(callback) |
||||
|
||||
def invocation_metadata(self): |
||||
return self._rpc.invocation_metadata() |
||||
|
||||
def peer(self): |
||||
raise NotImplementedError() |
||||
|
||||
def peer_identities(self): |
||||
raise NotImplementedError() |
||||
|
||||
def peer_identity_key(self): |
||||
raise NotImplementedError() |
||||
|
||||
def auth_context(self): |
||||
raise NotImplementedError() |
||||
|
||||
def send_initial_metadata(self, initial_metadata): |
||||
initial_metadata_sent = self._rpc.send_initial_metadata( |
||||
_common.fuss_with_metadata(initial_metadata)) |
||||
if not initial_metadata_sent: |
||||
raise ValueError( |
||||
'ServicerContext.send_initial_metadata called too late!') |
||||
|
||||
def set_trailing_metadata(self, trailing_metadata): |
||||
self._rpc.set_trailing_metadata( |
||||
_common.fuss_with_metadata(trailing_metadata)) |
||||
|
||||
def set_code(self, code): |
||||
self._rpc.set_code(code) |
||||
|
||||
def set_details(self, details): |
||||
self._rpc.set_details(details) |
@ -0,0 +1,66 @@ |
||||
# Copyright 2017 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
"""An example gRPC Python-using server-side application.""" |
||||
|
||||
import grpc |
||||
|
||||
# requests_pb2 is a semantic dependency of this module. |
||||
from tests.testing import _application_common |
||||
from tests.testing.proto import requests_pb2 # pylint: disable=unused-import |
||||
from tests.testing.proto import services_pb2 |
||||
from tests.testing.proto import services_pb2_grpc |
||||
|
||||
|
||||
class FirstServiceServicer(services_pb2_grpc.FirstServiceServicer): |
||||
"""Services RPCs.""" |
||||
|
||||
def UnUn(self, request, context): |
||||
if _application_common.UNARY_UNARY_REQUEST == request: |
||||
return _application_common.UNARY_UNARY_RESPONSE |
||||
else: |
||||
context.set_code(grpc.StatusCode.INVALID_ARGUMENT) |
||||
context.set_details('Something is wrong with your request!') |
||||
return services_pb2.Down() |
||||
|
||||
def UnStre(self, request, context): |
||||
if _application_common.UNARY_STREAM_REQUEST != request: |
||||
context.set_code(grpc.StatusCode.INVALID_ARGUMENT) |
||||
context.set_details('Something is wrong with your request!') |
||||
return |
||||
yield services_pb2.Strange() |
||||
|
||||
def StreUn(self, request_iterator, context): |
||||
context.send_initial_metadata(( |
||||
('server_application_metadata_key', 'Hi there!',),)) |
||||
for request in request_iterator: |
||||
if request != _application_common.STREAM_UNARY_REQUEST: |
||||
context.set_code(grpc.StatusCode.INVALID_ARGUMENT) |
||||
context.set_details('Something is wrong with your request!') |
||||
return services_pb2.Strange() |
||||
elif not context.is_active(): |
||||
return services_pb2.Strange() |
||||
else: |
||||
return _application_common.STREAM_UNARY_RESPONSE |
||||
|
||||
def StreStre(self, request_iterator, context): |
||||
for request in request_iterator: |
||||
if request != _application_common.STREAM_STREAM_REQUEST: |
||||
context.set_code(grpc.StatusCode.INVALID_ARGUMENT) |
||||
context.set_details('Something is wrong with your request!') |
||||
return |
||||
elif not context.is_active(): |
||||
return |
||||
else: |
||||
yield _application_common.STREAM_STREAM_RESPONSE |
||||
yield _application_common.STREAM_STREAM_RESPONSE |
@ -0,0 +1,169 @@ |
||||
# Copyright 2017 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
import time |
||||
import unittest |
||||
|
||||
import grpc |
||||
import grpc_testing |
||||
|
||||
from tests.testing import _application_common |
||||
from tests.testing import _application_testing_common |
||||
from tests.testing import _server_application |
||||
from tests.testing.proto import services_pb2 |
||||
|
||||
|
||||
# TODO(https://github.com/google/protobuf/issues/3452): Drop this skip. |
||||
@unittest.skipIf( |
||||
services_pb2.DESCRIPTOR.services_by_name.get('FirstService') is None, |
||||
'Fix protobuf issue 3452!') |
||||
class FirstServiceServicerTest(unittest.TestCase): |
||||
|
||||
def setUp(self): |
||||
self._real_time = grpc_testing.strict_real_time() |
||||
self._fake_time = grpc_testing.strict_fake_time(time.time()) |
||||
servicer = _server_application.FirstServiceServicer() |
||||
descriptors_to_servicers = { |
||||
_application_testing_common.FIRST_SERVICE: servicer |
||||
} |
||||
self._real_time_server = grpc_testing.server_from_dictionary( |
||||
descriptors_to_servicers, self._real_time) |
||||
self._fake_time_server = grpc_testing.server_from_dictionary( |
||||
descriptors_to_servicers, self._fake_time) |
||||
|
||||
def test_successful_unary_unary(self): |
||||
rpc = self._real_time_server.invoke_unary_unary( |
||||
_application_testing_common.FIRST_SERVICE_UNUN, (), |
||||
_application_common.UNARY_UNARY_REQUEST, None) |
||||
initial_metadata = rpc.initial_metadata() |
||||
response, trailing_metadata, code, details = rpc.termination() |
||||
|
||||
self.assertEqual(_application_common.UNARY_UNARY_RESPONSE, response) |
||||
self.assertIs(code, grpc.StatusCode.OK) |
||||
|
||||
def test_successful_unary_stream(self): |
||||
rpc = self._real_time_server.invoke_unary_stream( |
||||
_application_testing_common.FIRST_SERVICE_UNSTRE, (), |
||||
_application_common.UNARY_STREAM_REQUEST, None) |
||||
initial_metadata = rpc.initial_metadata() |
||||
trailing_metadata, code, details = rpc.termination() |
||||
|
||||
self.assertIs(code, grpc.StatusCode.OK) |
||||
|
||||
def test_successful_stream_unary(self): |
||||
rpc = self._real_time_server.invoke_stream_unary( |
||||
_application_testing_common.FIRST_SERVICE_STREUN, (), None) |
||||
rpc.send_request(_application_common.STREAM_UNARY_REQUEST) |
||||
rpc.send_request(_application_common.STREAM_UNARY_REQUEST) |
||||
rpc.send_request(_application_common.STREAM_UNARY_REQUEST) |
||||
rpc.requests_closed() |
||||
initial_metadata = rpc.initial_metadata() |
||||
response, trailing_metadata, code, details = rpc.termination() |
||||
|
||||
self.assertEqual(_application_common.STREAM_UNARY_RESPONSE, response) |
||||
self.assertIs(code, grpc.StatusCode.OK) |
||||
|
||||
def test_successful_stream_stream(self): |
||||
rpc = self._real_time_server.invoke_stream_stream( |
||||
_application_testing_common.FIRST_SERVICE_STRESTRE, (), None) |
||||
rpc.send_request(_application_common.STREAM_STREAM_REQUEST) |
||||
initial_metadata = rpc.initial_metadata() |
||||
responses = [ |
||||
rpc.take_response(), |
||||
rpc.take_response(), |
||||
] |
||||
rpc.send_request(_application_common.STREAM_STREAM_REQUEST) |
||||
rpc.send_request(_application_common.STREAM_STREAM_REQUEST) |
||||
responses.extend([ |
||||
rpc.take_response(), |
||||
rpc.take_response(), |
||||
rpc.take_response(), |
||||
rpc.take_response(), |
||||
]) |
||||
rpc.requests_closed() |
||||
trailing_metadata, code, details = rpc.termination() |
||||
|
||||
for response in responses: |
||||
self.assertEqual(_application_common.STREAM_STREAM_RESPONSE, |
||||
response) |
||||
self.assertIs(code, grpc.StatusCode.OK) |
||||
|
||||
def test_server_rpc_idempotence(self): |
||||
rpc = self._real_time_server.invoke_unary_unary( |
||||
_application_testing_common.FIRST_SERVICE_UNUN, (), |
||||
_application_common.UNARY_UNARY_REQUEST, None) |
||||
first_initial_metadata = rpc.initial_metadata() |
||||
second_initial_metadata = rpc.initial_metadata() |
||||
third_initial_metadata = rpc.initial_metadata() |
||||
first_termination = rpc.termination() |
||||
second_termination = rpc.termination() |
||||
third_termination = rpc.termination() |
||||
|
||||
for later_initial_metadata in (second_initial_metadata, |
||||
third_initial_metadata,): |
||||
self.assertEqual(first_initial_metadata, later_initial_metadata) |
||||
response = first_termination[0] |
||||
terminal_metadata = first_termination[1] |
||||
code = first_termination[2] |
||||
details = first_termination[3] |
||||
for later_termination in (second_termination, third_termination,): |
||||
self.assertEqual(response, later_termination[0]) |
||||
self.assertEqual(terminal_metadata, later_termination[1]) |
||||
self.assertIs(code, later_termination[2]) |
||||
self.assertEqual(details, later_termination[3]) |
||||
self.assertEqual(_application_common.UNARY_UNARY_RESPONSE, response) |
||||
self.assertIs(code, grpc.StatusCode.OK) |
||||
|
||||
def test_misbehaving_client_unary_unary(self): |
||||
rpc = self._real_time_server.invoke_unary_unary( |
||||
_application_testing_common.FIRST_SERVICE_UNUN, (), |
||||
_application_common.ERRONEOUS_UNARY_UNARY_REQUEST, None) |
||||
initial_metadata = rpc.initial_metadata() |
||||
response, trailing_metadata, code, details = rpc.termination() |
||||
|
||||
self.assertIsNot(code, grpc.StatusCode.OK) |
||||
|
||||
def test_infinite_request_stream_real_time(self): |
||||
rpc = self._real_time_server.invoke_stream_unary( |
||||
_application_testing_common.FIRST_SERVICE_STREUN, (), |
||||
_application_common.INFINITE_REQUEST_STREAM_TIMEOUT) |
||||
rpc.send_request(_application_common.STREAM_UNARY_REQUEST) |
||||
rpc.send_request(_application_common.STREAM_UNARY_REQUEST) |
||||
rpc.send_request(_application_common.STREAM_UNARY_REQUEST) |
||||
initial_metadata = rpc.initial_metadata() |
||||
self._real_time.sleep_for( |
||||
_application_common.INFINITE_REQUEST_STREAM_TIMEOUT * 2) |
||||
rpc.send_request(_application_common.STREAM_UNARY_REQUEST) |
||||
response, trailing_metadata, code, details = rpc.termination() |
||||
|
||||
self.assertIs(code, grpc.StatusCode.DEADLINE_EXCEEDED) |
||||
|
||||
def test_infinite_request_stream_fake_time(self): |
||||
rpc = self._fake_time_server.invoke_stream_unary( |
||||
_application_testing_common.FIRST_SERVICE_STREUN, (), |
||||
_application_common.INFINITE_REQUEST_STREAM_TIMEOUT) |
||||
rpc.send_request(_application_common.STREAM_UNARY_REQUEST) |
||||
rpc.send_request(_application_common.STREAM_UNARY_REQUEST) |
||||
rpc.send_request(_application_common.STREAM_UNARY_REQUEST) |
||||
initial_metadata = rpc.initial_metadata() |
||||
self._fake_time.sleep_for( |
||||
_application_common.INFINITE_REQUEST_STREAM_TIMEOUT * 2) |
||||
rpc.send_request(_application_common.STREAM_UNARY_REQUEST) |
||||
response, trailing_metadata, code, details = rpc.termination() |
||||
|
||||
self.assertIs(code, grpc.StatusCode.DEADLINE_EXCEEDED) |
||||
|
||||
|
||||
if __name__ == '__main__': |
||||
unittest.main(verbosity=2) |
@ -1,44 +1,569 @@ |
||||
# This configuration was generated by `rubocop --auto-gen-config` |
||||
# on 2015-05-22 13:23:34 -0700 using RuboCop version 0.30.1. |
||||
# This configuration was generated by |
||||
# `rubocop --auto-gen-config` |
||||
# on 2017-09-04 17:00:36 +0200 using RuboCop version 0.49.1. |
||||
# The point is for the user to remove these configuration records |
||||
# one by one as the offenses are removed from the code base. |
||||
# Note that changes in the inspected code, or installation of new |
||||
# versions of RuboCop, may require this file to be generated again. |
||||
|
||||
# Offense count: 30 |
||||
Metrics/AbcSize: |
||||
Max: 38 |
||||
# Offense count: 3 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentOneStep, IndentationWidth. |
||||
# SupportedStyles: case, end |
||||
Layout/CaseIndentation: |
||||
Exclude: |
||||
- 'tools/platform_check.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
Layout/CommentIndentation: |
||||
Exclude: |
||||
- 'qps/client.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
Layout/EmptyLineAfterMagicComment: |
||||
Exclude: |
||||
- 'tools/grpc-tools.gemspec' |
||||
|
||||
# Offense count: 33 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. |
||||
Layout/EmptyLineBetweenDefs: |
||||
Exclude: |
||||
- 'qps/client.rb' |
||||
- 'qps/histogram.rb' |
||||
- 'qps/proxy-worker.rb' |
||||
- 'qps/server.rb' |
||||
- 'qps/worker.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
Layout/EmptyLines: |
||||
Exclude: |
||||
- 'qps/qps-common.rb' |
||||
|
||||
# Offense count: 8 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles. |
||||
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines |
||||
Layout/EmptyLinesAroundClassBody: |
||||
Exclude: |
||||
- 'pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb' |
||||
- 'pb/grpc/testing/metrics_services_pb.rb' |
||||
- 'pb/src/proto/grpc/testing/test_services_pb.rb' |
||||
- 'qps/src/proto/grpc/testing/proxy-service_services_pb.rb' |
||||
- 'qps/src/proto/grpc/testing/services_services_pb.rb' |
||||
|
||||
# Offense count: 28 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. |
||||
Layout/ExtraSpacing: |
||||
Enabled: false |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles. |
||||
# SupportedStyles: normal, rails |
||||
Layout/IndentationConsistency: |
||||
Exclude: |
||||
- 'pb/grpc/health/checker.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: Width, IgnoredPatterns. |
||||
Layout/IndentationWidth: |
||||
Exclude: |
||||
- 'pb/grpc/health/checker.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles. |
||||
# SupportedStyles: symmetrical, new_line, same_line |
||||
Layout/MultilineHashBraceLayout: |
||||
Exclude: |
||||
- 'spec/generic/active_call_spec.rb' |
||||
|
||||
# Offense count: 70 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles. |
||||
# SupportedStyles: symmetrical, new_line, same_line |
||||
Layout/MultilineMethodCallBraceLayout: |
||||
Enabled: false |
||||
|
||||
# Offense count: 2 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. |
||||
# SupportedStyles: aligned, indented, indented_relative_to_receiver |
||||
Layout/MultilineMethodCallIndentation: |
||||
Exclude: |
||||
- 'spec/generic/rpc_desc_spec.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles. |
||||
# SupportedStyles: symmetrical, new_line, same_line |
||||
Layout/MultilineMethodDefinitionBraceLayout: |
||||
Exclude: |
||||
- 'spec/generic/client_stub_spec.rb' |
||||
|
||||
# Offense count: 5 |
||||
# Cop supports --auto-correct. |
||||
Layout/SpaceAfterColon: |
||||
Exclude: |
||||
- 'lib/grpc/generic/rpc_server.rb' |
||||
|
||||
# Offense count: 7 |
||||
# Cop supports --auto-correct. |
||||
Layout/SpaceAfterComma: |
||||
Exclude: |
||||
- 'qps/client.rb' |
||||
|
||||
# Offense count: 27 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: AllowForAlignment. |
||||
Layout/SpaceAroundOperators: |
||||
Exclude: |
||||
- 'qps/client.rb' |
||||
- 'qps/histogram.rb' |
||||
- 'qps/proxy-worker.rb' |
||||
- 'qps/server.rb' |
||||
- 'spec/generic/active_call_spec.rb' |
||||
- 'spec/generic/rpc_server_spec.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters. |
||||
# SupportedStyles: space, no_space |
||||
# SupportedStylesForEmptyBraces: space, no_space |
||||
Layout/SpaceInsideBlockBraces: |
||||
Exclude: |
||||
- 'stress/stress_client.rb' |
||||
|
||||
# Offense count: 4 |
||||
# Cop supports --auto-correct. |
||||
Layout/SpaceInsideBrackets: |
||||
Exclude: |
||||
- 'tools/bin/grpc_tools_ruby_protoc' |
||||
- 'tools/bin/grpc_tools_ruby_protoc_plugin' |
||||
|
||||
# Offense count: 2 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces. |
||||
# SupportedStyles: space, no_space, compact |
||||
# SupportedStylesForEmptyBraces: space, no_space |
||||
Layout/SpaceInsideHashLiteralBraces: |
||||
Exclude: |
||||
- 'qps/server.rb' |
||||
|
||||
# Offense count: 6 |
||||
# Cop supports --auto-correct. |
||||
Layout/SpaceInsidePercentLiteralDelimiters: |
||||
Exclude: |
||||
- 'spec/generic/client_stub_spec.rb' |
||||
- 'tools/grpc-tools.gemspec' |
||||
|
||||
# Offense count: 3 |
||||
# Configuration parameters: CountComments. |
||||
Metrics/ClassLength: |
||||
Max: 200 |
||||
# Cop supports --auto-correct. |
||||
Layout/Tab: |
||||
Exclude: |
||||
- 'pb/grpc/health/checker.rb' |
||||
- 'qps/client.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
Layout/TrailingWhitespace: |
||||
Exclude: |
||||
- 'qps/worker.rb' |
||||
|
||||
# Offense count: 1 |
||||
Lint/IneffectiveAccessModifier: |
||||
Exclude: |
||||
- 'lib/grpc/generic/active_call.rb' |
||||
|
||||
# Offense count: 4 |
||||
# Cop supports --auto-correct. |
||||
Lint/PercentStringArray: |
||||
Exclude: |
||||
- 'spec/client_server_spec.rb' |
||||
- 'spec/generic/active_call_spec.rb' |
||||
- 'spec/generic/client_stub_spec.rb' |
||||
|
||||
# Offense count: 4 |
||||
Lint/ScriptPermission: |
||||
Exclude: |
||||
- 'qps/client.rb' |
||||
- 'qps/histogram.rb' |
||||
- 'qps/qps-common.rb' |
||||
- 'qps/server.rb' |
||||
|
||||
# Offense count: 2 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. |
||||
Lint/UnusedBlockArgument: |
||||
Exclude: |
||||
- 'qps/client.rb' |
||||
|
||||
# Offense count: 2 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. |
||||
Lint/UnusedMethodArgument: |
||||
Exclude: |
||||
- 'qps/client.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. |
||||
Lint/UselessAccessModifier: |
||||
Exclude: |
||||
- 'lib/grpc/logconfig.rb' |
||||
|
||||
# Offense count: 1 |
||||
Lint/UselessAssignment: |
||||
Exclude: |
||||
- 'qps/client.rb' |
||||
|
||||
# Offense count: 35 |
||||
# Offense count: 4 |
||||
Lint/Void: |
||||
Exclude: |
||||
- 'stress/metrics_server.rb' |
||||
- 'stress/stress_client.rb' |
||||
|
||||
# Offense count: 53 |
||||
Metrics/AbcSize: |
||||
Max: 57 |
||||
|
||||
# Offense count: 81 |
||||
# Configuration parameters: CountComments, ExcludedMethods. |
||||
Metrics/BlockLength: |
||||
Max: 715 |
||||
|
||||
# Offense count: 82 |
||||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. |
||||
# URISchemes: http, https |
||||
Metrics/LineLength: |
||||
Max: 141 |
||||
|
||||
# Offense count: 82 |
||||
# Configuration parameters: CountComments. |
||||
Metrics/MethodLength: |
||||
Max: 36 |
||||
Max: 54 |
||||
|
||||
# Offense count: 7 |
||||
# Offense count: 5 |
||||
# Configuration parameters: CountKeywordArgs. |
||||
Metrics/ParameterLists: |
||||
Max: 8 |
||||
Max: 7 |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
Performance/RedundantBlockCall: |
||||
Exclude: |
||||
- 'spec/generic/client_stub_spec.rb' |
||||
|
||||
# Offense count: 5 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: MaxKeyValuePairs. |
||||
Performance/RedundantMerge: |
||||
Exclude: |
||||
- 'spec/generic/active_call_spec.rb' |
||||
- 'spec/generic/client_stub_spec.rb' |
||||
|
||||
# Offense count: 8 |
||||
# Cop supports --auto-correct. |
||||
Performance/TimesMap: |
||||
Exclude: |
||||
- 'spec/channel_spec.rb' |
||||
- 'spec/client_server_spec.rb' |
||||
- 'spec/server_spec.rb' |
||||
|
||||
# Offense count: 7 |
||||
Style/AccessorMethodName: |
||||
Exclude: |
||||
- 'qps/server.rb' |
||||
- 'stress/metrics_server.rb' |
||||
- 'stress/stress_client.rb' |
||||
|
||||
# Offense count: 2 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles. |
||||
# SupportedStyles: prefer_alias, prefer_alias_method |
||||
Style/Alias: |
||||
Exclude: |
||||
- 'lib/grpc/generic/rpc_server.rb' |
||||
- 'lib/grpc/notifier.rb' |
||||
|
||||
# Offense count: 7 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. |
||||
# SupportedStyles: line_count_based, semantic, braces_for_chaining |
||||
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object |
||||
# FunctionalMethods: let, let!, subject, watch |
||||
# IgnoredMethods: lambda, proc, it |
||||
Style/BlockDelimiters: |
||||
Exclude: |
||||
- 'qps/client.rb' |
||||
- 'qps/proxy-worker.rb' |
||||
- 'qps/server.rb' |
||||
- 'qps/worker.rb' |
||||
|
||||
# Offense count: 2 |
||||
# Cop supports --auto-correct. |
||||
Style/ClassMethods: |
||||
Exclude: |
||||
- 'tools/platform_check.rb' |
||||
|
||||
# Offense count: 2 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions. |
||||
# SupportedStyles: assign_to_condition, assign_inside_condition |
||||
Style/ConditionalAssignment: |
||||
Exclude: |
||||
- 'lib/grpc/generic/rpc_server.rb' |
||||
- 'lib/grpc/generic/service.rb' |
||||
|
||||
# Offense count: 19 |
||||
Style/Documentation: |
||||
Exclude: |
||||
- 'spec/**/*' |
||||
- 'test/**/*' |
||||
- 'pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb' |
||||
- 'pb/grpc/testing/metrics_services_pb.rb' |
||||
- 'pb/src/proto/grpc/testing/test_pb.rb' |
||||
- 'qps/client.rb' |
||||
- 'qps/histogram.rb' |
||||
- 'qps/proxy-worker.rb' |
||||
- 'qps/server.rb' |
||||
- 'qps/src/proto/grpc/testing/proxy-service_services_pb.rb' |
||||
- 'qps/src/proto/grpc/testing/services_pb.rb' |
||||
- 'qps/src/proto/grpc/testing/services_services_pb.rb' |
||||
- 'qps/worker.rb' |
||||
- 'stress/metrics_server.rb' |
||||
- 'stress/stress_client.rb' |
||||
- 'tools/platform_check.rb' |
||||
|
||||
# Offense count: 9 |
||||
# Offense count: 8 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles. |
||||
# SupportedStyles: compact, expanded |
||||
Style/EmptyMethod: |
||||
Exclude: |
||||
- 'bin/noproto_server.rb' |
||||
- 'lib/grpc/logconfig.rb' |
||||
- 'spec/generic/rpc_desc_spec.rb' |
||||
|
||||
# Offense count: 2 |
||||
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms. |
||||
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS |
||||
Style/FileName: |
||||
Exclude: |
||||
- 'qps/src/proto/grpc/testing/proxy-service_pb.rb' |
||||
- 'qps/src/proto/grpc/testing/proxy-service_services_pb.rb' |
||||
|
||||
# Offense count: 12 |
||||
# Configuration parameters: AllowedVariables. |
||||
Style/GlobalVars: |
||||
Enabled: false |
||||
Exclude: |
||||
- 'ext/grpc/extconf.rb' |
||||
|
||||
# Offense count: 3 |
||||
# Configuration parameters: MinBodyLength. |
||||
Style/GuardClause: |
||||
Exclude: |
||||
- 'lib/grpc/generic/bidi_call.rb' |
||||
- 'lib/grpc/generic/rpc_server.rb' |
||||
- 'qps/client.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. |
||||
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys |
||||
Style/HashSyntax: |
||||
Exclude: |
||||
- 'stress/metrics_server.rb' |
||||
|
||||
# Offense count: 1 |
||||
Style/IfInsideElse: |
||||
Exclude: |
||||
- 'lib/grpc/generic/rpc_desc.rb' |
||||
|
||||
# Offense count: 4 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: MaxLineLength. |
||||
Style/IfUnlessModifier: |
||||
Exclude: |
||||
- 'ext/grpc/extconf.rb' |
||||
- 'qps/histogram.rb' |
||||
- 'stress/stress_client.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
Style/MethodCallWithoutArgsParentheses: |
||||
Exclude: |
||||
- 'qps/client.rb' |
||||
|
||||
# Offense count: 3 |
||||
# Cop supports --auto-correct. |
||||
Style/MultilineIfModifier: |
||||
Exclude: |
||||
- 'lib/grpc/generic/bidi_call.rb' |
||||
- 'lib/grpc/generic/client_stub.rb' |
||||
- 'spec/spec_helper.rb' |
||||
|
||||
# Offense count: 7 |
||||
# Cop supports --auto-correct. |
||||
Style/MutableConstant: |
||||
Exclude: |
||||
- 'ext/grpc/extconf.rb' |
||||
- 'lib/grpc/version.rb' |
||||
- 'spec/compression_options_spec.rb' |
||||
- 'spec/generic/active_call_spec.rb' |
||||
- 'tools/version.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. |
||||
Style/Next: |
||||
# Cop supports --auto-correct. |
||||
Style/NegatedWhile: |
||||
Exclude: |
||||
- 'qps/client.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles. |
||||
# SupportedStyles: predicate, comparison |
||||
Style/NumericPredicate: |
||||
Exclude: |
||||
- 'spec/**/*' |
||||
- 'ext/grpc/extconf.rb' |
||||
|
||||
# Offense count: 7 |
||||
# Cop supports --auto-correct. |
||||
Style/ParallelAssignment: |
||||
Exclude: |
||||
- 'bin/math_server.rb' |
||||
- 'lib/grpc/generic/rpc_server.rb' |
||||
- 'spec/generic/client_stub_spec.rb' |
||||
- 'spec/generic/rpc_desc_spec.rb' |
||||
- 'spec/generic/rpc_server_pool_spec.rb' |
||||
- 'spec/generic/rpc_server_spec.rb' |
||||
|
||||
# Offense count: 8 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: PreferredDelimiters. |
||||
Style/PercentLiteralDelimiters: |
||||
Exclude: |
||||
- 'end2end/grpc_class_init_driver.rb' |
||||
- 'spec/client_server_spec.rb' |
||||
- 'spec/generic/active_call_spec.rb' |
||||
- 'spec/generic/client_stub_spec.rb' |
||||
- 'tools/grpc-tools.gemspec' |
||||
|
||||
# Offense count: 3 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles. |
||||
# SupportedStyles: compact, exploded |
||||
Style/RaiseArgs: |
||||
Exclude: |
||||
- 'stress/metrics_server.rb' |
||||
|
||||
# Offense count: 4 |
||||
# Cop supports --auto-correct. |
||||
Style/RedundantParentheses: |
||||
Exclude: |
||||
- 'lib/grpc/generic/rpc_server.rb' |
||||
- 'qps/client.rb' |
||||
- 'qps/proxy-worker.rb' |
||||
- 'spec/generic/rpc_desc_spec.rb' |
||||
|
||||
# Offense count: 5 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: AllowMultipleReturnValues. |
||||
Style/RedundantReturn: |
||||
Exclude: |
||||
- 'end2end/grpc_class_init_client.rb' |
||||
|
||||
# Offense count: 77 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles. |
||||
# SupportedStyles: only_raise, only_fail, semantic |
||||
Style/SignalException: |
||||
Enabled: false |
||||
|
||||
# Offense count: 2 |
||||
# Configuration parameters: Methods. |
||||
Style/SingleLineBlockParams: |
||||
Enabled: false |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles. |
||||
# SupportedStyles: use_perl_names, use_english_names |
||||
Style/SpecialGlobalVars: |
||||
Exclude: |
||||
- 'ext/grpc/extconf.rb' |
||||
- 'stress/stress_client.rb' |
||||
|
||||
# Offense count: 189 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. |
||||
# SupportedStyles: single_quotes, double_quotes |
||||
Style/StringLiterals: |
||||
Exclude: |
||||
- 'pb/grpc/testing/metrics_pb.rb' |
||||
- 'pb/src/proto/grpc/testing/empty_pb.rb' |
||||
- 'pb/src/proto/grpc/testing/messages_pb.rb' |
||||
- 'qps/proxy-worker.rb' |
||||
- 'qps/server.rb' |
||||
- 'qps/src/proto/grpc/testing/control_pb.rb' |
||||
- 'qps/src/proto/grpc/testing/messages_pb.rb' |
||||
- 'qps/src/proto/grpc/testing/payloads_pb.rb' |
||||
- 'qps/src/proto/grpc/testing/proxy-service_pb.rb' |
||||
- 'qps/src/proto/grpc/testing/stats_pb.rb' |
||||
- 'qps/worker.rb' |
||||
|
||||
# Offense count: 1 |
||||
Style/StructInheritance: |
||||
Enabled: false |
||||
Exclude: |
||||
- 'lib/grpc/generic/rpc_desc.rb' |
||||
|
||||
# Offense count: 10 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: MinSize, SupportedStyles. |
||||
# SupportedStyles: percent, brackets |
||||
Style/SymbolArray: |
||||
EnforcedStyle: brackets |
||||
|
||||
# Offense count: 2 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: IgnoredMethods. |
||||
# IgnoredMethods: respond_to, define_method |
||||
Style/SymbolProc: |
||||
Exclude: |
||||
- 'qps/client.rb' |
||||
- 'stress/stress_client.rb' |
||||
|
||||
# Offense count: 6 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: AllowNamedUnderscoreVariables. |
||||
Style/TrailingUnderscoreVariable: |
||||
Exclude: |
||||
- 'spec/channel_credentials_spec.rb' |
||||
- 'spec/server_credentials_spec.rb' |
||||
|
||||
# Offense count: 3 |
||||
# Cop supports --auto-correct. |
||||
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist. |
||||
# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym |
||||
Style/TrivialAccessors: |
||||
Exclude: |
||||
- 'qps/histogram.rb' |
||||
|
||||
# Offense count: 3 |
||||
# Cop supports --auto-correct. |
||||
Style/UnneededInterpolation: |
||||
Exclude: |
||||
- 'pb/grpc/health/checker.rb' |
||||
|
||||
# Offense count: 1 |
||||
# Cop supports --auto-correct. |
||||
Style/YodaCondition: |
||||
Exclude: |
||||
- 'stress/stress_client.rb' |
||||
|
||||
# Offense count: 2 |
||||
# Cop supports --auto-correct. |
||||
Style/ZeroLengthPredicate: |
||||
Exclude: |
||||
- 'lib/grpc/generic/rpc_server.rb' |
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue