This commit is contained in:
chrislu committed 2025-09-10 12:30:11 -07:00
1 parent 7c4a5f546c
commit fdb7f94526
2 files changed
+20 -20

No files matched your search

+18 -18
View File
@@ -1,12 +1,12 @@
package gateway package gateway
import ( import (
"context" "context"
"net" "net"
"sync" "sync"
"github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/mq/kafka/protocol" "github.com/seaweedfs/seaweedfs/weed/mq/kafka/protocol"
) )
type Options struct { type Options struct {
@@ -14,12 +14,12 @@ type Options struct {
} }
type Server struct { type Server struct {
opts Options opts Options
ln net.Listener ln net.Listener
wg sync.WaitGroup wg sync.WaitGroup
ctx context.Context ctx context.Context
cancel context.CancelFunc cancel context.CancelFunc
handler *protocol.Handler handler *protocol.Handler
} }
func NewServer(opts Options) *Server { func NewServer(opts Options) *Server {
@@ -51,13 +51,13 @@ func (s *Server) Start() error {
return return
} }
} }
s.wg.Add(1) s.wg.Add(1)
go func(c net.Conn) { go func(c net.Conn) {
defer s.wg.Done() defer s.wg.Done()
if err := s.handler.HandleConn(c); err != nil { if err := s.handler.HandleConn(c); err != nil {
glog.V(1).Infof("handle conn %v: %v", c.RemoteAddr(), err) glog.V(1).Infof("handle conn %v: %v", c.RemoteAddr(), err)
} }
}(conn) }(conn)
} }
}() }()
return nil return nil
+2 -2
View File
@@ -28,8 +28,8 @@ func TestHandler_ApiVersions(t *testing.T) {
clientID := "test-client" clientID := "test-client"
message := make([]byte, 0, 64) message := make([]byte, 0, 64)
message = append(message, 0, 18) // API key 18 (ApiVersions) message = append(message, 0, 18) // API key 18 (ApiVersions)
message = append(message, 0, 0) // API version 0 message = append(message, 0, 0) // API version 0
// Correlation ID // Correlation ID
correlationIDBytes := make([]byte, 4) correlationIDBytes := make([]byte, 4)