vortexpy 4.0.3__tar.gz → 4.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. {vortexpy-4.0.3 → vortexpy-4.0.6}/PKG-INFO +1 -1
  2. {vortexpy-4.0.3 → vortexpy-4.0.6}/pyproject.toml +1 -1
  3. {vortexpy-4.0.3/vortex/test → vortexpy-4.0.6/vortex}/PayloadTest.py +5 -5
  4. {vortexpy-4.0.3/vortex/test → vortexpy-4.0.6/vortex}/TupleDataForTest.py +1 -1
  5. {vortexpy-4.0.3/vortex/test → vortexpy-4.0.6/vortex}/TupleRestfulTest.py +1 -2
  6. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/TupleSelector.py +46 -3
  7. {vortexpy-4.0.3/vortex/test → vortexpy-4.0.6/vortex}/TupleTest.py +2 -2
  8. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexFactory.py +89 -30
  9. {vortexpy-4.0.3/vortex/test → vortexpy-4.0.6/vortex}/VortexTcpMemoryLeakRawTest.py +3 -3
  10. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/__init__.py +1 -1
  11. vortexpy-4.0.6/vortex/data_loader/TupleDataLiveLockManager.py +259 -0
  12. vortexpy-4.0.6/vortex/data_loader/TupleDataLoader.py +321 -0
  13. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/data_loader/TupleDataLoaderDelegate.py +22 -5
  14. vortexpy-4.0.6/vortex/data_loader/TupleDataLoaderTuples.py +51 -0
  15. {vortexpy-4.0.3/vortex/test/vortexjs → vortexpy-4.0.6/vortex/handler}/TupleActionProcessorTestHandler.py +1 -2
  16. vortexpy-4.0.6/vortex/handler/TupleChangeEventBus.py +156 -0
  17. vortexpy-4.0.6/vortex/handler/TupleChangeEventBusObserverABC.py +12 -0
  18. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/handler/TupleDataObservableHandler.py +8 -1
  19. {vortexpy-4.0.3/vortex/test/vortexjs → vortexpy-4.0.6/vortex/handler}/TupleDataObservableTestHandler.py +2 -2
  20. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortexpy.egg-info/PKG-INFO +1 -1
  21. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortexpy.egg-info/SOURCES.txt +22 -21
  22. vortexpy-4.0.3/vortex/data_loader/TupleDataLoader.py +0 -306
  23. vortexpy-4.0.3/vortex/storage/__init__.py +0 -0
  24. vortexpy-4.0.3/vortex/test/__init__.py +0 -0
  25. vortexpy-4.0.3/vortex/test/vortexjs/__init__.py +0 -13
  26. {vortexpy-4.0.3 → vortexpy-4.0.6}/LICENSE +0 -0
  27. {vortexpy-4.0.3 → vortexpy-4.0.6}/README.md +0 -0
  28. {vortexpy-4.0.3 → vortexpy-4.0.6}/setup.cfg +0 -0
  29. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/DataWrapTuple.py +0 -0
  30. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/DeferUtil.py +0 -0
  31. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/Jsonable.py +0 -0
  32. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/Payload.py +0 -0
  33. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/PayloadEndpoint.py +0 -0
  34. {vortexpy-4.0.3/vortex/test → vortexpy-4.0.6/vortex}/PayloadEndpointTest.py +0 -0
  35. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/PayloadEnvelope.py +0 -0
  36. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/PayloadFilterKeys.py +0 -0
  37. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/PayloadIO.py +0 -0
  38. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/PayloadPriority.py +0 -0
  39. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/PayloadResponse.py +0 -0
  40. {vortexpy-4.0.3/vortex/test → vortexpy-4.0.6/vortex}/PayloadResponseTest.py +0 -0
  41. {vortexpy-4.0.3/vortex/test → vortexpy-4.0.6/vortex}/PerformTestActionTuple.py +0 -0
  42. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/SerialiseUtil.py +0 -0
  43. {vortexpy-4.0.3/vortex/test → vortexpy-4.0.6/vortex}/TestTuple.py +0 -0
  44. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/Tuple.py +0 -0
  45. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/TupleAction.py +0 -0
  46. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/TupleActionVortex.py +0 -0
  47. {vortexpy-4.0.3/vortex/test → vortexpy-4.0.6/vortex}/TuplePerfTest.py +2 -2
  48. /vortexpy-4.0.3/vortex/test/PolymorphicTupleTypeFieldArgTest.py → /vortexpy-4.0.6/vortex/TuplePolymorphicTupleTypeFieldArgTest.py +0 -0
  49. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexABC.py +0 -0
  50. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexClientHttp.py +0 -0
  51. {vortexpy-4.0.3/vortex/test → vortexpy-4.0.6/vortex}/VortexClientHttpTest.py +0 -0
  52. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexClientTcp.py +0 -0
  53. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexClientWebsocketFactory.py +0 -0
  54. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexConnectionABC.py +0 -0
  55. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexPayloadProtocol.py +0 -0
  56. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexServer.py +0 -0
  57. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexServerConnection.py +0 -0
  58. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexServerHttpResource.py +0 -0
  59. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexServerTcp.py +0 -0
  60. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexServerWebsocket.py +0 -0
  61. {vortexpy-4.0.3/vortex/test → vortexpy-4.0.6/vortex}/VortexTcpMemoryLeakPayloadTest.py +0 -0
  62. {vortexpy-4.0.3/vortex/test → vortexpy-4.0.6/vortex}/VortexTest.py +0 -0
  63. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexUtil.py +0 -0
  64. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/VortexWritePushProducer.py +0 -0
  65. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/data_loader/TupleDataLoaderTupleABC.py +0 -0
  66. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/data_loader/__init__.py +0 -0
  67. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/handler/TupleActionProcessor.py +0 -0
  68. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/handler/TupleActionProcessorProxy.py +0 -0
  69. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/handler/TupleDataActionClient.py +0 -0
  70. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/handler/TupleDataObservableCache.py +0 -0
  71. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/handler/TupleDataObservableProxyHandler.py +0 -0
  72. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/handler/TupleDataObserverClient.py +0 -0
  73. {vortexpy-4.0.3/vortex/test/vortexjs → vortexpy-4.0.6/vortex/handler}/VortexJSTupleLoaderTestHandler.py +0 -0
  74. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/handler/__init__.py +0 -0
  75. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/restful/GzippedDataHttpClient.py +0 -0
  76. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/restful/GzippedDataHttpClientTest.py +0 -0
  77. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/restful/GzippedPayloadHttpClient.py +0 -0
  78. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/restful/RestfulHttpClient.py +0 -0
  79. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/restful/RestfulHttpClientTest.py +0 -0
  80. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/restful/RestfulResource.py +0 -0
  81. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/restful/RestfulResourceTest.py +0 -0
  82. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/restful/__init__.py +0 -0
  83. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/rpc/RPC.py +0 -0
  84. {vortexpy-4.0.3/vortex/rpc/test → vortexpy-4.0.6/vortex/rpc}/RPCTest.py +0 -0
  85. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/rpc/__init__.py +0 -0
  86. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/sqla_orm/OrmCrudHandler.py +0 -0
  87. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/sqla_orm/TupleProviderForDb.py +0 -0
  88. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/sqla_orm/VortexTupleJson.py +0 -0
  89. {vortexpy-4.0.3/vortex/rpc/test → vortexpy-4.0.6/vortex/sqla_orm}/__init__.py +0 -0
  90. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortex/storage/TupleStorageSqlite.py +0 -0
  91. {vortexpy-4.0.3/vortex/sqla_orm → vortexpy-4.0.6/vortex/storage}/__init__.py +0 -0
  92. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortexpy.egg-info/dependency_links.txt +0 -0
  93. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortexpy.egg-info/requires.txt +0 -0
  94. {vortexpy-4.0.3 → vortexpy-4.0.6}/vortexpy.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vortexpy
