@@ -465,7 +465,7 @@ def _name_from_project_path(path, project, template):
465
465
return match .group ('name' )
466
466
467
467
468
- def make_secure_channel (credentials , user_agent , host ):
468
+ def make_secure_channel (credentials , user_agent , host , extra_options = None ):
469
469
"""Makes a secure channel for an RPC service.
470
470
471
471
Uses / depends on gRPC.
@@ -480,22 +480,30 @@ def make_secure_channel(credentials, user_agent, host):
480
480
:type host: str
481
481
:param host: The host for the service.
482
482
483
+ :type extra_options: tuple
484
+ :param extra_options: (Optional) Extra gRPC options used when creating the
485
+ channel.
486
+
483
487
:rtype: :class:`grpc._channel.Channel`
484
488
:returns: gRPC secure channel with credentials attached.
485
489
"""
486
490
target = '%s:%d' % (host , http_client .HTTPS_PORT )
487
491
http_request = google_auth_httplib2 .Request (http = httplib2 .Http ())
488
- options = (
489
- ('grpc.primary_user_agent' , user_agent ),
490
- )
492
+
493
+ user_agent_option = ('grpc.primary_user_agent' , user_agent )
494
+ if extra_options is not None :
495
+ options = (user_agent_option ,) + extra_options
496
+ else :
497
+ options = (user_agent_option ,)
491
498
return google .auth .transport .grpc .secure_authorized_channel (
492
499
credentials ,
493
500
http_request ,
494
501
target ,
495
502
options = options )
496
503
497
504
498
- def make_secure_stub (credentials , user_agent , stub_class , host ):
505
+ def make_secure_stub (credentials , user_agent , stub_class , host ,
506
+ extra_options = None ):
499
507
"""Makes a secure stub for an RPC service.
500
508
501
509
Uses / depends on gRPC.
@@ -513,10 +521,15 @@ def make_secure_stub(credentials, user_agent, stub_class, host):
513
521
:type host: str
514
522
:param host: The host for the service.
515
523
524
+ :type extra_options: tuple
525
+ :param extra_options: (Optional) Extra gRPC options passed when creating
526
+ the channel.
527
+
516
528
:rtype: object, instance of ``stub_class``
517
529
:returns: The stub object used to make gRPC requests to a given API.
518
530
"""
519
- channel = make_secure_channel (credentials , user_agent , host )
531
+ channel = make_secure_channel (credentials , user_agent , host ,
532
+ extra_options = extra_options )
520
533
return stub_class (channel )
521
534
522
535
0 commit comments