lablup / raftify

Experimental High level Raft framework
https://docs.rs/raftify/latest/raftify
Apache License 2.0
36 stars 14 forks source link

feat: Node.js binding PoC #162

Open jopemachine opened 1 month ago

jopemachine commented 1 month ago

Related issue: #94.

This was done purely just for fun, and I have no intention of finishing this task. But I'm leaving it as a PR for future reference.

❯ node example.js
Oct 13 06:55:59.846 INFO RaftNode bootstrapped. Config { raft_config: { id: 0, election_tick: 20, heartbeat_tick: 2, applied: 0, max_size_per_msg: 0, max_inflight_msgs: 256, check_quorum: false, pre_vote: false, min_election_tick: 0, max_election_tick: 0, read_only_option: Safe, skip_bcast_commit: false, batch_append: false, priority: 0, max_uncommitted_size: 18446744073709551615, max_committed_size_per_ready: 18446744073709551615, }, log_dir: logs, bootstrap_from_snapshot: false, save_compacted_logs: false, compacted_log_dir: ./, compacted_log_size_threshold: 1073741824, snapshot_interval: None, tick_interval: 0.1, initial_peers: None, lmdb_map_size: 1073741824, cluster_id: default, conf_change_request_timeout: 2, }
Oct 13 06:55:59.853 INFO switched to configuration; config: Configuration { voters: Configuration { incoming: Configuration { voters: {1} }, outgoing: Configuration { voters: {} } }, learners: {}, learners_next: {}, auto_leave: false }
Oct 13 06:55:59.853 DEBG reset election timeout 0 -> 37 at 0
Oct 13 06:55:59.853 INFO became follower at term 0 from_role Follower
Oct 13 06:55:59.853 INFO newRaft; term: 0, commit: 0, applied: 0, last index: 0, last term: 0, peers: Configuration { incoming: Configuration { voters: {1} }, outgoing: Configuration { voters: {} } }
Oct 13 06:55:59.853 INFO RawNode created with id 1.
Oct 13 06:55:59.853 DEBG reset election timeout 37 -> 36 at 0
Oct 13 06:55:59.853 INFO became candidate at term 1
Oct 13 06:55:59.853 DEBG reset election timeout 36 -> 31 at 0
Oct 13 06:55:59.853 INFO became leader at term 1
Oct 13 06:55:59.853 DEBG RaftServer starts to listen gRPC requests on "127.0.0.1:60061"...
Applying entries: [Entry { entry_type: EntryNormal, term: 1, index: 1, data: [], context: [], sync_log: false }]
Oct 13 06:55:59.968 DEBG persisted index 1
Oct 13 06:55:59.968 DEBG committing index 1
Oct 13 06:55:59.968 DEBG Entries [1, 2) requested.