3
- Version: 4.0.3
3
+ Version: 4.0.6
4
4
  Summary: Synertys observable, routable, data serialisation and transport code.
5
5
  Author-email: Synerty <contact@synerty.com>
6
6
  Project-URL: Homepage, https://github.com/Synerty/vortexpy
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "vortexpy"
7
- version = "4.0.3"
7
+ version = "4.0.6"
8
8
  authors = [{name = "Synerty", email = "contact@synerty.com"}]
9
9
  description = "Synertys observable, routable, data serialisation and transport code."
10
10
  keywords = [
@@ -13,7 +13,7 @@ from twisted.trial import unittest
13
13
  from vortex.Payload import Payload
14
14
  from vortex.PayloadFilterKeys import rapuiClientEcho
15
15
  from vortex.Tuple import TupleHash
16
- from vortex.test.VortexTcpMemoryLeakPayloadTest import MemoryCheckerTestMixin
16
+ from vortex.VortexTcpMemoryLeakPayloadTest import MemoryCheckerTestMixin
17
17
 
18
18
 
19
19
  def makeTestPayloadA(tupleDataSize=10 * 1024):
@@ -49,21 +49,21 @@ class PayloadPyTest(unittest.TestCase, MemoryCheckerTestMixin):
49
49
  self.assertEqual(payload.tuples[0], origPayload.tuples[0])
50
50
 
51
51
  def testMakeStr_100m_x100(self):
52
- self._memCheckFunction(self._makeStr, 1000, 100 * 1024 ** 2)
52
+ self._memCheckFunction(self._makeStr, 1000, 100 * 1024**2)
53
53
 
54
54
  def testPayloadToFromEncodedPayload_10k_x1000(self):
55
55
  self._memCheckFunction(self._payloadEncodeDecode, 1000, 10 * 1024)
56
56
 
57
57
  def testPayloadToFromEncodedPayload_100m_x100(self):
58
- self._memCheckFunction(self._payloadEncodeDecode, 100, 10 * 1024 ** 2)
58
+ self._memCheckFunction(self._payloadEncodeDecode, 100, 10 * 1024**2)
59
59
 
60
60
  def testPayloadToFromEncodedPayload_1m_x1000(self):
61
- self._memCheckFunction(self._payloadEncodeDecode, 1000, 1 * 1024 ** 2)
61
+ self._memCheckFunction(self._payloadEncodeDecode, 1000, 1 * 1024**2)
62
62
 
63
63
  def testPayloadToFromEncodedPayload10mb(self):
64
64
  # Create Payload
65
65
  origPayload = makeTestPayloadA()
66
- origPayload.tuples = ["1234567890" * 1024 ** 2]
66
+ origPayload.tuples = ["1234567890" * 1024**2]
67
67
 
68
68
  encodedPayload = origPayload.toEncodedPayload()
69
69
  payload = Payload().fromEncodedPayload(encodedPayload)
@@ -6,7 +6,7 @@
6
6
  * Website : http://www.synerty.com
7
7
  * Support : support@synerty.com
8
8
  """
9
- from vortex.test.TestTuple import TestTuple
9
+ from vortex.TestTuple import TestTuple
10
10
 
11
11
 
12
12
  def makeTestTupleData(count=5):
@@ -7,7 +7,6 @@
7
7
  * Support : support@synerty.com
8
8
  """
9
9
 
10
- import datetime
11
10
  import json
12
11
  from typing import Dict, Annotated
13
12
  from typing import List
@@ -16,9 +15,9 @@ from typing import Union
16
15
  from ddt import data, ddt
17
16
  from twisted.trial import unittest
18
17
 
19
- from vortex.Tuple import TUPLE_TYPES_BY_NAME, TupleHash, IntTupleFieldValidator
20
18
  from vortex.Tuple import Tuple
21
19
  from vortex.Tuple import TupleField
20
+ from vortex.Tuple import TupleHash, IntTupleFieldValidator
22
21
  from vortex.Tuple import addTupleType
23
22
 
24
23
 
@@ -7,11 +7,15 @@
7
7
  * Support : support@synerty.com
8
8
  """
9
9
  import json
10
- from typing import Dict, Optional
10
+ from typing import Dict, Optional, Union, Type
11
11
 
12
12
  from vortex.Tuple import Tuple, addTupleType
13
13
 
14
14
 
15
+ class InvalidTupleSelectorNameException(Exception):
16
+ pass
17
+
18
+
15
19
  @addTupleType
16
20
  class TupleSelector(Tuple):
17
21
  __tupleType__ = "vortex.TupleSelector"
@@ -21,10 +25,12 @@ class TupleSelector(Tuple):
21
25
  # selector: Dict[str, Any] = TupleField(comment="The values to select")
22
26
 
23
27
  def __init__(
24
- self, name: Optional[str] = None, selector: Optional[Dict] = None
28
+ self,
29
+ name: Optional[Union[str, Type[Tuple], Tuple]] = None,
30
+ selector: Optional[Dict] = None,
25
31
  ) -> None:
26
32
  Tuple.__init__(self)
27
- self.name = name
33
+ self.name = self.nameFromTuple(name)
28
34
  self.selector = selector if selector else {}
29
35
 
30
36
  def __eq__(self, y):
@@ -33,6 +39,43 @@ class TupleSelector(Tuple):
33
39
  def __hash__(self):
34
40
  return hash(self.toJsonStr())
35
41
 
42
+ # noinspection PyMethodMayBeStatic
43
+ @classmethod
44
+ def nameFromTuple(
45
+ cls, nameOrTuple: Optional[Union[str, Type[Tuple], Tuple]]
46
+ ) -> Optional[str]:
47
+ # When the TupleSelector is reconstructed / deserialised, it's constructed with
48
+ # no arguments
49
+ if nameOrTuple is None:
50
+ return None
51
+
52
+ if isinstance(nameOrTuple, str):
53
+ name = nameOrTuple
54
+
55
+ elif issubclass(nameOrTuple, Tuple):
56
+ name = nameOrTuple.tupleType()
57
+
58
+ elif isinstance(nameOrTuple, Tuple):
59
+ name = nameOrTuple.tupleType()
60
+
61
+ else:
62
+ raise Exception(
63
+ "Argument should be of type Union[str, Type[Tuple], Tuple]"
64
+ )
65
+
66
+ if name == TupleSelector.tupleName():
67
+ raise InvalidTupleSelectorNameException(
68
+ "We've found the name of TupleSelector.tupleType(),"
69
+ "which means we've been passed a TupleSelector."
70
+ )
71
+
72
+ return name
73
+
74
+ def isForTuple(
75
+ self, nameOrTuple: Optional[Union[str, Type[Tuple], Tuple]]
76
+ ) -> bool:
77
+ return self.name == self.nameFromTuple(nameOrTuple)
78
+
36
79
  def toJsonStr(self) -> str:
37
80
  """To Json Str
38
81
 
@@ -12,8 +12,8 @@ import json
12
12
 
13
13
  from twisted.trial import unittest
14
14
 
15
- from vortex.Tuple import TUPLE_TYPES_BY_NAME, TupleHash
16
- from vortex.test.TestTuple import TestSubTuple, TestTuple
15
+ from vortex.TestTuple import TestSubTuple, TestTuple
16
+ from vortex.Tuple import TupleHash
17
17
 
18
18
 
19
19
  def makeTupleA():
@@ -19,13 +19,13 @@ from twisted.internet.defer import inlineCallbacks
19
19
  from twisted.internet.defer import succeed
20
20
  from twisted.internet.task import deferLater
21
21
  from twisted.python.failure import Failure
22
-
23
22
  from txhttputil.util.PemUtil import parsePemBundleForClient
24
23
  from txhttputil.util.PemUtil import parsePemBundleForServer
25
24
  from txhttputil.util.PemUtil import parsePemBundleForTrustedPeers
26
25
  from txhttputil.util.SslUtil import buildCertificateOptionsForTwisted
27
26
  from txhttputil.util.SslUtil import parseTrustRootFromBundle
28
27
  from txwebsocket.txws import WebSocketFactory
28
+
29
29
  from vortex.DeferUtil import yesMainThread
30
30
  from vortex.PayloadEnvelope import PayloadEnvelope
31
31
  from vortex.PayloadEnvelope import VortexMsgList
@@ -64,12 +64,11 @@ _ConnectionDateSuccess = namedtuple(
64
64
 
65
65
 
66
66
  class _VortexConnectionRateLimit:
67
- _ROLLING_WINDOW_SECONDS = 10.0
68
- _NEW_CONNECTIONS_IN_WINDOW = 5
69
-
70
67
  def __init__(self):
71
68
  self._connections: list[_ConnectionDateSuccess] = []
72
69
  self._peerConnectionLimitPerIp = None
70
+ self._newConnectionsPerWindow = 5
71
+ self._rollingNewConnectionWindowSeconds = 10.0
73
72
 
74
73
  def _hasHitPeerConnectionLimit(
75
74
  self, connectionCountForPeer: int, fromIp: str
@@ -103,7 +102,7 @@ class _VortexConnectionRateLimit:
103
102
  self._connections = list(
104
103
  filter(
105
104
  lambda item: (now - item.dateTime).total_seconds()
106
- < self._ROLLING_WINDOW_SECONDS,
105
+ < self._rollingNewConnectionWindowSeconds,
107
106
  self._connections,
108
107
  )
109
108
  )
@@ -112,7 +111,7 @@ class _VortexConnectionRateLimit:
112
111
  list(filter(lambda item: item.success, self._connections))
113
112
  )
114
113
 
115
- if connectedInWindow < self._NEW_CONNECTIONS_IN_WINDOW:
114
+ if connectedInWindow < self._newConnectionsPerWindow:
116
115
  self._connections.append(_ConnectionDateSuccess(now, True, fromIp))
117
116
  return True
118
117
 
@@ -133,17 +132,27 @@ class _VortexConnectionRateLimit:
133
132
 
134
133
  return False
135
134
 
135
+ def setNewConnectionsPerWindow(self, limit):
136
+ self._newConnectionsPerWindow = limit
137
+
136
138
  def setPeerConnectionLimitPerIp(self, limit):
137
139
  self._peerConnectionLimitPerIp = limit
138
140
 
141
+ def setRollingNewConnectionWindowSeconds(self, seconds):
142
+ self._rollingNewConnectionWindowSeconds = seconds
143
+
139
144
 
140
145
  VortexUuidList = List[str]
141
146
 
142
147
 
143
148
  class _VortexFactoryVortexInfo:
144
149
  def __init__(self):
145
- self.__vortexServersByName: Dict[str, List[VortexServer]] = defaultdict(list)
146
- self.__vortexClientsByName: Dict[str, List[VortexABC]] = defaultdict(list)
150
+ self.__vortexServersByName: Dict[str, List[VortexServer]] = defaultdict(
151
+ list
152
+ )
153
+ self.__vortexClientsByName: Dict[str, List[VortexABC]] = defaultdict(
154
+ list
155
+ )
147
156
 
148
157
  self.__vortexServers: tuple[VortexServer] = tuple()
149
158
  self.__vortexClients: tuple[VortexABC] = tuple()
@@ -241,12 +250,16 @@ class _VortexFactoryVortexInfo:
241
250
 
242
251
  self.__remoteVortexUuids = set(self.__remoteVortexNameByUuid)
243
252
 
244
- def getRemoteVortexInfos(self, name=None, uuid=None) -> list[tuple[VortexABC, str]]:
253
+ def getRemoteVortexInfos(
254
+ self, name=None, uuid=None
255
+ ) -> list[tuple[VortexABC, str]]:
245
256
  assert name or uuid, "We expect a name or uuid"
246
257
 
247
258
  # If we're passed a UUID, then there will only be one result
248
259
  if uuid:
249
- vortex, foundName = self.__remoteVortexNameByUuid.get(uuid, (None, None))
260
+ vortex, foundName = self.__remoteVortexNameByUuid.get(
261
+ uuid, (None, None)
262
+ )
250
263
  if not foundName:
251
264
  return []
252
265
  return [(vortex, uuid)]
@@ -254,7 +267,9 @@ class _VortexFactoryVortexInfo:
254
267
  # Name is asserted
255
268
  return [
256
269
  (vortex, foundUuid)
257
- for vortex, foundUuid in self.__remoteVortexUuidsByName.get(name, [])
270
+ for vortex, foundUuid in self.__remoteVortexUuidsByName.get(
271
+ name, []
272
+ )
258
273
  ]
259
274
 
260
275
  def getRemoteVortexIpByUuid(self, vortexUuid: str, vortexName=None) -> str:
@@ -267,7 +282,10 @@ class _VortexFactoryVortexInfo:
267
282
  not conn.closed
268
283
  and not conn.timedOut
269
284
  and conn.remoteVortexUuid == vortexUuid
270
- and (conn.remoteVortexName == vortexName or vortexName is None)
285
+ and (
286
+ conn.remoteVortexName == vortexName
287
+ or vortexName is None
288
+ )
271
289
  ):
272
290
  targetConns.append(conn)
273
291
 
@@ -283,7 +301,9 @@ class _VortexFactoryVortexInfo:
283
301
  return targetConns[-1].ip
284
302
 
285
303
  if not targetConns:
286
- raise NoVortexException(f"Can not find vortex with UUID {vortexUuid}")
304
+ raise NoVortexException(
305
+ f"Can not find vortex with UUID {vortexUuid}"
306
+ )
287
307
 
288
308
  return targetConns[0].ip
289
309
 
@@ -300,7 +320,10 @@ class _VortexFactoryVortexInfo:
300
320
  not conn.closed
301
321
  and not conn.timedOut
302
322
  and conn.ip == ip
303
- and (conn.remoteVortexName == vortexName or vortexName is None)
323
+ and (
324
+ conn.remoteVortexName == vortexName
325
+ or vortexName is None
326
+ )
304
327
  ):
