Manager paradigm change to an event-loop concurrency style, begun implementing batching in binance futures_websocket.go
This commit is contained in:
@@ -22,7 +22,7 @@ func NewGRPCControlServer(m *manager.Manager) *GRPCControlServer {
|
||||
}
|
||||
|
||||
// StartStream creates a new session. It does NOT attach client channels.
|
||||
// Your streaming RPC should later call GetChannels(sessionID, opts).
|
||||
// Your streaming RPC should later call AttachClient(sessionID, opts).
|
||||
func (s *GRPCControlServer) StartStream(_ context.Context, req *pb.StartStreamRequest) (*pb.StartStreamResponse, error) {
|
||||
sessionID, err := s.manager.NewSession(time.Duration(1) * time.Minute) // timeout set to 1 minute
|
||||
if err != nil {
|
||||
@@ -51,7 +51,7 @@ func (s *GRPCControlServer) ConfigureStream(_ context.Context, req *pb.Configure
|
||||
ids = append(ids, id)
|
||||
}
|
||||
|
||||
if err := s.manager.SetSubscriptions(streamID, ids); err != nil {
|
||||
if err := s.manager.ConfigureSession(streamID, ids); err != nil {
|
||||
// Map common manager errors to gRPC codes.
|
||||
switch err {
|
||||
case manager.ErrSessionNotFound:
|
||||
|
||||
@@ -28,15 +28,7 @@ func (s *GRPCStreamingServer) ConnectStream(req *pb.ConnectStreamRequest, stream
|
||||
return fmt.Errorf("invalid UUID: %w", err)
|
||||
}
|
||||
|
||||
// Defaults; tune or map from req if your proto carries options.
|
||||
opts := manager.ChannelOpts{
|
||||
InBufSize: 256,
|
||||
OutBufSize: 1024,
|
||||
DropOutbound: true, // do not let slow clients stall producers
|
||||
DropInbound: true, // irrelevant here (we don't send inbound), safe default
|
||||
}
|
||||
|
||||
_, out, err := s.manager.GetChannels(sessionID, opts)
|
||||
_, out, err := s.manager.AttachClient(sessionID, 256, 1024)
|
||||
if err != nil {
|
||||
return fmt.Errorf("attach channels: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user