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
c32375c6
Commit
c32375c6
authored
10 years ago
by
Tim Emiola
Browse files
Options
Downloads
Patches
Plain Diff
Decompose the ClientStub initialize method
parent
ee092fcc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ruby/lib/grpc/generic/client_stub.rb
+23
-28
23 additions, 28 deletions
src/ruby/lib/grpc/generic/client_stub.rb
with
23 additions
and
28 deletions
src/ruby/lib/grpc/generic/client_stub.rb
+
23
−
28
View file @
c32375c6
...
...
@@ -39,6 +39,25 @@ module GRPC
# Default deadline is 5 seconds.
DEFAULT_DEADLINE
=
5
# setup_channel is used by #initialize to constuct a channel from its
# arguments.
def
self
.
setup_channel
(
alt_chan
,
host
,
creds
,
**
kw
)
unless
alt_chan
.
nil?
fail
(
TypeError
,
'!Channel'
)
unless
alt_chan
.
is_a?
(
Core
::
Channel
)
return
alt_chan
end
return
Core
::
Channel
.
new
(
host
,
kw
)
if
creds
.
nil?
fail
(
TypeError
,
'!Credentials'
)
unless
creds
.
is_a?
(
Core
::
Credentials
)
Core
::
Channel
.
new
(
host
,
kw
,
creds
)
end
# check_update_metadata is used by #initialize verify that it's a Proc.
def
self
.
check_update_metadata
(
update_metadata
)
return
update_metadata
if
update_metadata
.
nil?
fail
(
TypeError
,
'!is_a?Proc'
)
unless
update_metadata
.
is_a?
(
Proc
)
update_metadata
end
# Creates a new ClientStub.
#
# Minimally, a stub is created with the just the host of the gRPC service
...
...
@@ -73,39 +92,15 @@ module GRPC
# @param update_metadata a func that updates metadata as described above
# @param kw [KeywordArgs]the channel arguments
def
initialize
(
host
,
q
,
channel_override
:nil
,
channel_override:
nil
,
deadline:
DEFAULT_DEADLINE
,
creds:
nil
,
update_metadata:
nil
,
**
kw
)
unless
q
.
is_a?
Core
::
CompletionQueue
fail
(
ArgumentError
,
'not a CompletionQueue'
)
end
fail
(
TypeError
,
'!CompletionQueue'
)
unless
q
.
is_a?
(
Core
::
CompletionQueue
)
@queue
=
q
# set the channel instance
if
!
channel_override
.
nil?
ch
=
channel_override
fail
(
ArgumentError
,
'not a Channel'
)
unless
ch
.
is_a?
Core
::
Channel
else
if
creds
.
nil?
ch
=
Core
::
Channel
.
new
(
host
,
kw
)
elsif
!
creds
.
is_a?
(
Core
::
Credentials
)
fail
(
ArgumentError
,
'not a Credentials'
)
else
ch
=
Core
::
Channel
.
new
(
host
,
kw
,
creds
)
end
end
@ch
=
ch
@update_metadata
=
nil
unless
update_metadata
.
nil?
unless
update_metadata
.
is_a?
Proc
fail
(
ArgumentError
,
'update_metadata is not a Proc'
)
end
@update_metadata
=
update_metadata
end
@ch
=
ClientStub
.
setup_channel
(
channel_override
,
host
,
creds
,
**
kw
)
@update_metadata
=
ClientStub
.
check_update_metadata
(
update_metadata
)
@host
=
host
@deadline
=
deadline
end
...
...
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