305
328
  targetConns.append(conn)
306
329
 
@@ -348,7 +371,9 @@ class _VortexFactoryVortexInfo:
348
371
  def getLocalVortexClients(self, localVortexName: str) -> List[VortexABC]:
349
372
  return [
350
373
  vortex
351
- for vortex, _ in self.__localVortexUuidsByName.get(localVortexName, [])
374
+ for vortex, _ in self.__localVortexUuidsByName.get(
375
+ localVortexName, []
376
+ )
352
377
  ]
353
378
 
354
379
  def isRemoteVortexOnline(self, uuid):
@@ -401,6 +426,14 @@ class VortexFactory:
401
426
  def setPeerConnectionLimitPerIp(cls, limit: int):
402
427
  cls.__connectionRateLimit.setPeerConnectionLimitPerIp(limit)
403
428
 
429
+ @classmethod
430
+ def setNewConnectionsPerWindow(cls, limit):
431
+ cls.__connectionRateLimit.setNewConnectionsPerWindow(limit)
432
+
433
+ @classmethod
434
+ def setRollingNewConnectionWindowSeconds(cls, seconds):
435
+ cls.__connectionRateLimit.setRollingNewConnectionWindowSeconds(seconds)
436
+
404
437
  @classmethod
405
438
  def createServer(cls, name: str, rootResource) -> None:
