Refactor stream management: rename stream methods to use 'Client' prefix for clarity and update related logic in gRPC and manager files
This commit is contained in:
@@ -22,7 +22,7 @@ func NewGRPCControlServer(m *manager.Manager) *GRPCControlServer {
|
||||
}
|
||||
|
||||
func (s *GRPCControlServer) StartStream(_ context.Context, _ *pb.StartStreamRequest) (*pb.StartStreamResponse, error) {
|
||||
streamID, err := s.manager.StartStream()
|
||||
streamID, err := s.manager.StartClientStream()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to start stream: %w", err)
|
||||
}
|
||||
@@ -44,7 +44,7 @@ func (s *GRPCControlServer) ConfigureStream(_ context.Context, req *pb.Configure
|
||||
ids = append(ids, id)
|
||||
}
|
||||
|
||||
if err := s.manager.ConfigureStream(streamID, ids); err != nil {
|
||||
if err := s.manager.ConfigureClientStream(streamID, ids); err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "configure failed: %v", err)
|
||||
}
|
||||
return &pb.ConfigureStreamResponse{}, nil
|
||||
@@ -55,7 +55,7 @@ func (s *GRPCControlServer) StopStream(_ context.Context, req *pb.StopStreamRequ
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid stream_uuid %q: %v", req.StreamUuid, err)
|
||||
}
|
||||
if err := s.manager.StopStream(streamID); err != nil {
|
||||
if err := s.manager.StopClientStream(streamID); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to stop stream: %v", err)
|
||||
}
|
||||
return &pb.StopStreamResponse{}, nil
|
||||
|
||||
@@ -23,7 +23,7 @@ func (s *GRPCStreamingServer) ConnectStream(req *pb.ConnectStreamRequest, stream
|
||||
return fmt.Errorf("invalid UUID: %w", err)
|
||||
}
|
||||
|
||||
ch, err := s.manager.ConnectStream(streamUUID)
|
||||
ch, err := s.manager.ConnectClientStream(streamUUID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to connect: %w", err)
|
||||
}
|
||||
@@ -31,7 +31,7 @@ func (s *GRPCStreamingServer) ConnectStream(req *pb.ConnectStreamRequest, stream
|
||||
for {
|
||||
select {
|
||||
case <-stream.Context().Done():
|
||||
s.manager.DisconnectStream(streamUUID)
|
||||
s.manager.DisconnectClientStream(streamUUID)
|
||||
return nil
|
||||
case msg, ok := <-ch:
|
||||
if !ok {
|
||||
|
||||
@@ -66,12 +66,12 @@ func (s *SocketStreamingServer) handleConnection(conn net.Conn) {
|
||||
return
|
||||
}
|
||||
|
||||
outCh, err := s.manager.ConnectStream(streamUUID)
|
||||
outCh, err := s.manager.ConnectClientStream(streamUUID)
|
||||
if err != nil {
|
||||
_, _ = fmt.Fprintf(conn, "Failed to connect to stream: %v\n", err)
|
||||
return
|
||||
}
|
||||
defer s.manager.DisconnectStream(streamUUID)
|
||||
defer s.manager.DisconnectClientStream(streamUUID)
|
||||
|
||||
writer := bufio.NewWriterSize(conn, 256*1024)
|
||||
defer func(w *bufio.Writer) {
|
||||
|
||||
Reference in New Issue
Block a user