-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
1,152 additions
and
632 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
from .node import AbstractNode # noqa: F401 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
from ..message.syft_message import SyftMessage | ||
from ..message.syft_message import SyftMessageWithReply | ||
from ..message.syft_message import SyftMessageWithoutReply | ||
from ...decorators import syft_decorator | ||
from typing import final | ||
|
||
|
||
@final | ||
class ServerConnection(object): | ||
@syft_decorator(typechecking=True) | ||
def recv_msg(self, msg: SyftMessage) -> SyftMessage: | ||
def recv_msg_with_reply(self, msg: SyftMessageWithReply) -> SyftMessageWithoutReply: | ||
raise NotImplementedError | ||
|
||
def recv_msg_without_reply(self, msg: SyftMessageWithoutReply) -> None: | ||
raise NotImplementedError | ||
|
||
|
||
@final | ||
class ClientConnection(object): | ||
@syft_decorator(typechecking=True) | ||
def send_msg(self, msg: SyftMessage) -> SyftMessage: | ||
def send_msg_with_reply(self, msg: SyftMessageWithReply) -> SyftMessageWithoutReply: | ||
raise NotImplementedError | ||
|
||
@syft_decorator(typechecking=True) | ||
def send_msg_without_reply(self, msg: SyftMessageWithoutReply) -> None: | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,54 @@ | ||
from ...decorators import syft_decorator | ||
from ...common.id import UID | ||
from typing import final | ||
|
||
from ...common.message import AbstractMessage | ||
from typing import List | ||
|
||
class Route(object): | ||
""" | ||
A route is how a node can be reached by other nodes. | ||
Route provides a name, imagine it like a name server | ||
so that if user had multiple routes to the same name server | ||
it can identify it that these routes lead to the same | ||
destination. | ||
and Route provides connection details which could be any protocol. | ||
potentially this could also serve authentication details. | ||
A route is the highest level interface for how a node can | ||
reach other nodes. Route provides a name, imagine it like a name server | ||
so that if user had multiple routes to the same name server | ||
it can identify it that these routes lead to the same | ||
destination. | ||
Route also maintains connection objects which allow for actual | ||
communication over this route. | ||
""" | ||
def __init__(self, node_unique_name: UID): | ||
self.name = node_unique_name | ||
self.connection_details = {} | ||
|
||
def configure_connection(self, protocol: str, host: str, port: int): | ||
""" | ||
the route should have connection details embedded in it. | ||
so that nodes operators can utilize it to route messages. | ||
""" | ||
self.connection_details.update({ | ||
'host': host, | ||
'protocol': protocol, | ||
'port': port | ||
}) | ||
|
||
def register_broadcast_channel(self, channel_name: str): | ||
""" | ||
In the case configured protocol is pub/sub or event driven. | ||
Args: | ||
channel_name: the name of the channel to broadcast on. | ||
""" | ||
self.connection_details.update({'broadcast_channel': channel_name}) | ||
|
||
def __init__(self, connection_client_type): | ||
self.connection_client_type = connection_client_type | ||
self.connection_client = None | ||
|
||
def connect(self, *args, **kwargs): | ||
"""This method should initialize the connection_client with the correct | ||
metadata. Args and Kwargs are the connection parameters.""" | ||
return self.connection_client_type(**kwargs) | ||
|
||
def send_msg(self, msg: AbstractMessage): | ||
raise self.connection_client.send_msg(msg) | ||
|
||
|
||
class PointToPointRoute(Route): | ||
|
||
def __init__(self, target_node_id: UID, connection_client_type: type): | ||
super().__init__(connection_client_type=connection_client_type) | ||
self.target_node_id = target_node_id | ||
|
||
class BroadcastRoute(Route): | ||
|
||
#TODO: instead of passing in a list, come up with an abstractoin for | ||
# "worker group" of arbitrary size and membership which can include | ||
# "known members" but isn't intended to be exhaustive. | ||
def __init__(self, target_node_ids: List[UID], connection_client_type: type): | ||
super().__init__(connection_client_type=connection_client_type) | ||
self.target_node_ids = target_node_ids | ||
|
||
class MQTTRoute(Route): | ||
def connect(self): | ||
pass | ||
|
||
|
||
class HTTPRoute(Route): | ||
def connect(self): | ||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from .syft_message import SyftMessage | ||
from .syft_message import SyftMessageWithoutReply | ||
|
||
class DeleteObjectMessage(SyftMessage): | ||
class DeleteObjectMessage(SyftMessageWithoutReply): | ||
def __init__(self, obj_id, address, msg_id=None): | ||
super().__init__(address=address, msg_id=msg_id) | ||
self.obj_id = obj_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from .syft_message import SyftMessage | ||
from .syft_message import SyftMessageWithReply | ||
|
||
class GetObjectMessage(SyftMessage): | ||
class GetObjectMessage(SyftMessageWithReply): | ||
def __init__(self, obj_id, address, msg_id=None): | ||
super().__init__(address=address, msg_id=msg_id) | ||
self.obj_id = obj_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from .syft_message import SyftMessage | ||
|
||
class SaveObjectMessage(SyftMessage): | ||
def __init__(self, id, obj, address, msg_id=None): | ||
def __init__(self, obj_id, obj, address, msg_id=None): | ||
super().__init__(address=address, msg_id=msg_id) | ||
self.id = id | ||
self.obj_id = obj_id | ||
self.obj = obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.