diff options
| author | 2023-06-05 10:15:05 +0200 | |
|---|---|---|
| committer | 2023-06-05 10:15:05 +0200 | |
| commit | b401bd1ccbce7fa547c75e9f0ae89e211112c1bb (patch) | |
| tree | 08bf9ed438713e8c390ea60732e7dfc14b0d3191 /vendor/google.golang.org/grpc | |
| parent | [chore]: Bump github.com/minio/minio-go/v7 from 7.0.55 to 7.0.56 (#1869) (diff) | |
| download | gotosocial-b401bd1ccbce7fa547c75e9f0ae89e211112c1bb.tar.xz | |
[chore] update latest deps, ensure readme up to date (#1873)
* [chore] update latest deps, ensure readme up to date
* remove double entry
Diffstat (limited to 'vendor/google.golang.org/grpc')
15 files changed, 216 insertions, 111 deletions
| diff --git a/vendor/google.golang.org/grpc/CONTRIBUTING.md b/vendor/google.golang.org/grpc/CONTRIBUTING.md index 8e001134d..608aa6e1a 100644 --- a/vendor/google.golang.org/grpc/CONTRIBUTING.md +++ b/vendor/google.golang.org/grpc/CONTRIBUTING.md @@ -20,10 +20,6 @@ How to get your contributions merged smoothly and quickly.    both author's & review's time is wasted. Create more PRs to address different    concerns and everyone will be happy. -- For speculative changes, consider opening an issue and discussing it first. If -  you are suggesting a behavioral or API change, consider starting with a [gRFC  -  proposal](https://github.com/grpc/proposal). -  - If you are searching for features to work on, issues labeled [Status: Help    Wanted](https://github.com/grpc/grpc-go/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Status%3A+Help+Wanted%22)    is a great place to start. These issues are well-documented and usually can be diff --git a/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go b/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go index 8cd89dab9..ec2c2fa14 100644 --- a/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go +++ b/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go @@ -18,7 +18,7 @@  // Code generated by protoc-gen-go. DO NOT EDIT.  // versions: -// 	protoc-gen-go v1.28.1 +// 	protoc-gen-go v1.30.0  // 	protoc        v4.22.0  // source: grpc/binlog/v1/binarylog.proto diff --git a/vendor/google.golang.org/grpc/clientconn.go b/vendor/google.golang.org/grpc/clientconn.go index b9cc05507..3a7614242 100644 --- a/vendor/google.golang.org/grpc/clientconn.go +++ b/vendor/google.golang.org/grpc/clientconn.go @@ -244,19 +244,6 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *  		}  	}() -	scSet := false -	if cc.dopts.scChan != nil { -		// Try to get an initial service config. -		select { -		case sc, ok := <-cc.dopts.scChan: -			if ok { -				cc.sc = &sc -				cc.safeConfigSelector.UpdateConfigSelector(&defaultConfigSelector{&sc}) -				scSet = true -			} -		default: -		} -	}  	if cc.dopts.bs == nil {  		cc.dopts.bs = backoff.DefaultExponential  	} @@ -272,7 +259,7 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *  	}  	channelz.Infof(logger, cc.channelzID, "Channel authority set to %q", cc.authority) -	if cc.dopts.scChan != nil && !scSet { +	if cc.dopts.scChan != nil {  		// Blocking wait for the initial service config.  		select {  		case sc, ok := <-cc.dopts.scChan: diff --git a/vendor/google.golang.org/grpc/dialoptions.go b/vendor/google.golang.org/grpc/dialoptions.go index e9d6852fd..cdc8263bd 100644 --- a/vendor/google.golang.org/grpc/dialoptions.go +++ b/vendor/google.golang.org/grpc/dialoptions.go @@ -295,6 +295,9 @@ func withBackoff(bs internalbackoff.Strategy) DialOption {  // WithBlock returns a DialOption which makes callers of Dial block until the  // underlying connection is up. Without this, Dial returns immediately and  // connecting the server happens in background. +// +// Use of this feature is not recommended.  For more information, please see: +// https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md  func WithBlock() DialOption {  	return newFuncDialOption(func(o *dialOptions) {  		o.block = true @@ -306,6 +309,9 @@ func WithBlock() DialOption {  // the context.DeadlineExceeded error.  // Implies WithBlock()  // +// Use of this feature is not recommended.  For more information, please see: +// https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md +//  // # Experimental  //  // Notice: This API is EXPERIMENTAL and may be changed or removed in a @@ -448,6 +454,9 @@ func withBinaryLogger(bl binarylog.Logger) DialOption {  // FailOnNonTempDialError only affects the initial dial, and does not do  // anything useful unless you are also using WithBlock().  // +// Use of this feature is not recommended.  For more information, please see: +// https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md +//  // # Experimental  //  // Notice: This API is EXPERIMENTAL and may be changed or removed in a diff --git a/vendor/google.golang.org/grpc/internal/envconfig/xds.go b/vendor/google.golang.org/grpc/internal/envconfig/xds.go index 04136882c..3b17705ba 100644 --- a/vendor/google.golang.org/grpc/internal/envconfig/xds.go +++ b/vendor/google.golang.org/grpc/internal/envconfig/xds.go @@ -79,7 +79,7 @@ var (  	// XDSFederation indicates whether federation support is enabled, which can  	// be enabled by setting the environment variable  	// "GRPC_EXPERIMENTAL_XDS_FEDERATION" to "true". -	XDSFederation = boolFromEnv("GRPC_EXPERIMENTAL_XDS_FEDERATION", false) +	XDSFederation = boolFromEnv("GRPC_EXPERIMENTAL_XDS_FEDERATION", true)  	// XDSRLS indicates whether processing of Cluster Specifier plugins and  	// support for the RLS CLuster Specifier is enabled, which can be enabled by diff --git a/vendor/google.golang.org/grpc/internal/grpcsync/callback_serializer.go b/vendor/google.golang.org/grpc/internal/grpcsync/callback_serializer.go new file mode 100644 index 000000000..79993d343 --- /dev/null +++ b/vendor/google.golang.org/grpc/internal/grpcsync/callback_serializer.go @@ -0,0 +1,65 @@ +/* + * + * Copyright 2022 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + *     http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package grpcsync + +import ( +	"context" + +	"google.golang.org/grpc/internal/buffer" +) + +// CallbackSerializer provides a mechanism to schedule callbacks in a +// synchronized manner. It provides a FIFO guarantee on the order of execution +// of scheduled callbacks. New callbacks can be scheduled by invoking the +// Schedule() method. +// +// This type is safe for concurrent access. +type CallbackSerializer struct { +	callbacks *buffer.Unbounded +} + +// NewCallbackSerializer returns a new CallbackSerializer instance. The provided +// context will be passed to the scheduled callbacks. Users should cancel the +// provided context to shutdown the CallbackSerializer. It is guaranteed that no +// callbacks will be executed once this context is canceled. +func NewCallbackSerializer(ctx context.Context) *CallbackSerializer { +	t := &CallbackSerializer{callbacks: buffer.NewUnbounded()} +	go t.run(ctx) +	return t +} + +// Schedule adds a callback to be scheduled after existing callbacks are run. +// +// Callbacks are expected to honor the context when performing any blocking +// operations, and should return early when the context is canceled. +func (t *CallbackSerializer) Schedule(f func(ctx context.Context)) { +	t.callbacks.Put(f) +} + +func (t *CallbackSerializer) run(ctx context.Context) { +	for ctx.Err() == nil { +		select { +		case <-ctx.Done(): +			return +		case callback := <-t.callbacks.Get(): +			t.callbacks.Load() +			callback.(func(ctx context.Context))(ctx) +		} +	} +} diff --git a/vendor/google.golang.org/grpc/internal/transport/controlbuf.go b/vendor/google.golang.org/grpc/internal/transport/controlbuf.go index c343c23a5..be5a9c81e 100644 --- a/vendor/google.golang.org/grpc/internal/transport/controlbuf.go +++ b/vendor/google.golang.org/grpc/internal/transport/controlbuf.go @@ -30,6 +30,7 @@ import (  	"golang.org/x/net/http2"  	"golang.org/x/net/http2/hpack" +	"google.golang.org/grpc/internal/grpclog"  	"google.golang.org/grpc/internal/grpcutil"  	"google.golang.org/grpc/status"  ) @@ -488,12 +489,13 @@ type loopyWriter struct {  	bdpEst        *bdpEstimator  	draining      bool  	conn          net.Conn +	logger        *grpclog.PrefixLogger  	// Side-specific handlers  	ssGoAwayHandler func(*goAway) (bool, error)  } -func newLoopyWriter(s side, fr *framer, cbuf *controlBuffer, bdpEst *bdpEstimator, conn net.Conn) *loopyWriter { +func newLoopyWriter(s side, fr *framer, cbuf *controlBuffer, bdpEst *bdpEstimator, conn net.Conn, logger *grpclog.PrefixLogger) *loopyWriter {  	var buf bytes.Buffer  	l := &loopyWriter{  		side:          s, @@ -507,6 +509,7 @@ func newLoopyWriter(s side, fr *framer, cbuf *controlBuffer, bdpEst *bdpEstimato  		hEnc:          hpack.NewEncoder(&buf),  		bdpEst:        bdpEst,  		conn:          conn, +		logger:        logger,  	}  	return l  } @@ -536,8 +539,8 @@ const minBatchSize = 1000  // left open to allow the I/O error to be encountered by the reader instead.  func (l *loopyWriter) run() (err error) {  	defer func() { -		if logger.V(logLevel) { -			logger.Infof("transport: loopyWriter exiting with error: %v", err) +		if l.logger.V(logLevel) { +			l.logger.Infof("loopyWriter exiting with error: %v", err)  		}  		if !isIOError(err) {  			l.framer.writer.Flush() @@ -636,8 +639,8 @@ func (l *loopyWriter) headerHandler(h *headerFrame) error {  	if l.side == serverSide {  		str, ok := l.estdStreams[h.streamID]  		if !ok { -			if logger.V(logLevel) { -				logger.Warningf("transport: loopy doesn't recognize the stream: %d", h.streamID) +			if l.logger.V(logLevel) { +				l.logger.Infof("Unrecognized streamID %d in loopyWriter", h.streamID)  			}  			return nil  		} @@ -692,8 +695,8 @@ func (l *loopyWriter) writeHeader(streamID uint32, endStream bool, hf []hpack.He  	l.hBuf.Reset()  	for _, f := range hf {  		if err := l.hEnc.WriteField(f); err != nil { -			if logger.V(logLevel) { -				logger.Warningf("transport: loopyWriter.writeHeader encountered error while encoding headers: %v", err) +			if l.logger.V(logLevel) { +				l.logger.Warningf("Encountered error while encoding headers: %v", err)  			}  		}  	} diff --git a/vendor/google.golang.org/grpc/internal/transport/handler_server.go b/vendor/google.golang.org/grpc/internal/transport/handler_server.go index e6626bf96..fbee581b8 100644 --- a/vendor/google.golang.org/grpc/internal/transport/handler_server.go +++ b/vendor/google.golang.org/grpc/internal/transport/handler_server.go @@ -39,6 +39,7 @@ import (  	"golang.org/x/net/http2"  	"google.golang.org/grpc/codes"  	"google.golang.org/grpc/credentials" +	"google.golang.org/grpc/internal/grpclog"  	"google.golang.org/grpc/internal/grpcutil"  	"google.golang.org/grpc/metadata"  	"google.golang.org/grpc/peer" @@ -83,6 +84,7 @@ func NewServerHandlerTransport(w http.ResponseWriter, r *http.Request, stats []s  		contentSubtype: contentSubtype,  		stats:          stats,  	} +	st.logger = prefixLoggerForServerHandlerTransport(st)  	if v := r.Header.Get("grpc-timeout"); v != "" {  		to, err := decodeTimeout(v) @@ -150,13 +152,14 @@ type serverHandlerTransport struct {  	// TODO make sure this is consistent across handler_server and http2_server  	contentSubtype string -	stats []stats.Handler +	stats  []stats.Handler +	logger *grpclog.PrefixLogger  }  func (ht *serverHandlerTransport) Close(err error) {  	ht.closeOnce.Do(func() { -		if logger.V(logLevel) { -			logger.Infof("Closing serverHandlerTransport: %v", err) +		if ht.logger.V(logLevel) { +			ht.logger.Infof("Closing: %v", err)  		}  		close(ht.closedCh)  	}) diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_client.go b/vendor/google.golang.org/grpc/internal/transport/http2_client.go index 9826feb8c..5216998a8 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_client.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_client.go @@ -38,6 +38,7 @@ import (  	"google.golang.org/grpc/credentials"  	"google.golang.org/grpc/internal/channelz"  	icredentials "google.golang.org/grpc/internal/credentials" +	"google.golang.org/grpc/internal/grpclog"  	"google.golang.org/grpc/internal/grpcsync"  	"google.golang.org/grpc/internal/grpcutil"  	imetadata "google.golang.org/grpc/internal/metadata" @@ -145,6 +146,7 @@ type http2Client struct {  	bufferPool *bufferPool  	connectionID uint64 +	logger       *grpclog.PrefixLogger  }  func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error), addr resolver.Address, useProxy bool, grpcUA string) (net.Conn, error) { @@ -244,7 +246,7 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts  		if err := connectCtx.Err(); err != nil {  			// connectCtx expired before exiting the function.  Hard close the connection.  			if logger.V(logLevel) { -				logger.Infof("newClientTransport: aborting due to connectCtx: %v", err) +				logger.Infof("Aborting due to connect deadline expiring: %v", err)  			}  			conn.Close()  		} @@ -346,6 +348,7 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts  		bufferPool:            newBufferPool(),  		onClose:               onClose,  	} +	t.logger = prefixLoggerForClientTransport(t)  	// Add peer information to the http2client context.  	t.ctx = peer.NewContext(t.ctx, t.getPeer()) @@ -444,7 +447,7 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts  		return nil, err  	}  	go func() { -		t.loopy = newLoopyWriter(clientSide, t.framer, t.controlBuf, t.bdpEst, t.conn) +		t.loopy = newLoopyWriter(clientSide, t.framer, t.controlBuf, t.bdpEst, t.conn, t.logger)  		t.loopy.run()  		close(t.writerDone)  	}() @@ -782,7 +785,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,  		s.id = h.streamID  		s.fc = &inFlow{limit: uint32(t.initialWindowSize)}  		t.mu.Lock() -		if t.activeStreams == nil { // Can be niled from Close(). +		if t.state == draining || t.activeStreams == nil { // Can be niled from Close().  			t.mu.Unlock()  			return false // Don't create a stream if the transport is already closed.  		} @@ -859,8 +862,8 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,  		}  	}  	if transportDrainRequired { -		if logger.V(logLevel) { -			logger.Infof("transport: t.nextID > MaxStreamID. Draining") +		if t.logger.V(logLevel) { +			t.logger.Infof("Draining transport: t.nextID > MaxStreamID")  		}  		t.GracefulClose()  	} @@ -952,8 +955,8 @@ func (t *http2Client) Close(err error) {  		t.mu.Unlock()  		return  	} -	if logger.V(logLevel) { -		logger.Infof("transport: closing: %v", err) +	if t.logger.V(logLevel) { +		t.logger.Infof("Closing: %v", err)  	}  	// Call t.onClose ASAP to prevent the client from attempting to create new  	// streams. @@ -1009,8 +1012,8 @@ func (t *http2Client) GracefulClose() {  		t.mu.Unlock()  		return  	} -	if logger.V(logLevel) { -		logger.Infof("transport: GracefulClose called") +	if t.logger.V(logLevel) { +		t.logger.Infof("GracefulClose called")  	}  	t.onClose(GoAwayInvalid)  	t.state = draining @@ -1174,8 +1177,8 @@ func (t *http2Client) handleRSTStream(f *http2.RSTStreamFrame) {  	}  	statusCode, ok := http2ErrConvTab[f.ErrCode]  	if !ok { -		if logger.V(logLevel) { -			logger.Warningf("transport: http2Client.handleRSTStream found no mapped gRPC status for the received http2 error: %v", f.ErrCode) +		if t.logger.V(logLevel) { +			t.logger.Infof("Received a RST_STREAM frame with code %q, but found no mapped gRPC status", f.ErrCode)  		}  		statusCode = codes.Unknown  	} diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_server.go b/vendor/google.golang.org/grpc/internal/transport/http2_server.go index 99ae1a737..4b406b8cb 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_server.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_server.go @@ -35,7 +35,9 @@ import (  	"github.com/golang/protobuf/proto"  	"golang.org/x/net/http2"  	"golang.org/x/net/http2/hpack" +	"google.golang.org/grpc/internal/grpclog"  	"google.golang.org/grpc/internal/grpcutil" +	"google.golang.org/grpc/internal/pretty"  	"google.golang.org/grpc/internal/syscall"  	"google.golang.org/grpc/codes" @@ -129,6 +131,8 @@ type http2Server struct {  	// This lock may not be taken if mu is already held.  	maxStreamMu sync.Mutex  	maxStreamID uint32 // max stream ID ever seen + +	logger *grpclog.PrefixLogger  }  // NewServerTransport creates a http2 transport with conn and configuration @@ -267,6 +271,7 @@ func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport,  		czData:            new(channelzData),  		bufferPool:        newBufferPool(),  	} +	t.logger = prefixLoggerForServerTransport(t)  	// Add peer information to the http2server context.  	t.ctx = peer.NewContext(t.ctx, t.getPeer()) @@ -331,7 +336,7 @@ func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport,  	t.handleSettings(sf)  	go func() { -		t.loopy = newLoopyWriter(serverSide, t.framer, t.controlBuf, t.bdpEst, t.conn) +		t.loopy = newLoopyWriter(serverSide, t.framer, t.controlBuf, t.bdpEst, t.conn, t.logger)  		t.loopy.ssGoAwayHandler = t.outgoingGoAwayHandler  		t.loopy.run()  		close(t.writerDone) @@ -425,8 +430,8 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(  		// "Transports must consider requests containing the Connection header  		// as malformed." - A41  		case "connection": -			if logger.V(logLevel) { -				logger.Errorf("transport: http2Server.operateHeaders parsed a :connection header which makes a request malformed as per the HTTP/2 spec") +			if t.logger.V(logLevel) { +				t.logger.Infof("Received a HEADERS frame with a :connection header which makes the request malformed, as per the HTTP/2 spec")  			}  			protocolError = true  		default: @@ -436,7 +441,7 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(  			v, err := decodeMetadataHeader(hf.Name, hf.Value)  			if err != nil {  				headerError = status.Newf(codes.Internal, "malformed binary metadata %q in header %q: %v", hf.Value, hf.Name, err) -				logger.Warningf("Failed to decode metadata header (%q, %q): %v", hf.Name, hf.Value, err) +				t.logger.Warningf("Failed to decode metadata header (%q, %q): %v", hf.Name, hf.Value, err)  				break  			}  			mdata[hf.Name] = append(mdata[hf.Name], v) @@ -450,8 +455,8 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(  	// error, this takes precedence over a client not speaking gRPC.  	if len(mdata[":authority"]) > 1 || len(mdata["host"]) > 1 {  		errMsg := fmt.Sprintf("num values of :authority: %v, num values of host: %v, both must only have 1 value as per HTTP/2 spec", len(mdata[":authority"]), len(mdata["host"])) -		if logger.V(logLevel) { -			logger.Errorf("transport: %v", errMsg) +		if t.logger.V(logLevel) { +			t.logger.Infof("Aborting the stream early: %v", errMsg)  		}  		t.controlBuf.put(&earlyAbortStream{  			httpStatus:     http.StatusBadRequest, @@ -545,9 +550,9 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(  	}  	if httpMethod != http.MethodPost {  		t.mu.Unlock() -		errMsg := fmt.Sprintf("http2Server.operateHeaders parsed a :method field: %v which should be POST", httpMethod) -		if logger.V(logLevel) { -			logger.Infof("transport: %v", errMsg) +		errMsg := fmt.Sprintf("Received a HEADERS frame with :method %q which should be POST", httpMethod) +		if t.logger.V(logLevel) { +			t.logger.Infof("Aborting the stream early: %v", errMsg)  		}  		t.controlBuf.put(&earlyAbortStream{  			httpStatus:     405, @@ -563,8 +568,8 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(  		var err error  		if s.ctx, err = t.inTapHandle(s.ctx, &tap.Info{FullMethodName: s.method}); err != nil {  			t.mu.Unlock() -			if logger.V(logLevel) { -				logger.Infof("transport: http2Server.operateHeaders got an error from InTapHandle: %v", err) +			if t.logger.V(logLevel) { +				t.logger.Infof("Aborting the stream early due to InTapHandle failure: %v", err)  			}  			stat, ok := status.FromError(err)  			if !ok { @@ -638,8 +643,8 @@ func (t *http2Server) HandleStreams(handle func(*Stream), traceCtx func(context.  		atomic.StoreInt64(&t.lastRead, time.Now().UnixNano())  		if err != nil {  			if se, ok := err.(http2.StreamError); ok { -				if logger.V(logLevel) { -					logger.Warningf("transport: http2Server.HandleStreams encountered http2.StreamError: %v", se) +				if t.logger.V(logLevel) { +					t.logger.Warningf("Encountered http2.StreamError: %v", se)  				}  				t.mu.Lock()  				s := t.activeStreams[se.StreamID] @@ -682,8 +687,8 @@ func (t *http2Server) HandleStreams(handle func(*Stream), traceCtx func(context.  		case *http2.GoAwayFrame:  			// TODO: Handle GoAway from the client appropriately.  		default: -			if logger.V(logLevel) { -				logger.Errorf("transport: http2Server.HandleStreams found unhandled frame type %v.", frame) +			if t.logger.V(logLevel) { +				t.logger.Infof("Received unsupported frame type %T", frame)  			}  		}  	} @@ -942,8 +947,8 @@ func (t *http2Server) checkForHeaderListSize(it interface{}) bool {  	var sz int64  	for _, f := range hdrFrame.hf {  		if sz += int64(f.Size()); sz > int64(*t.maxSendHeaderListSize) { -			if logger.V(logLevel) { -				logger.Errorf("header list size to send violates the maximum size (%d bytes) set by client", *t.maxSendHeaderListSize) +			if t.logger.V(logLevel) { +				t.logger.Infof("Header list size to send violates the maximum size (%d bytes) set by client", *t.maxSendHeaderListSize)  			}  			return false  		} @@ -1056,7 +1061,7 @@ func (t *http2Server) WriteStatus(s *Stream, st *status.Status) error {  		stBytes, err := proto.Marshal(p)  		if err != nil {  			// TODO: return error instead, when callers are able to handle it. -			logger.Errorf("transport: failed to marshal rpc status: %v, error: %v", p, err) +			t.logger.Errorf("Failed to marshal rpc status: %s, error: %v", pretty.ToJSON(p), err)  		} else {  			headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-status-details-bin", Value: encodeBinHeader(stBytes)})  		} @@ -1171,8 +1176,8 @@ func (t *http2Server) keepalive() {  			select {  			case <-ageTimer.C:  				// Close the connection after grace period. -				if logger.V(logLevel) { -					logger.Infof("transport: closing server transport due to maximum connection age.") +				if t.logger.V(logLevel) { +					t.logger.Infof("Closing server transport due to maximum connection age")  				}  				t.controlBuf.put(closeConnection{})  			case <-t.done: @@ -1223,8 +1228,8 @@ func (t *http2Server) Close(err error) {  		t.mu.Unlock()  		return  	} -	if logger.V(logLevel) { -		logger.Infof("transport: closing: %v", err) +	if t.logger.V(logLevel) { +		t.logger.Infof("Closing: %v", err)  	}  	t.state = closing  	streams := t.activeStreams @@ -1232,8 +1237,8 @@ func (t *http2Server) Close(err error) {  	t.mu.Unlock()  	t.controlBuf.finish()  	close(t.done) -	if err := t.conn.Close(); err != nil && logger.V(logLevel) { -		logger.Infof("transport: error closing conn during Close: %v", err) +	if err := t.conn.Close(); err != nil && t.logger.V(logLevel) { +		t.logger.Infof("Error closing underlying net.Conn during Close: %v", err)  	}  	channelz.RemoveEntry(t.channelzID)  	// Cancel all active streams. diff --git a/vendor/google.golang.org/grpc/internal/transport/http_util.go b/vendor/google.golang.org/grpc/internal/transport/http_util.go index 8fcae4f4d..19cbb18f5 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http_util.go +++ b/vendor/google.golang.org/grpc/internal/transport/http_util.go @@ -38,7 +38,6 @@ import (  	"golang.org/x/net/http2/hpack"  	spb "google.golang.org/genproto/googleapis/rpc/status"  	"google.golang.org/grpc/codes" -	"google.golang.org/grpc/grpclog"  	"google.golang.org/grpc/status"  ) @@ -86,7 +85,6 @@ var (  		// 504 Gateway timeout - UNAVAILABLE.  		http.StatusGatewayTimeout: codes.Unavailable,  	} -	logger = grpclog.Component("transport")  )  // isReservedHeader checks whether hdr belongs to HTTP2 headers diff --git a/vendor/google.golang.org/grpc/internal/transport/logging.go b/vendor/google.golang.org/grpc/internal/transport/logging.go new file mode 100644 index 000000000..42ed2b07a --- /dev/null +++ b/vendor/google.golang.org/grpc/internal/transport/logging.go @@ -0,0 +1,40 @@ +/* + * + * Copyright 2023 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + *     http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package transport + +import ( +	"fmt" + +	"google.golang.org/grpc/grpclog" +	internalgrpclog "google.golang.org/grpc/internal/grpclog" +) + +var logger = grpclog.Component("transport") + +func prefixLoggerForServerTransport(p *http2Server) *internalgrpclog.PrefixLogger { +	return internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf("[server-transport %p] ", p)) +} + +func prefixLoggerForServerHandlerTransport(p *serverHandlerTransport) *internalgrpclog.PrefixLogger { +	return internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf("[server-handler-transport %p] ", p)) +} + +func prefixLoggerForClientTransport(p *http2Client) *internalgrpclog.PrefixLogger { +	return internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf("[client-transport %p] ", p)) +} diff --git a/vendor/google.golang.org/grpc/server.go b/vendor/google.golang.org/grpc/server.go index 087b9ad7c..76d152a69 100644 --- a/vendor/google.golang.org/grpc/server.go +++ b/vendor/google.golang.org/grpc/server.go @@ -43,7 +43,6 @@ import (  	"google.golang.org/grpc/internal"  	"google.golang.org/grpc/internal/binarylog"  	"google.golang.org/grpc/internal/channelz" -	"google.golang.org/grpc/internal/grpcrand"  	"google.golang.org/grpc/internal/grpcsync"  	"google.golang.org/grpc/internal/grpcutil"  	"google.golang.org/grpc/internal/transport" @@ -146,7 +145,7 @@ type Server struct {  	channelzID *channelz.Identifier  	czData     *channelzData -	serverWorkerChannels []chan *serverWorkerData +	serverWorkerChannel chan *serverWorkerData  }  type serverOptions struct { @@ -561,40 +560,38 @@ func NumStreamWorkers(numServerWorkers uint32) ServerOption {  const serverWorkerResetThreshold = 1 << 16  // serverWorkers blocks on a *transport.Stream channel forever and waits for -// data to be fed by serveStreams. This allows different requests to be +// data to be fed by serveStreams. This allows multiple requests to be  // processed by the same goroutine, removing the need for expensive stack  // re-allocations (see the runtime.morestack problem [1]).  //  // [1] https://github.com/golang/go/issues/18138 -func (s *Server) serverWorker(ch chan *serverWorkerData) { -	// To make sure all server workers don't reset at the same time, choose a -	// random number of iterations before resetting. -	threshold := serverWorkerResetThreshold + grpcrand.Intn(serverWorkerResetThreshold) -	for completed := 0; completed < threshold; completed++ { -		data, ok := <-ch +func (s *Server) serverWorker() { +	for completed := 0; completed < serverWorkerResetThreshold; completed++ { +		data, ok := <-s.serverWorkerChannel  		if !ok {  			return  		} -		s.handleStream(data.st, data.stream, s.traceInfo(data.st, data.stream)) -		data.wg.Done() +		s.handleSingleStream(data)  	} -	go s.serverWorker(ch) +	go s.serverWorker()  } -// initServerWorkers creates worker goroutines and channels to process incoming +func (s *Server) handleSingleStream(data *serverWorkerData) { +	defer data.wg.Done() +	s.handleStream(data.st, data.stream, s.traceInfo(data.st, data.stream)) +} + +// initServerWorkers creates worker goroutines and a channel to process incoming  // connections to reduce the time spent overall on runtime.morestack.  func (s *Server) initServerWorkers() { -	s.serverWorkerChannels = make([]chan *serverWorkerData, s.opts.numServerWorkers) +	s.serverWorkerChannel = make(chan *serverWorkerData)  	for i := uint32(0); i < s.opts.numServerWorkers; i++ { -		s.serverWorkerChannels[i] = make(chan *serverWorkerData) -		go s.serverWorker(s.serverWorkerChannels[i]) +		go s.serverWorker()  	}  }  func (s *Server) stopServerWorkers() { -	for i := uint32(0); i < s.opts.numServerWorkers; i++ { -		close(s.serverWorkerChannels[i]) -	} +	close(s.serverWorkerChannel)  }  // NewServer creates a gRPC server which has no service registered and has not @@ -946,26 +943,21 @@ func (s *Server) serveStreams(st transport.ServerTransport) {  	defer st.Close(errors.New("finished serving streams for the server transport"))  	var wg sync.WaitGroup -	var roundRobinCounter uint32  	st.HandleStreams(func(stream *transport.Stream) {  		wg.Add(1)  		if s.opts.numServerWorkers > 0 {  			data := &serverWorkerData{st: st, wg: &wg, stream: stream}  			select { -			case s.serverWorkerChannels[atomic.AddUint32(&roundRobinCounter, 1)%s.opts.numServerWorkers] <- data: +			case s.serverWorkerChannel <- data: +				return  			default:  				// If all stream workers are busy, fallback to the default code path. -				go func() { -					s.handleStream(st, stream, s.traceInfo(st, stream)) -					wg.Done() -				}()  			} -		} else { -			go func() { -				defer wg.Done() -				s.handleStream(st, stream, s.traceInfo(st, stream)) -			}()  		} +		go func() { +			defer wg.Done() +			s.handleStream(st, stream, s.traceInfo(st, stream)) +		}()  	}, func(ctx context.Context, method string) context.Context {  		if !EnableTracing {  			return ctx diff --git a/vendor/google.golang.org/grpc/status/status.go b/vendor/google.golang.org/grpc/status/status.go index 623be39f2..53910fb7c 100644 --- a/vendor/google.golang.org/grpc/status/status.go +++ b/vendor/google.golang.org/grpc/status/status.go @@ -77,7 +77,9 @@ func FromProto(s *spb.Status) *Status {  // FromError returns a Status representation of err.  //  //   - If err was produced by this package or implements the method `GRPCStatus() -//     *Status`, the appropriate Status is returned. +//     *Status`, or if err wraps a type satisfying this, the appropriate Status is +//     returned.  For wrapped errors, the message returned contains the entire +//     err.Error() text and not just the wrapped status.  //  //   - If err is nil, a Status is returned with codes.OK and no message.  // @@ -88,10 +90,15 @@ func FromError(err error) (s *Status, ok bool) {  	if err == nil {  		return nil, true  	} -	if se, ok := err.(interface { -		GRPCStatus() *Status -	}); ok { -		return se.GRPCStatus(), true +	type grpcstatus interface{ GRPCStatus() *Status } +	if gs, ok := err.(grpcstatus); ok { +		return gs.GRPCStatus(), true +	} +	var gs grpcstatus +	if errors.As(err, &gs) { +		p := gs.GRPCStatus().Proto() +		p.Message = err.Error() +		return status.FromProto(p), true  	}  	return New(codes.Unknown, err.Error()), false  } @@ -103,19 +110,16 @@ func Convert(err error) *Status {  	return s  } -// Code returns the Code of the error if it is a Status error, codes.OK if err -// is nil, or codes.Unknown otherwise. +// Code returns the Code of the error if it is a Status error or if it wraps a +// Status error. If that is not the case, it returns codes.OK if err is nil, or +// codes.Unknown otherwise.  func Code(err error) codes.Code {  	// Don't use FromError to avoid allocation of OK status.  	if err == nil {  		return codes.OK  	} -	if se, ok := err.(interface { -		GRPCStatus() *Status -	}); ok { -		return se.GRPCStatus().Code() -	} -	return codes.Unknown + +	return Convert(err).Code()  }  // FromContextError converts a context error or wrapped context error into a diff --git a/vendor/google.golang.org/grpc/version.go b/vendor/google.golang.org/grpc/version.go index 3c6e3c911..853ce0e30 100644 --- a/vendor/google.golang.org/grpc/version.go +++ b/vendor/google.golang.org/grpc/version.go @@ -19,4 +19,4 @@  package grpc  // Version is the current grpc version. -const Version = "1.54.0" +const Version = "1.55.0" | 
