@@ -633,6 +633,8 @@ type clientStream struct {
633633 // nameResolutionDelay indicates if there was a delay in the name resolution.
634634 // This field is only valid on client side, it's always false on server side.
635635 nameResolutionDelay bool
636+
637+ compressorOptions []any
636638}
637639
638640type replayOp struct {
@@ -964,7 +966,7 @@ func (cs *clientStream) SendMsg(m any) (err error) {
964966 }
965967
966968 // load hdr, payload, data
967- hdr , data , payload , pf , err := prepareMsg (m , cs .codec , cs .compressorV0 , cs .compressorV1 , cs .cc .dopts .copts .BufferPool )
969+ hdr , data , payload , pf , err := prepareMsg (m , cs .codec , cs .compressorV0 , cs .compressorV1 , cs .cc .dopts .copts .BufferPool , cs . compressorOptions ... )
968970 if err != nil {
969971 return err
970972 }
@@ -1471,7 +1473,7 @@ func (as *addrConnStream) SendMsg(m any) (err error) {
14711473 }
14721474
14731475 // load hdr, payload, data
1474- hdr , data , payload , pf , err := prepareMsg (m , as .codec , as .sendCompressorV0 , as .sendCompressorV1 , as .ac .dopts .copts .BufferPool )
1476+ hdr , data , payload , pf , err := prepareMsg (m , as .codec , as .sendCompressorV0 , as .sendCompressorV1 , as .ac .dopts .copts .BufferPool , as . callInfo . compressorOptions ... )
14751477 if err != nil {
14761478 return err
14771479 }
@@ -1669,7 +1671,8 @@ type serverStream struct {
16691671 // synchronized.
16701672 serverHeaderBinlogged bool
16711673
1672- mu sync.Mutex // protects trInfo.tr after the service handler runs.
1674+ mu sync.Mutex // protects trInfo.tr after the service handler runs.
1675+ sendCompressorOptions []any
16731676}
16741677
16751678func (ss * serverStream ) Context () context.Context {
@@ -1748,10 +1751,11 @@ func (ss *serverStream) SendMsg(m any) (err error) {
17481751 if sendCompressorsName := ss .s .SendCompress (); sendCompressorsName != ss .sendCompressorName {
17491752 ss .compressorV1 = encoding .GetCompressor (sendCompressorsName )
17501753 ss .sendCompressorName = sendCompressorsName
1754+ ss .sendCompressorOptions = ss .s .SendCompressOptions ()
17511755 }
17521756
17531757 // load hdr, payload, data
1754- hdr , data , payload , pf , err := prepareMsg (m , ss .codec , ss .compressorV0 , ss .compressorV1 , ss .p .bufferPool )
1758+ hdr , data , payload , pf , err := prepareMsg (m , ss .codec , ss .compressorV0 , ss .compressorV1 , ss .p .bufferPool , ss . sendCompressorOptions ... )
17551759 if err != nil {
17561760 return err
17571761 }
@@ -1893,7 +1897,7 @@ func MethodFromServerStream(stream ServerStream) (string, bool) {
18931897// compression was made and therefore whether the payload needs to be freed in
18941898// addition to the returned data. Freeing the payload if the returned boolean is
18951899// false can lead to undefined behavior.
1896- func prepareMsg (m any , codec baseCodec , cp Compressor , comp encoding.Compressor , pool mem.BufferPool ) (hdr []byte , data , payload mem.BufferSlice , pf payloadFormat , err error ) {
1900+ func prepareMsg (m any , codec baseCodec , cp Compressor , comp encoding.Compressor , pool mem.BufferPool , compressorOptions ... any ) (hdr []byte , data , payload mem.BufferSlice , pf payloadFormat , err error ) {
18971901 if preparedMsg , ok := m .(* PreparedMsg ); ok {
18981902 return preparedMsg .hdr , preparedMsg .encodedData , preparedMsg .payload , preparedMsg .pf , nil
18991903 }
@@ -1903,7 +1907,7 @@ func prepareMsg(m any, codec baseCodec, cp Compressor, comp encoding.Compressor,
19031907 if err != nil {
19041908 return nil , nil , nil , 0 , err
19051909 }
1906- compData , pf , err := compress (data , cp , comp , pool )
1910+ compData , pf , err := compress (data , cp , comp , pool , compressorOptions ... )
19071911 if err != nil {
19081912 data .Free ()
19091913 return nil , nil , nil , 0 , err
0 commit comments