fix: close stream adaptive gaps and switch notify to stario v0.1.1

- make stream fast path honor adaptive soft payload limits end-to-end
  - split oversized fast-stream payloads into sequential frames before batching
  - use adaptive soft cap when encoding stream batch payloads
  - move timeout-like error detection into production code for adaptive tx
  - tune notify FrameReader read size explicitly to avoid throughput regression
  - drop local stario replace and depend on released b612.me/stario v0.1.1
This commit is contained in:
2026-04-18 16:05:57 +08:00
parent 4f760f2807
commit f038a89771
76 changed files with 12656 additions and 906 deletions
+55 -20
View File
@@ -59,26 +59,8 @@ func (s *ServerCommon) pushMessageSourceFast(queue *stario.StarQueue, data []byt
if queue == nil || dispatcher == nil || len(data) == 0 {
return false
}
if err := queue.ParseMessageOwned(data, source, func(msg stario.MsgQueue) error {
payload := msg.Msg
source := msg.Conn
s.wg.Add(1)
if !dispatcher.Dispatch(serverInboundDispatchSource(source), func() {
defer s.wg.Done()
logical, transport := s.resolveInboundSource(source)
if logical == nil {
return
}
now := time.Now()
inboundConn := serverInboundConn(source)
if err := s.dispatchInboundTransportPayload(logical, transport, inboundConn, payload, now); err != nil {
if s.showError || s.debugMode {
fmt.Println("server decode envelope error", err)
}
}
}) {
s.wg.Done()
}
if err := queue.ParseMessageView(data, source, func(frame stario.FrameView) error {
s.pushTransportPayloadSourceFast(frame.Payload, nil, frame.Conn)
return nil
}); err != nil && (s.showError || s.debugMode) {
fmt.Println("server parse inbound frame error", err)
@@ -86,6 +68,59 @@ func (s *ServerCommon) pushMessageSourceFast(queue *stario.StarQueue, data []byt
return true
}
func (s *ServerCommon) pushTransportPayloadSourceFast(payload []byte, release func(), source interface{}) bool {
dispatcher := s.serverInboundDispatcherSnapshot()
if len(payload) == 0 {
if release != nil {
release()
}
return false
}
if dispatcher == nil {
queue := s.serverQueueSnapshot()
if queue == nil {
if release != nil {
release()
}
return false
}
frame := queue.BuildMessage(payload)
if release != nil {
release()
}
if err := queue.ParseMessage(frame, source); err != nil && (s.showError || s.debugMode) {
fmt.Println("server enqueue inbound frame error", err)
}
return true
}
if s.tryDispatchBorrowedBulkTransportPayload(source, payload) {
if release != nil {
release()
}
return true
}
owned := append([]byte(nil), payload...)
if release != nil {
release()
}
s.wg.Add(1)
if !dispatcher.Dispatch(serverInboundDispatchSource(source), func() {
defer s.wg.Done()
logical, transport := s.resolveInboundSource(source)
if logical == nil {
return
}
now := time.Now()
inboundConn := serverInboundConn(source)
if err := s.dispatchInboundTransportPayload(logical, transport, inboundConn, owned, now); err != nil && (s.showError || s.debugMode) {
fmt.Println("server decode envelope error", err)
}
}) {
s.wg.Done()
}
return true
}
func serverInboundConn(source interface{}) net.Conn {
switch data := source.(type) {
case net.Conn: