Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
a44d3145
Commit
a44d3145
authored
8 years ago
by
kpayson64
Committed by
Ken Payson
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow handlers to hint at the services they export
parent
11948f74
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/python/grpcio/grpc/__init__.py
+20
-0
20 additions, 0 deletions
src/python/grpcio/grpc/__init__.py
src/python/grpcio/grpc/_utilities.py
+5
-1
5 additions, 1 deletion
src/python/grpcio/grpc/_utilities.py
with
25 additions
and
1 deletion
src/python/grpcio/grpc/__init__.py
+
20
−
0
View file @
a44d3145
...
...
@@ -849,6 +849,26 @@ class GenericRpcHandler(six.with_metaclass(abc.ABCMeta)):
raise
NotImplementedError
()
class
ServiceRpcHandler
(
six
.
with_metaclass
(
abc
.
ABCMeta
,
GenericRpcHandler
)):
"""
An implementation of RPC methods belonging to a service.
A service handles RPC methods with structured names of the form
'
/Service.Name/Service.MethodX
'
, where
'
Service.Name
'
is the value
returned by service_name(), and
'
Service.MethodX
'
is the service method
name. A service can have multiple service methods names, but only a single
service name.
"""
@abc.abstractmethod
def
service_name
(
self
):
"""
Returns this services name.
Returns:
The service name.
"""
raise
NotImplementedError
()
############################# Server Interface ###############################
...
...
This diff is collapsed.
Click to expand it.
src/python/grpcio/grpc/_utilities.py
+
5
−
1
View file @
a44d3145
...
...
@@ -53,13 +53,17 @@ class RpcMethodHandler(
pass
class
DictionaryGenericHandler
(
grpc
.
Gen
ericRpcHandler
):
class
DictionaryGenericHandler
(
grpc
.
S
er
v
ic
e
RpcHandler
):
def
__init__
(
self
,
service
,
method_handlers
):
self
.
_name
=
service
self
.
_method_handlers
=
{
_common
.
fully_qualified_method
(
service
,
method
):
method_handler
for
method
,
method_handler
in
six
.
iteritems
(
method_handlers
)}
def
service_name
(
self
):
return
self
.
_name
def
service
(
self
,
handler_call_details
):
return
self
.
_method_handlers
.
get
(
handler_call_details
.
method
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment