socket.d 2.4.12__tar.gz → 2.4.13__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {socket.d-2.4.12 → socket.d-2.4.13}/PKG-INFO +1 -1
- {socket.d-2.4.12 → socket.d-2.4.13}/setup.py +1 -1
- {socket.d-2.4.12 → socket.d-2.4.13}/socket.d.egg-info/PKG-INFO +1 -1
- {socket.d-2.4.12 → socket.d-2.4.13}/socket.d.egg-info/SOURCES.txt +1 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/SocketD.py +3 -3
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/broker/BrokerListener.py +1 -1
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/broker/BrokerListenerBase.py +2 -1
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/cluster/ClusterClient.py +9 -8
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/exception/SocketDExecption.py +8 -1
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/client/ClientChannel.py +3 -1
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/Session.py +4 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/codec/CodecDefault.py +5 -6
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/entity/EntityDefault.py +3 -2
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/entity/MessageDefault.py +3 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/fragment/FragmentAggregatorDefault.py +2 -1
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/impl/ChannelBase.py +3 -2
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/impl/ChannelDefault.py +3 -2
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/impl/ProcessorDefault.py +9 -6
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/impl/SessionBase.py +5 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/impl/SessionDefault.py +9 -5
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/listener/RouteSelectorDefault.py +6 -5
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/stream/RequestStream.py +3 -3
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/stream/StreamMangerDefault.py +2 -1
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/stream/impl/StreamBase.py +2 -3
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/utils/CompletableFuture.py +2 -2
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/utils/LogConfig.py +2 -2
- socket.d-2.4.13/socketd/utils/MapUtils.py +7 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_websocket/impl/AIOWebSocketClientImpl.py +6 -5
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_websocket/impl/AIOWebSocketServerImpl.py +3 -1
- {socket.d-2.4.12 → socket.d-2.4.13}/README.md +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/setup.cfg +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socket.d.egg-info/dependency_links.txt +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socket.d.egg-info/requires.txt +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socket.d.egg-info/top_level.txt +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socket.d.egg-info/zip-safe +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/broker/BrokerFragmentHandler.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/broker/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/cluster/ClusterClientSession.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/cluster/LoadBalancer.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/cluster/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/exception/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/client/Client.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/client/ClientBase.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/client/ClientConfig.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/client/ClientConfigHandler.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/client/ClientConnectHandler.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/client/ClientConnector.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/client/ClientConnectorBase.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/client/ClientHandshakeResult.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/client/ClientHeartbeatHandler.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/client/ClientProvider.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/client/ClientSession.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/client/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/Asserts.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/Channel.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/ChannelAssistant.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/ChannelInternal.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/ChannelSupporter.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/Codec.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/Config.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/Costants.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/Entity.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/EntityMetas.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/Flags.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/FragmentAggregator.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/FragmentHandler.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/Frame.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/Frames.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/HandshakeDefault.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/IdGenerator.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/Listener.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/Message.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/Processor.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/codec/Buffer.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/codec/ByteBufferCodecReader.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/codec/ByteBufferCodecWriter.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/codec/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/entity/FileEntity.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/entity/MessageBuilder.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/entity/StringEntity.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/entity/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/fragment/FragmentHandlerBase.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/fragment/FragmentHandlerDefault.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/fragment/FragmentHolder.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/fragment/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/impl/ConfigBase.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/impl/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/listener/EventListener.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/listener/PathListener.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/listener/PipelineListener.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/listener/RouteSelector.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/listener/SimpleListener.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/listener/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/server/Server.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/server/ServerBase.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/server/ServerConfig.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/server/ServerProvider.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/server/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/stream/SendStream.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/stream/Stream.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/stream/StreamManger.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/stream/SubscribeStream.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/stream/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/stream/impl/RequestStreamImpl.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/stream/impl/SendStreamImpl.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/stream/impl/SubscribeStreamImpl.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/stream/impl/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/utils/AsyncUtils.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/utils/RunUtils.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/utils/StrUtils.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/utils/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/utils/async_api/AtomicRefer.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/utils/async_api/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/utils/sync_api/AtomicRefer.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd/utils/sync_api/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_aio_tcp/TCPAIOServer.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_aio_tcp/TCPStreamIO.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_aio_tcp/TcpAIOChannelAssistant.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_aio_tcp/TcpAioClient.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_aio_tcp/TcpAioClientConnector.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_aio_tcp/TcpAioProvider.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_aio_tcp/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_websocket/WsAioChannelAssistant.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_websocket/WsAioClient.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_websocket/WsAioClientConnector.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_websocket/WsAioProvider.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_websocket/WsAioServer.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_websocket/__init__.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_websocket/impl/AIOConnect.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_websocket/impl/AIOServe.py +0 -0
- {socket.d-2.4.12 → socket.d-2.4.13}/socketd_websocket/impl/__init__.py +0 -0
@@ -104,6 +104,7 @@ socketd/transport/stream/impl/__init__.py
|
|
104
104
|
socketd/utils/AsyncUtils.py
|
105
105
|
socketd/utils/CompletableFuture.py
|
106
106
|
socketd/utils/LogConfig.py
|
107
|
+
socketd/utils/MapUtils.py
|
107
108
|
socketd/utils/RunUtils.py
|
108
109
|
socketd/utils/StrUtils.py
|
109
110
|
socketd/utils/__init__.py
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import Dict
|
2
2
|
|
3
|
-
|
3
|
+
from socketd.cluster.ClusterClient import ClusterClient
|
4
4
|
from socketd.transport.client.ClientConfig import ClientConfig
|
5
5
|
from socketd.transport.client.Client import Client
|
6
6
|
from socketd.transport.client.ClientProvider import ClientProvider
|
@@ -14,7 +14,7 @@ from socketd_aio_tcp.TcpAioProvider import TcpAioProvider
|
|
14
14
|
|
15
15
|
|
16
16
|
def version() -> str:
|
17
|
-
return "2.4.
|
17
|
+
return "2.4.13"
|
18
18
|
|
19
19
|
|
20
20
|
def protocol_version() -> str:
|
@@ -81,7 +81,7 @@ def create_client_or_null(config: ClientConfig) -> Client | None:
|
|
81
81
|
|
82
82
|
|
83
83
|
def create_cluster_client(*urls) -> Client:
|
84
|
-
return ClusterClient(
|
84
|
+
return ClusterClient(urls)
|
85
85
|
|
86
86
|
|
87
87
|
# Initialize the client and server factory maps
|
@@ -6,6 +6,7 @@ from socketd.transport.core.EntityMetas import EntityMetas
|
|
6
6
|
from socketd.transport.core.Listener import Listener
|
7
7
|
from socketd.transport.core.Message import Message
|
8
8
|
from socketd.transport.core.Session import Session
|
9
|
+
from socketd.utils.MapUtils import MapUtils
|
9
10
|
from socketd.utils.StrUtils import StrUtils
|
10
11
|
|
11
12
|
|
@@ -79,4 +80,4 @@ class BrokerListenerBase(Listener, ABC):
|
|
79
80
|
if tmp is not None:
|
80
81
|
tmp.remove(session)
|
81
82
|
|
82
|
-
self.__sessionAll
|
83
|
+
MapUtils.remove(self.__sessionAll, session.session_id())
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import asyncio
|
2
|
-
from typing import
|
2
|
+
from typing import List
|
3
3
|
|
4
4
|
from socketd import SocketD
|
5
5
|
from socketd.cluster.ClusterClientSession import ClusterClientSession
|
@@ -14,8 +14,8 @@ from socketd.transport.client.ClientHeartbeatHandler import ClientHeartbeatHandl
|
|
14
14
|
|
15
15
|
class ClusterClient(Client):
|
16
16
|
|
17
|
-
def __init__(self,
|
18
|
-
self.__serverUrls:
|
17
|
+
def __init__(self, serverUrls:tuple[str]):
|
18
|
+
self.__serverUrls:tuple[str] = serverUrls
|
19
19
|
|
20
20
|
self.__connectHandler: ClientConnectHandler = None
|
21
21
|
self.__heartbeatHandler: ClientHeartbeatHandler = None
|
@@ -39,11 +39,11 @@ class ClusterClient(Client):
|
|
39
39
|
self.__listener = listener
|
40
40
|
return self
|
41
41
|
|
42
|
-
def open(self) ->
|
43
|
-
return self._open_do(False)
|
42
|
+
async def open(self) -> ClientSession:
|
43
|
+
return await self._open_do(False)
|
44
44
|
|
45
|
-
def open_or_throw(self) ->
|
46
|
-
return self._open_do(True)
|
45
|
+
async def open_or_throw(self) -> ClientSession:
|
46
|
+
return await self._open_do(True)
|
47
47
|
|
48
48
|
async def _open_do(self, is_throw):
|
49
49
|
sessions: List[Session] = []
|
@@ -69,7 +69,8 @@ class ClusterClient(Client):
|
|
69
69
|
else:
|
70
70
|
client.get_config().exchange_executor(exchangeExecutor)
|
71
71
|
|
72
|
-
|
72
|
+
sesssion = await (client.open_or_throw() if is_throw else client.open())
|
73
|
+
sessions.append(sesssion)
|
73
74
|
return ClusterClientSession(sessions)
|
74
75
|
|
75
76
|
|
@@ -1,3 +1,6 @@
|
|
1
|
+
from socketd.transport.core.Message import Message
|
2
|
+
|
3
|
+
|
1
4
|
class SocketDException(RuntimeError):
|
2
5
|
|
3
6
|
def __init__(self, message):
|
@@ -10,7 +13,11 @@ class SocketDException(RuntimeError):
|
|
10
13
|
|
11
14
|
class SocketDAlarmException(SocketDException):
|
12
15
|
""" 告警"""
|
13
|
-
|
16
|
+
def __init__(self, alarm:Message):
|
17
|
+
super().__init__(alarm.data_as_string())
|
18
|
+
self.__alarm = alarm
|
19
|
+
def get_alarm(self):
|
20
|
+
return self.__alarm
|
14
21
|
|
15
22
|
|
16
23
|
class SocketDChannelException(SocketDException):
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import asyncio
|
2
|
+
import traceback
|
2
3
|
from asyncio import Future
|
3
4
|
|
4
5
|
from socketd.exception.SocketDExecption import SocketDException, SocketDChannelException
|
@@ -40,7 +41,8 @@ class ClientChannel(ChannelBase):
|
|
40
41
|
if not self.__heartbeatScheduledFuture.done():
|
41
42
|
self.__heartbeatScheduledFuture.cancel()
|
42
43
|
except Exception as e:
|
43
|
-
|
44
|
+
e_msg = traceback.format_exc()
|
45
|
+
log.warning(e_msg)
|
44
46
|
|
45
47
|
async def __heartbeatScheduled(self) -> None:
|
46
48
|
while True:
|
@@ -32,16 +32,15 @@ class CodecDefault(Codec):
|
|
32
32
|
# sid
|
33
33
|
sidB: bytes = frame.message().sid().encode(self.config.get_charset())
|
34
34
|
# event
|
35
|
-
|
35
|
+
eventB: bytes = frame.message().event().encode(self.config.get_charset())
|
36
36
|
# metaString
|
37
37
|
metaStringB: bytes = frame.message().entity().meta_string().encode(self.config.get_charset())
|
38
38
|
|
39
|
-
# length (flag + sid + event + metaString + data +
|
40
|
-
len1 = len(sidB) + len(
|
41
|
-
metaStringB) + frame.message().entity().data_size() + 1 * 3 + 2 * 4
|
39
|
+
# length (len[int] + flag[int] + sid + event + metaString + data + \n*3)
|
40
|
+
len1 = 4 + 4 + len(sidB) + len(eventB) + len(metaStringB) + frame.message().data_size() + 2 * 3
|
42
41
|
|
43
42
|
Asserts.assert_size("sid", len(sidB), Constants.MAX_SIZE_SID)
|
44
|
-
Asserts.assert_size("event", len(
|
43
|
+
Asserts.assert_size("event", len(eventB), Constants.MAX_SIZE_EVENT)
|
45
44
|
Asserts.assert_size("metaString", len(metaStringB), Constants.MAX_SIZE_META_STRING)
|
46
45
|
Asserts.assert_size("data", frame.message().entity().data_size(), Constants.MAX_SIZE_DATA)
|
47
46
|
|
@@ -58,7 +57,7 @@ class CodecDefault(Codec):
|
|
58
57
|
target.put_char(10) #'\n'
|
59
58
|
|
60
59
|
# event
|
61
|
-
target.put_bytes(
|
60
|
+
target.put_bytes(eventB)
|
62
61
|
target.put_char(10)
|
63
62
|
|
64
63
|
# metaString
|
@@ -6,6 +6,7 @@ from typing import Any, Optional, BinaryIO
|
|
6
6
|
from socketd.transport.core.Entity import Entity
|
7
7
|
from socketd.transport.core.Costants import Constants
|
8
8
|
from socketd.transport.core.EntityMetas import EntityMetas
|
9
|
+
from socketd.utils.MapUtils import MapUtils
|
9
10
|
|
10
11
|
|
11
12
|
class EntityDefault(Entity):
|
@@ -66,13 +67,13 @@ class EntityDefault(Entity):
|
|
66
67
|
if val:
|
67
68
|
self.meta_map()[name] = val
|
68
69
|
else:
|
69
|
-
self.meta_map()
|
70
|
+
MapUtils.remove(self.meta_map(), name)
|
70
71
|
|
71
72
|
self._meta_stringChanged = True
|
72
73
|
return self
|
73
74
|
|
74
75
|
def meta_del(self, name:str):
|
75
|
-
self.meta_map()
|
76
|
+
MapUtils.remove(self.meta_map(), name)
|
76
77
|
self._meta_stringChanged = True
|
77
78
|
return self
|
78
79
|
|
{socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/fragment/FragmentAggregatorDefault.py
RENAMED
@@ -6,6 +6,7 @@ from socketd.transport.core.Message import MessageInternal
|
|
6
6
|
from socketd.transport.core.EntityMetas import EntityMetas
|
7
7
|
from socketd.transport.core.FragmentAggregator import FragmentAggregator
|
8
8
|
from socketd.exception.SocketDExecption import SocketDException
|
9
|
+
from socketd.utils.MapUtils import MapUtils
|
9
10
|
|
10
11
|
from .FragmentHolder import FragmentHolder
|
11
12
|
from ..entity.MessageBuilder import MessageBuilder
|
@@ -49,7 +50,7 @@ class FragmentAggregatorDefault(FragmentAggregator):
|
|
49
50
|
dataBuffer.write(fragment.message.data().getvalue())
|
50
51
|
|
51
52
|
entity = EntityDefault().meta_map_put(self.__main.meta_map()).data_set(dataBuffer)
|
52
|
-
entity.meta_map()
|
53
|
+
MapUtils.remove(entity.meta_map(), EntityMetas.META_DATA_FRAGMENT_IDX)
|
53
54
|
|
54
55
|
return Frame(self.__main.flag(),
|
55
56
|
MessageBuilder()
|
@@ -10,6 +10,7 @@ from socketd.transport.core.Frames import Frames
|
|
10
10
|
from socketd.transport.core.Config import Config
|
11
11
|
from socketd.transport.core.HandshakeDefault import HandshakeInternal
|
12
12
|
from socketd.transport.core.Message import Message
|
13
|
+
from socketd.utils.MapUtils import MapUtils
|
13
14
|
|
14
15
|
|
15
16
|
class ChannelBase(Channel, ABC):
|
@@ -17,7 +18,7 @@ class ChannelBase(Channel, ABC):
|
|
17
18
|
self.config = config
|
18
19
|
|
19
20
|
self.handshake: HandshakeInternal = None
|
20
|
-
self.__attachments = {}
|
21
|
+
self.__attachments:dict = {}
|
21
22
|
|
22
23
|
self.__lock: threading.Lock = threading.Lock()
|
23
24
|
self.__loop: Optional[asyncio.AbstractEventLoop] = None
|
@@ -45,7 +46,7 @@ class ChannelBase(Channel, ABC):
|
|
45
46
|
|
46
47
|
def put_attachment(self, name, val):
|
47
48
|
if val is None:
|
48
|
-
self.__attachments
|
49
|
+
MapUtils.remove(self.__attachments, name)
|
49
50
|
else:
|
50
51
|
self.__attachments[name] = val
|
51
52
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import asyncio
|
2
2
|
import time
|
3
|
+
import traceback
|
3
4
|
from typing import TypeVar, Optional
|
4
5
|
|
5
6
|
from socketd.transport.core import Entity
|
@@ -170,8 +171,8 @@ class ChannelDefault(ChannelBase, ChannelInternal):
|
|
170
171
|
await RunUtils.waitTry(self._assistant.close(self._source))
|
171
172
|
log.debug(f"{self.get_config().get_role_name()} channel closed, sessionId={self.get_session().session_id()}")
|
172
173
|
except Exception as e:
|
173
|
-
|
174
|
-
|
174
|
+
e_msg = traceback.format_exc()
|
175
|
+
log.warning(f"{self.get_config().get_role_name()} channel close error, sessionId={self.get_session().session_id()} \n{e_msg}")
|
175
176
|
|
176
177
|
if code > Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING:
|
177
178
|
self.on_close_do()
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import traceback
|
1
2
|
from abc import ABC
|
2
3
|
from typing import Optional
|
3
4
|
|
@@ -63,8 +64,7 @@ class ProcessorDefault(Processor, ABC):
|
|
63
64
|
if frame.flag() == Flags.Close:
|
64
65
|
raise SocketDConnectionException("Connection request was rejected")
|
65
66
|
|
66
|
-
log.warning("{} channel handshake is None, sessionId={
|
67
|
-
channel.get_session().session_id())
|
67
|
+
log.warning(f"{channel.get_config().get_role_name()} channel handshake is None, sessionId={channel.get_session().session_id()}")
|
68
68
|
return
|
69
69
|
|
70
70
|
# 更新最后活动时间
|
@@ -147,10 +147,11 @@ class ProcessorDefault(Processor, ABC):
|
|
147
147
|
|
148
148
|
async def on_open_do(self, channel: ChannelInternal):
|
149
149
|
try:
|
150
|
-
await self.listener.on_open(channel.get_session())
|
150
|
+
await RunUtils.waitTry(self.listener.on_open(channel.get_session()))
|
151
151
|
channel.do_open_future(True, None)
|
152
152
|
except Exception as e:
|
153
|
-
|
153
|
+
e_msg = traceback.format_exc()
|
154
|
+
log.warning(f"{channel.get_config().get_role_name()} channel listener onOpen error \n{e_msg}")
|
154
155
|
channel.do_open_future(False, e)
|
155
156
|
|
156
157
|
def on_message(self, channel: ChannelInternal, message: Message):
|
@@ -160,7 +161,8 @@ class ProcessorDefault(Processor, ABC):
|
|
160
161
|
try:
|
161
162
|
await self.listener.on_message(channel.get_session(), message)
|
162
163
|
except Exception as e:
|
163
|
-
|
164
|
+
e_msg = traceback.format_exc()
|
165
|
+
log.warning(f"{channel.get_config().get_role_name()} channel listener onMessage error \n{e_msg}")
|
164
166
|
self.on_error(channel, e)
|
165
167
|
|
166
168
|
def on_close(self, channel: ChannelInternal):
|
@@ -177,7 +179,8 @@ class ProcessorDefault(Processor, ABC):
|
|
177
179
|
try:
|
178
180
|
await RunUtils.waitTry(self.listener.on_error(channel.get_session(), error))
|
179
181
|
except Exception as e:
|
180
|
-
|
182
|
+
e_msg = traceback.format_exc()
|
183
|
+
log.warning(f"{channel.get_config().get_role_name()} channel listener onError error \n{e_msg}")
|
181
184
|
|
182
185
|
def do_close_notice(self, channel: ChannelInternal):
|
183
186
|
RunUtils.taskTry(self.do_close_notice_internal(channel))
|
@@ -2,6 +2,7 @@ from abc import ABC
|
|
2
2
|
from typing import Any, Dict
|
3
3
|
from socketd.transport.core.Session import Session
|
4
4
|
from socketd.transport.core.Channel import Channel
|
5
|
+
from socketd.utils.MapUtils import MapUtils
|
5
6
|
|
6
7
|
|
7
8
|
class SessionBase(Session, ABC):
|
@@ -22,6 +23,10 @@ class SessionBase(Session, ABC):
|
|
22
23
|
else:
|
23
24
|
return self._attrMap.__contains__(name)
|
24
25
|
|
26
|
+
def attr_del(self, name: str):
|
27
|
+
if self._attrMap is not None:
|
28
|
+
MapUtils.remove(self._attrMap, name)
|
29
|
+
|
25
30
|
def attr(self, name: str) -> Any:
|
26
31
|
if self._attrMap is None:
|
27
32
|
return None
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import traceback
|
1
2
|
from typing import Optional
|
2
3
|
|
3
4
|
from socketd.transport.core.entity.MessageBuilder import MessageBuilder
|
@@ -14,11 +15,10 @@ from socketd.transport.stream.SendStream import SendStream
|
|
14
15
|
|
15
16
|
from socketd.transport.stream.SubscribeStream import SubscribeStream
|
16
17
|
|
17
|
-
from loguru import logger
|
18
|
-
|
19
18
|
from socketd.transport.stream.impl.RequestStreamImpl import RequestStreamImpl
|
20
19
|
from socketd.transport.stream.impl.SendStreamImpl import SendStreamImpl
|
21
20
|
from socketd.transport.stream.impl.SubscribeStreamImpl import SubscribeStreamImpl
|
21
|
+
from socketd.utils.LogConfig import log
|
22
22
|
from socketd.utils.RunUtils import RunUtils
|
23
23
|
|
24
24
|
|
@@ -54,7 +54,10 @@ class SessionDefault(SessionBase):
|
|
54
54
|
return stream
|
55
55
|
|
56
56
|
def send_and_request(self, event: str, content: Entity,
|
57
|
-
timeout: int = 100) -> RequestStream:
|
57
|
+
timeout: int|None = 100) -> RequestStream:
|
58
|
+
|
59
|
+
if timeout is None:
|
60
|
+
timeout = 100
|
58
61
|
|
59
62
|
if timeout < 100:
|
60
63
|
timeout = self._channel.get_config().get_request_timeout() / 1000
|
@@ -80,7 +83,7 @@ class SessionDefault(SessionBase):
|
|
80
83
|
await self._channel.send(Frame(Flags.ReplyEnd, message), None)
|
81
84
|
|
82
85
|
async def preclose(self):
|
83
|
-
|
86
|
+
log.debug(
|
84
87
|
f"{self._channel.get_config().get_role_name()} session close starting, sessionId={self.session_id()}")
|
85
88
|
if self._channel.is_valid():
|
86
89
|
await self._channel.send_close(Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING)
|
@@ -90,7 +93,8 @@ class SessionDefault(SessionBase):
|
|
90
93
|
try:
|
91
94
|
await self._channel.send_close(Constants.CLOSE1001_PROTOCOL_CLOSE)
|
92
95
|
except Exception as e:
|
93
|
-
|
96
|
+
e_msg = traceback.format_exc()
|
97
|
+
log.warning(f" {self._channel.get_config().get_role_name()} channel send_close error \n{e_msg}")
|
94
98
|
await self._channel.close(Constants.CLOSE2009_USER)
|
95
99
|
|
96
100
|
def param(self, name: str):
|
@@ -2,19 +2,20 @@ from typing import Dict
|
|
2
2
|
|
3
3
|
from socketd.transport.core import Listener
|
4
4
|
from socketd.transport.core.listener.RouteSelector import RouteSelector
|
5
|
+
from socketd.utils.MapUtils import MapUtils
|
5
6
|
|
6
7
|
|
7
8
|
class RouteSelectorDefault(RouteSelector):
|
8
9
|
def __init__(self):
|
9
|
-
|
10
|
+
self._map:Dict[str, Listener] = {}
|
10
11
|
def select(self, route: str) -> Listener:
|
11
|
-
return self.
|
12
|
+
return self._map.get(route)
|
12
13
|
|
13
14
|
def put(self, route: str, target: Listener):
|
14
|
-
self.
|
15
|
+
self._map.put(route, target)
|
15
16
|
|
16
17
|
def remove(self, route: str):
|
17
|
-
self.
|
18
|
+
MapUtils.remove(self._map, route)
|
18
19
|
|
19
20
|
def size(self) -> int:
|
20
|
-
return self.
|
21
|
+
return self._map.__len__()
|
@@ -10,7 +10,7 @@ class RequestStream(Stream):
|
|
10
10
|
...
|
11
11
|
|
12
12
|
@abstractmethod
|
13
|
-
def then_error(self, onError: Callable[[Exception], None]) -> '
|
13
|
+
def then_error(self, onError: Callable[[Exception], None]) -> 'RequestStream':
|
14
14
|
"""
|
15
15
|
异常发生
|
16
16
|
:param onError: 当异常发生时执行的函数,接受一个异常参数
|
@@ -18,7 +18,7 @@ class RequestStream(Stream):
|
|
18
18
|
...
|
19
19
|
|
20
20
|
@abstractmethod
|
21
|
-
def then_progress(self, onProgress: Callable[[bool, int, int], None]) -> '
|
21
|
+
def then_progress(self, onProgress: Callable[[bool, int, int], None]) -> 'RequestStream':
|
22
22
|
"""
|
23
23
|
进度发生时
|
24
24
|
:param onProgress (isSend, val, max)
|
@@ -26,7 +26,7 @@ class RequestStream(Stream):
|
|
26
26
|
...
|
27
27
|
|
28
28
|
@abstractmethod
|
29
|
-
def then_reply(self, onReply: Callable[[Reply], None]) -> '
|
29
|
+
def then_reply(self, onReply: Callable[[Reply], None]) -> 'RequestStream':
|
30
30
|
"""
|
31
31
|
答复发生时
|
32
32
|
"""
|
@@ -2,6 +2,7 @@ import logging
|
|
2
2
|
|
3
3
|
from socketd.transport.stream.Stream import StreamInternal
|
4
4
|
from socketd.transport.stream.StreamManger import StreamManger
|
5
|
+
from socketd.utils.MapUtils import MapUtils
|
5
6
|
|
6
7
|
logger = logging.getLogger(__name__)
|
7
8
|
|
@@ -27,7 +28,7 @@ class StreamMangerDefault(StreamManger):
|
|
27
28
|
stream.insurance_start(self, stream_timeout)
|
28
29
|
|
29
30
|
def remove_stream(self, sid):
|
30
|
-
stream: StreamInternal = self.stream_map
|
31
|
+
stream: StreamInternal = MapUtils.remove(self.stream_map, sid)
|
31
32
|
if stream:
|
32
33
|
stream.insurance_cancel()
|
33
34
|
logger.debug(f"{self.config.get_role_name()} stream removed, sid={sid}")
|
@@ -17,7 +17,6 @@ class StreamBase(StreamInternal, ABC):
|
|
17
17
|
self.__timeout = timeout
|
18
18
|
self.__demands = demands
|
19
19
|
|
20
|
-
self.__onError: Callable[[Exception], None] = None
|
21
20
|
self.__doOnError: Callable[[Exception], None] = None
|
22
21
|
self.__doOnProgress: Callable[[bool, int, int], None] = None
|
23
22
|
|
@@ -30,7 +29,7 @@ class StreamBase(StreamInternal, ABC):
|
|
30
29
|
return True
|
31
30
|
|
32
31
|
def then_error_do(self, onError: Callable[[Exception], None]):
|
33
|
-
self.
|
32
|
+
self.__doOnError = onError
|
34
33
|
|
35
34
|
def then_progress_do(self, onProgress: Callable[[bool, int, int], None]):
|
36
35
|
self.__doOnProgress = onProgress
|
@@ -63,7 +62,7 @@ class StreamBase(StreamInternal, ABC):
|
|
63
62
|
...
|
64
63
|
|
65
64
|
def on_error(self, error: Exception):
|
66
|
-
if error:
|
65
|
+
if error and self.__doOnError:
|
67
66
|
self.__doOnError(error)
|
68
67
|
|
69
68
|
def on_progress(self, is_send, val, max_val):
|
@@ -3,7 +3,7 @@ import functools
|
|
3
3
|
from threading import Lock
|
4
4
|
from typing import Generic, TypeVar, Callable
|
5
5
|
|
6
|
-
from
|
6
|
+
from socketd.utils.LogConfig import log
|
7
7
|
|
8
8
|
T = TypeVar('T')
|
9
9
|
|
@@ -14,7 +14,7 @@ class CompletableFuture(Generic[T]):
|
|
14
14
|
if loop is None:
|
15
15
|
loop = asyncio.get_running_loop()
|
16
16
|
if _future and not asyncio.iscoroutine(_future):
|
17
|
-
|
17
|
+
log.warning("{name} invalid coroutine object", name=_future.__name__)
|
18
18
|
return
|
19
19
|
self._future: asyncio.Task = loop.create_task(_future) if _future else loop.create_future()
|
20
20
|
self._lock = Lock()
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import asyncio
|
2
|
+
import traceback
|
2
3
|
from asyncio import CancelledError
|
3
4
|
from typing import Optional, Sequence, List
|
4
|
-
from loguru import logger
|
5
5
|
from websockets.extensions import ClientExtensionFactory
|
6
6
|
from websockets.uri import WebSocketURI
|
7
7
|
|
@@ -58,7 +58,8 @@ class AIOWebSocketClientImpl(WebSocketClientProtocol):
|
|
58
58
|
try:
|
59
59
|
await self.on_message()
|
60
60
|
except Exception as e:
|
61
|
-
|
61
|
+
e_msg = traceback.format_exc()
|
62
|
+
log.warning(e_msg)
|
62
63
|
break
|
63
64
|
|
64
65
|
def connection_open(self) -> None:
|
@@ -69,7 +70,6 @@ class AIOWebSocketClientImpl(WebSocketClientProtocol):
|
|
69
70
|
super().connection_open()
|
70
71
|
self._handler_future = self.loop.create_task(self._handler())
|
71
72
|
|
72
|
-
@logger.catch
|
73
73
|
async def on_open(self):
|
74
74
|
"""开始建立连接"""
|
75
75
|
try:
|
@@ -118,10 +118,11 @@ class AIOWebSocketClientImpl(WebSocketClientProtocol):
|
|
118
118
|
log.debug(c)
|
119
119
|
raise c
|
120
120
|
except SocketDConnectionException as s:
|
121
|
+
s_msg = traceback.format_exc()
|
121
122
|
self.handshake_future.accept(ClientHandshakeResult(self.channel, s))
|
122
|
-
|
123
|
+
log.warning(s_msg)
|
123
124
|
except ConnectionClosedOK as e:
|
124
|
-
|
125
|
+
log.info(e)
|
125
126
|
except Exception as e:
|
126
127
|
self.on_error(e)
|
127
128
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
import asyncio
|
3
|
+
import traceback
|
3
4
|
from typing import Optional, Union
|
4
5
|
|
5
6
|
from websockets import ConnectionClosedOK
|
@@ -58,7 +59,8 @@ class AIOWebSocketServerImpl(WebSocketServerProtocol):
|
|
58
59
|
# 有可能未 onOpen,就 onError 了;此时通道未成
|
59
60
|
self.ws_aio_server.get_processor().on_error(channel, ex)
|
60
61
|
except Exception as e:
|
61
|
-
|
62
|
+
e_msg = traceback.format_exc()
|
63
|
+
log.warning(e_msg)
|
62
64
|
|
63
65
|
async def on_message(self, conn: Union[AIOWebSocketServerImpl, WebSocketServerProtocol], path: str):
|
64
66
|
"""ws_handler"""
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{socket.d-2.4.12 → socket.d-2.4.13}/socketd/transport/core/fragment/FragmentHandlerDefault.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|