Skip to content

Commit 4f538d3

Browse files
committed
Moving node_id to default config section
Also fixing a few minor bugs introduced by the rebase with master.
1 parent f987e85 commit 4f538d3

4 files changed

Lines changed: 15 additions & 15 deletions

File tree

docs/source/intro.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ following configuration:
8282
In the video below you'll see these 3 nodes launched in a ``tmux`` 4-pane layout
8383
with the following commands::
8484

85-
$ receptor -d /tmp/controller controller --socket-path=/tmp/receptor.sock --listen-port=8888 --node-id=controller
86-
$ receptor -d /tmp/node-a node --listen-port=8889 --peer=localhost:8888 --node-id=node-a
87-
$ receptor -d /tmp/node-b node --listen-port=8890 --peer=localhost:8889 --node-id=node-b
85+
$ receptor --node-id=controller -d /tmp/controller controller --socket-path=/tmp/receptor.sock --listen-port=8888
86+
$ receptor --node-id=node-a -d /tmp/node-a node --listen-port=8889 --peer=localhost:8888
87+
$ receptor --node-id=node-b -d /tmp/node-b node --listen-port=8890 --peer=localhost:8889
8888

8989
In the last pane we execute the ``ping`` command::
9090

receptor/config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ def __init__(self, args=None):
5555
self._config_file = configparser.ConfigParser(allow_no_value=True, delimiters=('=',))
5656

5757
# Default options, which apply to all sub-commands.
58+
self.add_config_option(
59+
section='default',
60+
key='node_id',
61+
#long_option='--node-id',
62+
default_value='',
63+
value_type='str',
64+
hint='Set/override node identifier. If unspecified here or in a config file, one will be automatically generated.',
65+
)
5866
self.add_config_option(
5967
section='default',
6068
key='config',
@@ -112,14 +120,6 @@ def __init__(self, args=None):
112120
value_type='int',
113121
hint='Set/override TCP port to listen on. If not set here or in a config file, the default is 8888.',
114122
)
115-
self.add_config_option(
116-
section='node',
117-
key='id',
118-
long_option='--node-id',
119-
default_value='',
120-
value_type='str',
121-
hint='Set/override node identifier. If unspecified here or in a config file, one will be automatically generated.',
122-
)
123123
self.add_config_option(
124124
section='node',
125125
key='peers',

receptor/entrypoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ def run_as_send(config):
2727

2828
def run_as_node(config):
2929
receptor = Receptor(config)
30-
logger.info("Running as Receptor node with ID: {}".format(receptor.node_id))
30+
logger.info(f'Running as Receptor node with ID: {receptor.node_id}')
3131
node.mainloop(receptor, config.node_ping_interval)

receptor/receptor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ class Receptor:
1717
def __init__(self, config, node_id=None, router_cls=None,
1818
work_manager_cls=None):
1919
self.config = config
20-
self.node_id = node_id or self.config.node_id or self._find_node_id()
20+
self.node_id = node_id or self.config.default_node_id or self._find_node_id()
2121
self.router = (router_cls or MeshRouter)(self)
2222
self.work_manager = (work_manager_cls or WorkManager)(self)
2323
self.connections = dict()
2424
self.controller_connections = []
25-
self.connection_manifest_path = os.path.join(self.config.server.data_dir,
25+
self.connection_manifest_path = os.path.join(self.config.default_data_dir,
2626
self.node_id,
2727
"connection_manifest")
2828
self.stop = False
@@ -41,7 +41,7 @@ async def watch_expire(self):
4141
while True:
4242
current_manifest = self.get_connection_manifest()
4343
for connection in current_manifest:
44-
buffer = self.config.components.buffer_manager.get_buffer_for_node(connection["id"], self)
44+
buffer = self.config.components_buffer_manager.get_buffer_for_node(connection["id"], self)
4545
for ident, message in buffer:
4646
message_actual = json.loads(message)
4747
if "expire_time" in message_actual and message_actual['expire_time'] < time.time():

0 commit comments

Comments
 (0)