koi-net 1.0.0b14__py3-none-any.whl → 1.0.0b15__py3-none-any.whl
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.
Potentially problematic release.
This version of koi-net might be problematic. Click here for more details.
- koi_net/processor/default_handlers.py +53 -0
- {koi_net-1.0.0b14.dist-info → koi_net-1.0.0b15.dist-info}/METADATA +1 -1
- {koi_net-1.0.0b14.dist-info → koi_net-1.0.0b15.dist-info}/RECORD +5 -5
- {koi_net-1.0.0b14.dist-info → koi_net-1.0.0b15.dist-info}/WHEEL +0 -0
- {koi_net-1.0.0b14.dist-info → koi_net-1.0.0b15.dist-info}/licenses/LICENSE +0 -0
|
@@ -9,6 +9,8 @@ from .handler import KnowledgeHandler, HandlerType, STOP_CHAIN
|
|
|
9
9
|
from .knowledge_object import KnowledgeObject, KnowledgeSource
|
|
10
10
|
from ..protocol.event import Event, EventType
|
|
11
11
|
from ..protocol.edge import EdgeProfile, EdgeStatus, EdgeType
|
|
12
|
+
from ..protocol.node import NodeProfile
|
|
13
|
+
from ..protocol.helpers import generate_edge_bundle
|
|
12
14
|
|
|
13
15
|
logger = logging.getLogger(__name__)
|
|
14
16
|
|
|
@@ -124,6 +126,57 @@ def edge_negotiation_handler(processor: ProcessorInterface, kobj: KnowledgeObjec
|
|
|
124
126
|
|
|
125
127
|
# Network handlers
|
|
126
128
|
|
|
129
|
+
@KnowledgeHandler.create(HandlerType.Network, rid_types=[KoiNetNode])
|
|
130
|
+
def coordinator_contact(processor: ProcessorInterface, kobj: KnowledgeObject):
|
|
131
|
+
node_profile = kobj.bundle.validate_contents(NodeProfile)
|
|
132
|
+
|
|
133
|
+
# looking for event provider of nodes
|
|
134
|
+
if KoiNetNode not in node_profile.provides.event:
|
|
135
|
+
return
|
|
136
|
+
|
|
137
|
+
# already have an edge established
|
|
138
|
+
if processor.network.graph.get_edge_profile(
|
|
139
|
+
source=kobj.rid,
|
|
140
|
+
target=processor.identity.rid,
|
|
141
|
+
) is not None:
|
|
142
|
+
return
|
|
143
|
+
|
|
144
|
+
logger.info("Identified a coordinator!")
|
|
145
|
+
logger.info("Proposing new edge")
|
|
146
|
+
|
|
147
|
+
if processor.identity.profile.node_type == NodeType.FULL:
|
|
148
|
+
edge_type = EdgeType.WEBHOOK
|
|
149
|
+
else:
|
|
150
|
+
edge_type = EdgeType.POLL
|
|
151
|
+
|
|
152
|
+
# queued for processing
|
|
153
|
+
processor.handle(bundle=generate_edge_bundle(
|
|
154
|
+
source=kobj.rid,
|
|
155
|
+
target=processor.identity.rid,
|
|
156
|
+
edge_type=edge_type,
|
|
157
|
+
rid_types=[KoiNetNode]
|
|
158
|
+
))
|
|
159
|
+
|
|
160
|
+
logger.info("Catching up on network state")
|
|
161
|
+
|
|
162
|
+
payload = processor.network.request_handler.fetch_rids(
|
|
163
|
+
node=kobj.rid,
|
|
164
|
+
rid_types=[KoiNetNode]
|
|
165
|
+
)
|
|
166
|
+
for rid in payload.rids:
|
|
167
|
+
if rid == processor.identity.rid:
|
|
168
|
+
logger.info("Skipping myself")
|
|
169
|
+
continue
|
|
170
|
+
if processor.cache.exists(rid):
|
|
171
|
+
logger.info(f"Skipping known RID '{rid}'")
|
|
172
|
+
continue
|
|
173
|
+
|
|
174
|
+
# marked as external since we are handling RIDs from another node
|
|
175
|
+
# will fetch remotely instead of checking local cache
|
|
176
|
+
processor.handle(rid=rid, source=KnowledgeSource.External)
|
|
177
|
+
logger.info("Done")
|
|
178
|
+
|
|
179
|
+
|
|
127
180
|
@KnowledgeHandler.create(HandlerType.Network)
|
|
128
181
|
def basic_network_output_filter(processor: ProcessorInterface, kobj: KnowledgeObject):
|
|
129
182
|
"""Default network handler.
|
|
@@ -8,7 +8,7 @@ koi_net/network/interface.py,sha256=DhMbVjKp9xdZReKldHWh72jkhd3RS_Q4XeNqg42mwyM,
|
|
|
8
8
|
koi_net/network/request_handler.py,sha256=66gjX2x4UnBWZYwKLjp_3WkhL-ekhR3VAyfGviHTcUs,4790
|
|
9
9
|
koi_net/network/response_handler.py,sha256=CAwici2Etj9ESndERXdtYkMlc4gWHz_xc7jHgY2Qjcg,1830
|
|
10
10
|
koi_net/processor/__init__.py,sha256=x4fAY0hvQEDcpfdTB3POIzxBQjYAtn0qQazPo1Xm0m4,41
|
|
11
|
-
koi_net/processor/default_handlers.py,sha256=
|
|
11
|
+
koi_net/processor/default_handlers.py,sha256=f8Yl21lLGMa_oW51bf8sBuunfP9_rmiSu32T-rZ4kUY,8542
|
|
12
12
|
koi_net/processor/handler.py,sha256=7X6M6PP8m6-xdtsP1y4QO83g_MN5VSszNNikprITK80,2523
|
|
13
13
|
koi_net/processor/interface.py,sha256=Ecy0XWW7KfuDBFt7fXEmag4CzHP768mtO4uRZWNZN4E,13000
|
|
14
14
|
koi_net/processor/knowledge_object.py,sha256=RCgzkILsWm1Jw_NkSu4jTRYA9Ugga6mJ4jqKWwketQs,4090
|
|
@@ -19,7 +19,7 @@ koi_net/protocol/edge.py,sha256=CcmvIY4P1HEBdKNJ4wFRDmwYMRMss24Besmbi7ZRFxQ,427
|
|
|
19
19
|
koi_net/protocol/event.py,sha256=HxzLN-iCXPyr2YzrswMIkgZYeUdFbBpa5v98dAB06lQ,1328
|
|
20
20
|
koi_net/protocol/helpers.py,sha256=8ZkQrjb_G0QEaMIKe9wkFOBonl1bkmemx_pwKMwIiLg,695
|
|
21
21
|
koi_net/protocol/node.py,sha256=2HhCh3LdBLlY2Z_kXNmKHzpVLKbP_ODob3HjHayFQtM,375
|
|
22
|
-
koi_net-1.0.
|
|
23
|
-
koi_net-1.0.
|
|
24
|
-
koi_net-1.0.
|
|
25
|
-
koi_net-1.0.
|
|
22
|
+
koi_net-1.0.0b15.dist-info/METADATA,sha256=j7imUyTL-YbiIb4oL6j2jD2hd7dna35ya_mWGK2B2xE,34203
|
|
23
|
+
koi_net-1.0.0b15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
24
|
+
koi_net-1.0.0b15.dist-info/licenses/LICENSE,sha256=03mgCL5qth2aD9C3F3qNVs4sFJSpK9kjtYCyOwdSp7s,1069
|
|
25
|
+
koi_net-1.0.0b15.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|