@@ -52,7 +52,7 @@ pub fn client_new(
5252) -> BridgeResult < BridgeFuture < OpaqueOutboundHandle < Client > > > {
5353 let runtime = runtime. borrow ( ) ?. core_runtime . clone ( ) ;
5454 let metric_meter = runtime. telemetry ( ) . get_temporal_metric_meter ( ) ;
55- let options = config. into_connection_options ( metric_meter) ;
55+ let options = config. into_connection_options ( metric_meter) ? ;
5656
5757 runtime. clone ( ) . future_to_promise ( async move {
5858 let core_connection = match Connection :: connect ( options) . await {
@@ -621,15 +621,19 @@ mod config {
621621
622622 use temporalio_client:: {
623623 ClientTlsOptions as CoreClientTlsOptions , ConnectionOptions , DnsLoadBalancingOptions ,
624- HttpConnectProxyOptions , TlsOptions as CoreTlsOptions ,
624+ GrpcCompression as CoreGrpcCompression , HttpConnectProxyOptions ,
625+ TlsOptions as CoreTlsOptions ,
625626 } ;
626627 use temporalio_common:: telemetry:: metrics:: TemporalMeter ;
627628 use temporalio_sdk_core:: Url ;
628629 use tracing:: warn;
629630
630631 use bridge_macros:: TryFromJs ;
631632
632- use crate :: client:: MetadataValue ;
633+ use crate :: {
634+ client:: MetadataValue ,
635+ helpers:: { BridgeError , BridgeResult } ,
636+ } ;
633637
634638 #[ derive( Debug , Clone , TryFromJs ) ]
635639 pub ( super ) struct ClientOptions {
@@ -639,6 +643,7 @@ mod config {
639643 tls : Option < TlsOptions > ,
640644 http_connect_proxy : Option < HttpConnectProxy > ,
641645 dns_load_balancing_config : Option < DnsLoadBalancingConfig > ,
646+ grpc_compression : Option < GrpcCompressionConfig > ,
642647 headers : Option < HashMap < String , MetadataValue > > ,
643648 api_key : Option < String > ,
644649 disable_error_code_metric_tags : bool ,
@@ -675,11 +680,16 @@ mod config {
675680 resolution_interval_millis : u64 ,
676681 }
677682
683+ #[ derive( Debug , Clone , TryFromJs ) ]
684+ struct GrpcCompressionConfig {
685+ codec : String ,
686+ }
687+
678688 impl ClientOptions {
679689 pub ( super ) fn into_connection_options (
680690 self ,
681691 metrics_meter : Option < TemporalMeter > ,
682- ) -> ConnectionOptions {
692+ ) -> BridgeResult < ConnectionOptions > {
683693 let ( ascii_headers, bin_headers) = partition_headers ( self . headers ) ;
684694 let has_http_connect_proxy = self . http_connect_proxy . is_some ( ) ;
685695 // Core rejects DNS load balancing alongside an HTTP CONNECT proxy, so
@@ -694,13 +704,17 @@ mod config {
694704 self . dns_load_balancing_config . map ( Into :: into)
695705 } ;
696706 let http_connect_proxy = self . http_connect_proxy . map ( Into :: into) ;
707+ let grpc_compression = self
708+ . grpc_compression
709+ . map_or ( Ok ( CoreGrpcCompression :: Gzip ) , TryInto :: try_into) ?;
697710
698- ConnectionOptions :: new ( self . target_url )
711+ Ok ( ConnectionOptions :: new ( self . target_url )
699712 . client_name ( self . client_name )
700713 . client_version ( self . client_version )
701714 . maybe_tls_options ( self . tls . map ( Into :: into) )
702715 . maybe_http_connect_proxy ( http_connect_proxy)
703716 . dns_load_balancing ( dns_load_balancing)
717+ . grpc_compression ( grpc_compression)
704718 . maybe_headers ( ascii_headers)
705719 . maybe_binary_headers ( bin_headers)
706720 . maybe_api_key ( self . api_key )
@@ -711,7 +725,22 @@ mod config {
711725 // override_origin -- skipped: will default to tls_cfg.domain
712726 // keep_alive -- skipped: defaults to true; is there any reason to disable this?
713727 // skip_get_system_info -- skipped: defaults to false; is there any reason to set this?
714- . build ( )
728+ . build ( ) )
729+ }
730+ }
731+
732+ impl TryFrom < GrpcCompressionConfig > for CoreGrpcCompression {
733+ type Error = BridgeError ;
734+
735+ fn try_from ( val : GrpcCompressionConfig ) -> Result < Self , Self :: Error > {
736+ match val. codec . as_str ( ) {
737+ "gzip" => Ok ( Self :: Gzip ) ,
738+ "none" => Ok ( Self :: None ) ,
739+ codec => Err ( BridgeError :: InvalidVariant {
740+ enum_name : "GrpcCompressionConfig" . to_string ( ) ,
741+ variant : codec. to_string ( ) ,
742+ } ) ,
743+ }
715744 }
716745 }
717746
0 commit comments