{"id":18385351,"url":"https://github.com/upsight/dinghy","last_synced_at":"2025-07-27T12:36:50.055Z","repository":{"id":49825273,"uuid":"81683276","full_name":"upsight/dinghy","owner":"upsight","description":"Dinghy implements leader election using the raft protocol","archived":false,"fork":false,"pushed_at":"2018-01-09T21:11:27.000Z","size":209,"stargazers_count":13,"open_issues_count":1,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-06-19T02:08:31.631Z","etag":null,"topics":["go","golang","leader-election","raft"],"latest_commit_sha":null,"homepage":"","language":"Go","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/upsight.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":"2017-02-11T21:24:18.000Z","updated_at":"2023-08-25T10:06:43.000Z","dependencies_parsed_at":"2022-09-26T20:52:18.313Z","dependency_job_id":null,"html_url":"https://github.com/upsight/dinghy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upsight%2Fdinghy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upsight%2Fdinghy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upsight%2Fdinghy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upsight%2Fdinghy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/upsight","download_url":"https://codeload.github.com/upsight/dinghy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223266797,"owners_count":17116517,"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":["go","golang","leader-election","raft"],"created_at":"2024-11-06T01:17:21.680Z","updated_at":"2024-11-06T01:17:22.196Z","avatar_url":"https://github.com/upsight.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dinghy [![GoDoc](https://godoc.org/github.com/upsight/dinghy?status.svg)](http://godoc.org/github.com/upsight/dinghy) [![Build Status](https://travis-ci.org/upsight/dinghy.svg?branch=master)](https://travis-ci.org/upsight/dinghy)\n\nDinghy implements leader election using part of the raft protocol. It might\nbe useful if you have several workers but only want one of them at a time\ndoing things.\n\n```\npackage main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\t\"os\"\n\t\"strings\"\n\n\t\"github.com/upsight/dinghy\"\n)\n\nfunc main() {\n\taddr := flag.String(\"addr\", \"localhost:8899\", \"The address to listen on.\")\n\tnodesList := flag.String(\"nodes\", \"localhost:8898,localhost:8897\", \"Comma separated list of host:port\")\n\tflag.Parse()\n\n\tnodes := strings.Split(*nodesList, \",\")\n\tnodes = append(nodes, *addr)\n\n\tonLeader := func() error {\n\t\tfmt.Println(\"leader\")\n\t\treturn nil\n\t}\n\tonFollower := func() error {\n\t\tfmt.Println(\"me follower\")\n\t\treturn nil\n\t}\n\n\tdin, err := dinghy.New(\n\t\t*addr,\n\t\tnodes,\n\t\tonLeader,\n\t\tonFollower,\n\t\t\u0026dinghy.LogLogger{Logger: log.New(os.Stderr, \"logger: \", log.Lshortfile)},\n\t\tdinghy.DefaultElectionTickRange,\n\t\tdinghy.DefaultHeartbeatTickRange,\n\t)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfor _, route := range din.Routes() {\n\t\thttp.HandleFunc(route.Path, route.Handler)\n\t}\n\tgo func() {\n\t\tif err := din.Start(); err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}()\n\tlog.Fatal(http.ListenAndServe(*addr, nil))\n}\n```\n\n\n![dinghy](dinghy.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupsight%2Fdinghy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fupsight%2Fdinghy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupsight%2Fdinghy/lists"}