406
439
  """Create Server
@@ -474,7 +507,9 @@ class VortexFactory:
474
507
 
475
508
  vortexServer = VortexServer(name, requiresBase64Encoding=False)
476
509
  cls.__vortexInfoState.addVortexServer(name, vortexServer)
477
- vortexWebsocketServerFactory = VortexWebsocketServerFactory(vortexServer)
510
+ vortexWebsocketServerFactory = VortexWebsocketServerFactory(
511
+ vortexServer
512
+ )
478
513
  site = WebSocketFactory(vortexWebsocketServerFactory)
479
514
  if enableSsl:
480
515
  trustedCertificateAuthorities = None
@@ -507,12 +542,18 @@ class VortexFactory:
507
542
  cls.__listeningPorts.append(port)
508
543
 
509
544
  @classmethod
510
- def createHttpWebsocketResource(cls, name: str) -> VortexWebSocketUpgradeResource:
545
+ def createHttpWebsocketResource(
546
+ cls, name: str
547
+ ) -> VortexWebSocketUpgradeResource:
511
548
  vortexServer = VortexServer(name, requiresBase64Encoding=False)
512
549
  cls.__vortexInfoState.addVortexServer(name, vortexServer)
513
550
 
514
- vortexWebsocketServerFactory = VortexWebsocketServerFactory(vortexServer)
515
- websocketFactory = VortexWrappedWebSocketFactory(vortexWebsocketServerFactory)
551
+ vortexWebsocketServerFactory = VortexWebsocketServerFactory(
552
+ vortexServer
553
+ )
554
+ websocketFactory = VortexWrappedWebSocketFactory(
555
+ vortexWebsocketServerFactory
556
+ )
516
557
 
517
558
  return VortexWebSocketUpgradeResource(websocketFactory)
518
559
 
@@ -532,8 +573,12 @@ class VortexFactory:
532
573
 
533
574
  vortexServer = VortexServer(name, requiresBase64Encoding=False)
534
575
  cls.__vortexInfoState.addVortexServer(name, vortexServer)
535
- vortexWebsocketServerFactory = VortexWebsocketServerFactory(vortexServer)
536
- websocketFactory = VortexWrappedWebSocketFactory(vortexWebsocketServerFactory)
576
+ vortexWebsocketServerFactory = VortexWebsocketServerFactory(
577
+ vortexServer
578
+ )
579
+ websocketFactory = VortexWrappedWebSocketFactory(
580
+ vortexWebsocketServerFactory
581
+ )
537
582
 
538
583
  websocketResource = VortexWebSocketUpgradeResource(websocketFactory)
539
584
  rootResource.putChild(b"vortexws", websocketResource)
@@ -622,8 +667,12 @@ class VortexFactory:
622
667
  sslMutualTLSCertificateAuthorityBundleFilePath,
623
668
  sslMutualTLSTrustedPeerCertificateBundleFilePath,
624
669
  )
625
- vortexWebsocketClientFactory = VortexClientWebsocketFactory(name, url=url)
626
- cls.__vortexInfoState.addVortexClient(name, vortexWebsocketClientFactory)
670
+ vortexWebsocketClientFactory = VortexClientWebsocketFactory(
671
+ name, url=url
672
+ )
673
+ cls.__vortexInfoState.addVortexClient(
674
+ name, vortexWebsocketClientFactory
675
+ )
627
676
 
628
677
  if vortexWebsocketClientFactory.isSecure and sslEnableMutualTLS:
629
678
  trustedCertificateAuthorities = parseTrustRootFromBundle(
@@ -654,7 +703,9 @@ class VortexFactory:
654
703
  # raise minimum version to tls 1.2
655
704
  sslContextFactory.method = SSL.TLSv1_2_METHOD
656
705
 
657
- return vortexWebsocketClientFactory.connect(host, port, sslContextFactory)
706
+ return vortexWebsocketClientFactory.connect(
707
+ host, port, sslContextFactory
708
+ )
658
709
 
659
710
  @classmethod
660
711
  def createTcpClient(cls, name: str, host: str, port: int) -> Deferred:
@@ -678,7 +729,9 @@ class VortexFactory:
678
729
 
679
730
  @classmethod
680
731
  def addCustomServerVortex(cls, vortex: VortexABC):
681
- cls.__vortexInfoState.addVortexServer(vortex.localVortexInfo.name, vortex)
732
+ cls.__vortexInfoState.addVortexServer(
733
+ vortex.localVortexInfo.name, vortex
734
+ )
682
735
 
683
736
  @classmethod
684
737
  def canConnect(cls, fromIp: str) -> bool:
@@ -778,13 +831,17 @@ class VortexFactory:
778
831
  if [v for v in vortexAndUuids if v[0].requiresBase64Encoding]:
779
832
  for index, vortexMsg in enumerate(base64VortexMsgs):
780
833
  if vortexMsg.startswith(b"{"):
781
- base64VortexMsgs[index] = yield PayloadEnvelope.base64EncodeDefer(
782
- vortexMsg
783
- )
834
+ base64VortexMsgs[
835
+ index
836
+ ] = yield PayloadEnvelope.base64EncodeDefer(vortexMsg)
784
837
 
785
838
  deferreds = []
786
839
  for vortex, uuid in vortexAndUuids:
787
- msgToUse = base64VortexMsgs if vortex.requiresBase64Encoding else vortexMsgs
840
+ msgToUse = (
841
+ base64VortexMsgs
842
+ if vortex.requiresBase64Encoding
843
+ else vortexMsgs
844
+ )
788
845
  deferreds.append(vortex.sendVortexMsg(msgToUse, uuid))
789
846
 
790
847
  results = yield DeferredList(deferreds)
@@ -811,7 +868,9 @@ class VortexFactory:
811
868
  httpSession = "local"
812
869
  sendResponse = VortexFactory.sendVortexMsgLocally
813
870
 
814
- vortexMsgs = [vortexMsgs] if isinstance(vortexMsgs, bytes) else vortexMsgs
871
+ vortexMsgs = (
872
+ [vortexMsgs] if isinstance(vortexMsgs, bytes) else vortexMsgs
873
+ )
815
874
 
816
875
  def send(payloadEnvelope: PayloadEnvelope):
817
876
  try:
@@ -12,7 +12,7 @@ from twisted.internet import reactor
12
12
  from twisted.internet.defer import inlineCallbacks, Deferred
13
13
  from twisted.trial import unittest
14
14
 
15
- from vortex.test.VortexTcpMemoryLeakPayloadTest import (
15
+ from vortex.VortexTcpMemoryLeakPayloadTest import (
16
16
  MemoryCheckerTestMixin,
17
17
  VortexTcpConnectTestMixin,
18
18
  )
@@ -49,8 +49,8 @@ class VortexTcpMemoryLeakRawTest(
49
49
 
50
50
  dataSent = 0
51
51
  for _ in range(1024):
52
- dataSent += 1024 ** 2
53
- self._vortexServer.sendVortexMsg(b"x" * 1024 ** 2)
52
+ dataSent += 1024**2
53
+ self._vortexServer.sendVortexMsg(b"x" * 1024**2)
54
54
 
55
55
  # while dataSent < self._patchedProcessData_dataReceivedLen:
56
56
  for _ in range(2):
@@ -7,4 +7,4 @@
7
7
  * Support : support@synerty.com
8
8
  """
9
9
 
10
- __version__ = '4.0.3'
10
+ __version__ = '4.0.6'