{"id":21228912,"url":"https://github.com/anthonycorletti/pontoon","last_synced_at":"2025-08-06T11:26:47.799Z","repository":{"id":56888497,"uuid":"56719397","full_name":"anthonycorletti/pontoon","owner":"anthonycorletti","description":"Pontoon is a Ruby implementation of the Raft algorithm.","archived":false,"fork":false,"pushed_at":"2016-04-21T21:11:45.000Z","size":10,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T09:47:52.405Z","etag":null,"topics":["cluster","concurrency","raft","raft-algorithm","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anthonycorletti.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-20T20:39:56.000Z","updated_at":"2020-11-17T07:35:07.000Z","dependencies_parsed_at":"2022-08-20T16:00:32.015Z","dependency_job_id":null,"html_url":"https://github.com/anthonycorletti/pontoon","commit_stats":null,"previous_names":["anthcor/pontoon"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonycorletti%2Fpontoon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonycorletti%2Fpontoon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonycorletti%2Fpontoon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonycorletti%2Fpontoon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anthonycorletti","download_url":"https://codeload.github.com/anthonycorletti/pontoon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243672380,"owners_count":20328762,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cluster","concurrency","raft","raft-algorithm","ruby"],"created_at":"2024-11-20T23:23:12.991Z","updated_at":"2025-03-15T01:44:56.215Z","avatar_url":"https://github.com/anthonycorletti.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pontoon\n\n[![Build Status](https://travis-ci.org/anthcor/pontoon.svg?branch=master)](https://travis-ci.org/anthcor/pontoon)\n[![Gem Version](https://badge.fury.io/rb/pontoon.svg)](http://badge.fury.io/rb/pontoon)\n\nPontoon is a Ruby implementation of the Raft algorithm.\n\nRaft is a distributed consensus algorithm designed to be easy to understand. The algorithm is the work of Diego Ongaro and John Ousterhout at Stanford University.\nThe implementation here is based upon [this paper](https://ramcloud.stanford.edu/wiki/download/attachments/11370504/raft.pdf).\n\n## Technical Design\nThis gem provides a `Pontoon::Node` class that handles log replication across a cluster of peer nodes.\nDesign decisions about the RPC protocol, concurrency mechanism, error handling and data persistence are left to the client.\nFor convenience and testing, an example implementation is provided based on Goliath and EventMachine, with in-memory data persistence.\nContributions of further examples are very welcome!\n\n## Usage\nInstall the gem:\n```bash\ngem install pontoon\n```\n\nIn your code, add a require:\n```ruby\nrequire 'pontoon'\n```\n\nIf you'd like to use the example Goliath implementation, add:\n```ruby\nrequire 'pontoon/goliath'\n```\n\nPontoon replicates commands across a cluster of nodes.  Each node in the cluster is aware of every other node in the\ncluster.  Let's create a new cluster and define its configuration:\n```ruby\n@cluster = Pontoon::Cluster.new('alpha', 'beta', 'gamma')\n\n@config = Pontoon::Config.new(\n  rpc_provider,       # see Pontoon::RpcProvider\n  async_provider,     # see Pontoon::AsyncProvider\n  election_timeout,   # in seconds\n  election_splay,     # in seconds\n  update_interval,    # in seconds\n  heartbeat_interval) # in seconds\n```\n\nNow we can create Pontoon nodes for each node defined in the cluster:\n```ruby\n@nodes = @cluster.node_ids.map do |node_id|\n  Pontoon::Node.new(node_id, @config, @cluster)\nend\n```\n\nSince the concurrency mechanism is left to the client, you must call `Pontoon::Node#update` regularly to allow the\nnode to participate in the cluster:\n```ruby\n# Threaded example:\n@update_threads = @nodes.map do |node|\n Thread.new do\n   while true\n     node.update\n     sleep(node.config.update_interval)\n   end\n end\nend\n```\n```ruby\n# Evented example\n@update_timers =  @nodes.map do |node|\n  EventMachine.add_periodic_timer(node.config.update_interval) do\n    EM.synchrony do\n      node.update\n    end\n  end\nend\n```\n\nWe can send commands (which are strings) to the cluster and they will be appended to the command log, which will be\nreplicated across the cluster.\n```ruby\ncommand = 'example'\nrequest = Pontoon::CommandRequest.new(command)\nnode = @nodes.sample\nresponse = node.handle_command(request) # response is a Pontoon::CommandResponse\n```\n\nNote that `Pontoon::Node#handle_command` will not return success until the command has been replicated to a majority of nodes,\nso that it is considered *committed* and is safe to execute.\n\nIf you would like to execute commands as they are committed, you can assign a commit handler for each node:\n```ruby\n@nodes.each do |node|\n  node.commit_handler = Proc.new do |command|\n    puts \"Node #{node.id} executing command #{command}!\"\n  end\nend\n```\n\n## Issues and Feedback\nIf you encounter problems with this gem, please feel free to raise an issue.\n\n## Contributing\nFork this repository and make a pull request!\n\n## License\nPontoon is released under the [MIT license](/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonycorletti%2Fpontoon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanthonycorletti%2Fpontoon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonycorletti%2Fpontoon/lists"}