refactor: add context propagation to connection and event systems

This commit is contained in:
adman
2026-04-29 23:38:24 +02:00
parent 159437c1ca
commit 96481da0a4
4 changed files with 21 additions and 8 deletions
+5 -2
View File
@@ -269,8 +269,11 @@ func (c *Conn) Receive() (packet proto_base.EncodeDecodeAble, err error) {
}
return
}
func NewConn() (ret *Conn) {
return NewConnCtx(context.Background())
}
func NewConnCtx(ctx context.Context) (ret *Conn) {
ret = &Conn{}
ret.SetState(proto_base.Handshaking)
ret.SetCompressionThreshold(-1)
@@ -278,7 +281,7 @@ func NewConn() (ret *Conn) {
if err != nil {
panic(err)
}
ret.Loop = event.NewLoop()
ret.Loop = event.NewLoopCtx(ctx)
ret.Log = slog.Default()
return
}