feat: add stop subscribe api, show reasons for subscriber closure

This commit is contained in:
langhuihui
2023-08-06 14:16:06 +08:00
parent 9a352bcbad
commit 1a347b5a0b
24 changed files with 238 additions and 188 deletions

View File

@@ -55,7 +55,8 @@ func (b *LimitBuffer) Write(a []byte) (n int, err error) {
l := b.Len()
newL := l + len(a)
if c := b.Cap(); newL > c {
panic(fmt.Sprintf("LimitBuffer Write %d > %d", newL, c))
return 0, fmt.Errorf("LimitBuffer Write %d > %d", newL, c)
// panic(fmt.Sprintf("LimitBuffer Write %d > %d", newL, c))
} else {
b.Buffer = b.Buffer.SubBuf(0, newL)
copy(b.Buffer[l:], a)