async def start_cluster(node_cnt): pairs = [('127.0.0.1', 5600 + i) for i in range(node_cnt)] nodes = [] for i in range(node_cnt): node = Node(('127.0.0.1', 5600 + i)) nodes.append(node) for node in nodes: for pair in pairs: if node.port != pair[1]: node.add_node(pair) await node.start()
# coding: utf-8 __author__ = '*****@*****.**' __version__ = '0.0.1' from raft.node import Node import sys sys.path.append('..') if __name__ == '__main__': conf = { 'id': 'node_3', 'addr': ('localhost', 10003), 'peers': { 'node_1': ('localhost', 10001), 'node_2': ('localhost', 10002) } } node = Node(conf) node.run()
def test_ping(): from raft.node import Node node_instance = Node('locahost', 8000) node_instance.send_msg()