notify/servertype.go
starainrt f038a89771
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
2026-04-18 16:05:57 +08:00

112 lines
5.6 KiB
Go

package notify
import (
"context"
"net"
"time"
)
type Server interface {
// Deprecated: SetDefaultCommEncode overrides the transport codec directly.
// Prefer UseModernPSKServer or UseLegacySecurityServer.
SetDefaultCommEncode(func([]byte, []byte) []byte)
// Deprecated: SetDefaultCommDecode overrides the transport codec directly.
// Prefer UseModernPSKServer or UseLegacySecurityServer.
SetDefaultCommDecode(func([]byte, []byte) []byte)
SetDefaultLink(func(message *Message))
SetLink(string, func(*Message))
SetFileHandler(func(FileEvent))
SetStreamHandler(func(StreamAcceptInfo) error)
SetRecordStreamHandler(func(RecordAcceptInfo) error)
SetBulkHandler(func(BulkAcceptInfo) error)
SetTransferHandler(func(TransferAcceptInfo) (TransferReceiveOptions, error))
GetStreamConfig() StreamConfig
SetStreamConfig(StreamConfig)
SetTransferResumeStore(TransferResumeStore)
RecoverTransferSnapshots(context.Context) error
SetBulkOpenTuning(BulkOpenTuning)
BulkOpenTuning() BulkOpenTuning
SetFileReceiveDir(dir string) error
send(c *ClientConn, msg TransferMsg) (WaitMsg, error)
sendEnvelope(c *ClientConn, env Envelope) error
sendWait(c *ClientConn, msg TransferMsg, timeout time.Duration) (Message, error)
OpenStreamLogical(ctx context.Context, c *LogicalConn, opt StreamOpenOptions) (Stream, error)
OpenStreamTransport(ctx context.Context, t *TransportConn, opt StreamOpenOptions) (Stream, error)
OpenRecordStreamLogical(ctx context.Context, c *LogicalConn, opt RecordOpenOptions) (RecordStream, error)
OpenRecordStreamTransport(ctx context.Context, t *TransportConn, opt RecordOpenOptions) (RecordStream, error)
OpenBulkLogical(ctx context.Context, c *LogicalConn, opt BulkOpenOptions) (Bulk, error)
OpenBulkTransport(ctx context.Context, t *TransportConn, opt BulkOpenOptions) (Bulk, error)
SendTransferLogical(ctx context.Context, c *LogicalConn, opt TransferSendOptions) (TransferHandle, error)
SendTransferTransport(ctx context.Context, t *TransportConn, opt TransferSendOptions) (TransferHandle, error)
SendObjCtxLogical(ctx context.Context, c *LogicalConn, key string, val interface{}) (Message, error)
SendObjLogical(c *LogicalConn, key string, val interface{}) error
SendLogical(c *LogicalConn, key string, value MsgVal) error
SendWaitLogical(c *LogicalConn, key string, value MsgVal, timeout time.Duration) (Message, error)
SendWaitObjLogical(c *LogicalConn, key string, value interface{}, timeout time.Duration) (Message, error)
SendCtxLogical(ctx context.Context, c *LogicalConn, key string, value MsgVal) (Message, error)
SendObjCtxTransport(ctx context.Context, t *TransportConn, key string, val interface{}) (Message, error)
SendObjTransport(t *TransportConn, key string, val interface{}) error
SendTransport(t *TransportConn, key string, value MsgVal) error
SendWaitTransport(t *TransportConn, key string, value MsgVal, timeout time.Duration) (Message, error)
SendWaitObjTransport(t *TransportConn, key string, value interface{}, timeout time.Duration) (Message, error)
SendCtxTransport(ctx context.Context, t *TransportConn, key string, value MsgVal) (Message, error)
// Deprecated: prefer the LogicalConn/TransportConn variants.
SendObjCtx(ctx context.Context, c *ClientConn, key string, val interface{}) (Message, error)
// Deprecated: prefer the LogicalConn/TransportConn variants.
SendObj(c *ClientConn, key string, val interface{}) error
// Deprecated: prefer the LogicalConn/TransportConn variants.
Send(c *ClientConn, key string, value MsgVal) error
// Deprecated: prefer the LogicalConn/TransportConn variants.
SendWait(c *ClientConn, key string, value MsgVal, timeout time.Duration) (Message, error)
// Deprecated: prefer the LogicalConn/TransportConn variants.
SendWaitObj(c *ClientConn, key string, value interface{}, timeout time.Duration) (Message, error)
// Deprecated: prefer the LogicalConn/TransportConn variants.
SendCtx(ctx context.Context, c *ClientConn, key string, value MsgVal) (Message, error)
Reply(m Message, value MsgVal) error
pushMessage([]byte, string)
removeLogical(logical *LogicalConn)
removeClient(client *ClientConn)
Listen(network string, addr string) error
ListenByListener(listener net.Listener) error
Stop() error
StopMonitorChan() <-chan struct{}
Status() Status
GetSecretKey() []byte
// Deprecated: SetSecretKey injects a raw transport key directly.
// Prefer UseModernPSKServer or UseLegacySecurityServer.
SetSecretKey(key []byte)
// Deprecated: RsaPrivKey exposes the legacy RSA handshake key. Prefer UseModernPSKServer.
RsaPrivKey() []byte
// Deprecated: SetRsaPrivKey configures the legacy RSA handshake key. Prefer UseModernPSKServer.
SetRsaPrivKey([]byte)
GetLogicalConn(id string) *LogicalConn
GetLogicalConnList() []*LogicalConn
GetCurrentTransportConn(id string) *TransportConn
GetCurrentTransportConnByLogical(c *LogicalConn) *TransportConn
GetCurrentTransportConnList() []*TransportConn
// Deprecated: prefer GetLogicalConn.
GetClient(id string) *ClientConn
// Deprecated: prefer GetLogicalConnList.
GetClientLists() []*ClientConn
GetClientAddrs() []net.Addr
GetSequenceEn() func(interface{}) ([]byte, error)
SetSequenceEn(func(interface{}) ([]byte, error))
GetSequenceDe() func([]byte) (interface{}, error)
SetSequenceDe(func([]byte) (interface{}, error))
ShowError(bool)
DebugMode(bool)
IsDebugMode() bool
HeartbeatTimeoutSec() int64
SetHeartbeatTimeoutSec(int64)
DetachedClientKeepSec() int64
SetDetachedClientKeepSec(int64)
SendFileLogical(ctx context.Context, c *LogicalConn, filePath string) error
SendFileTransport(ctx context.Context, t *TransportConn, filePath string) error
// Deprecated: prefer SendFileLogical or SendFileTransport.
SendFile(ctx context.Context, c *ClientConn, filePath string) error
}