Todo: 集成多平台 解决因SaiNiu线程抢占资源问题 本地提交测试环境打包 和 正式打包脚本与正式环境打包bat 提交Python32环境包 改进多日志文件生成情况修改打包日志细节

This commit is contained in:
2025-09-18 15:52:03 +08:00
parent 8b9fc925fa
commit 7cfc0c22b7
7608 changed files with 2424791 additions and 25 deletions

View File

@@ -0,0 +1,123 @@
from __future__ import annotations
from collections.abc import Sequence
from ..frames import Frame
from ..typing import ExtensionName, ExtensionParameter
__all__ = ["Extension", "ClientExtensionFactory", "ServerExtensionFactory"]
class Extension:
"""
Base class for extensions.
"""
name: ExtensionName
"""Extension identifier."""
def decode(self, frame: Frame, *, max_size: int | None = None) -> Frame:
"""
Decode an incoming frame.
Args:
frame: Incoming frame.
max_size: Maximum payload size in bytes.
Returns:
Decoded frame.
Raises:
PayloadTooBig: If decoding the payload exceeds ``max_size``.
"""
raise NotImplementedError
def encode(self, frame: Frame) -> Frame:
"""
Encode an outgoing frame.
Args:
frame: Outgoing frame.
Returns:
Encoded frame.
"""
raise NotImplementedError
class ClientExtensionFactory:
"""
Base class for client-side extension factories.
"""
name: ExtensionName
"""Extension identifier."""
def get_request_params(self) -> Sequence[ExtensionParameter]:
"""
Build parameters to send to the server for this extension.
Returns:
Parameters to send to the server.
"""
raise NotImplementedError
def process_response_params(
self,
params: Sequence[ExtensionParameter],
accepted_extensions: Sequence[Extension],
) -> Extension:
"""
Process parameters received from the server.
Args:
params: Parameters received from the server for this extension.
accepted_extensions: List of previously accepted extensions.
Returns:
An extension instance.
Raises:
NegotiationError: If parameters aren't acceptable.
"""
raise NotImplementedError
class ServerExtensionFactory:
"""
Base class for server-side extension factories.
"""
name: ExtensionName
"""Extension identifier."""
def process_request_params(
self,
params: Sequence[ExtensionParameter],
accepted_extensions: Sequence[Extension],
) -> tuple[list[ExtensionParameter], Extension]:
"""
Process parameters received from the client.
Args:
params: Parameters received from the client for this extension.
accepted_extensions: List of previously accepted extensions.
Returns:
To accept the offer, parameters to send to the client for this
extension and an extension instance.
Raises:
NegotiationError: To reject the offer, if parameters received from
the client aren't acceptable.
"""
raise NotImplementedError