{"id":16714233,"url":"https://github.com/flier/curator.go","last_synced_at":"2025-03-21T20:33:39.192Z","repository":{"id":30169977,"uuid":"33720330","full_name":"flier/curator.go","owner":"flier","description":"Golang porting for Curator","archived":false,"fork":false,"pushed_at":"2015-09-19T04:29:24.000Z","size":414,"stargazers_count":50,"open_issues_count":1,"forks_count":19,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-18T05:07:09.365Z","etag":null,"topics":[],"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/flier.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":"2015-04-10T09:28:18.000Z","updated_at":"2024-02-23T19:43:40.000Z","dependencies_parsed_at":"2022-07-12T14:22:14.709Z","dependency_job_id":null,"html_url":"https://github.com/flier/curator.go","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/flier%2Fcurator.go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Fcurator.go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Fcurator.go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Fcurator.go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flier","download_url":"https://codeload.github.com/flier/curator.go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244866389,"owners_count":20523507,"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":[],"created_at":"2024-10-12T20:49:57.957Z","updated_at":"2025-03-21T20:33:38.885Z","avatar_url":"https://github.com/flier.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# What is Curator?\n\nCurator n ˈkyoor͝ˌātər: a keeper or custodian of a museum or other collection - A ZooKeeper Keeper.\n\n![curator](http://curator.apache.org/images/ph-quote.png \"Patrick Hunt Quote\")\n\n## What is curator.go?\n\nCurator.go is a Golang porting for Curator, which base on the [go-zookeeper](https://github.com/samuel/go-zookeeper/).\n\n# Getting Started\n\n## Learn ZooKeeper\n\nCurator.go users are assumed to know ZooKeeper. A good place to start is [ZooKeeper Getting Started Guide](http://zookeeper.apache.org/doc/trunk/zookeeperStarted.html)\n\n## Install Curator.go\n\n\u003e $ go get github.com/flier/curator.go\n\n## Using Curator\n\nThe Curator.go are available from [github.com](https://github.com/flier/curator.go). You can easily include Curator.go into your code.\n\n``` \nimport (\n\t\"github.com/flier/curator.go\"\n)\n```\n\n## Getting a Connection\nCurator uses Fluent Style. If you haven't used this before, it might seem odd so it's suggested that you familiarize yourself with the style.\n\nCurator connection instances (CuratorFramework) are allocated from the CuratorFrameworkBuilder. You only need one CuratorFramework object for each ZooKeeper cluster you are connecting to:\n\n```\ncurator.NewClient(connString, retryPolicy)\n```\n\nThis will create a connection to a ZooKeeper cluster using default values. The only thing that you need to specify is the retry policy. For most cases, you should use:\n\n```\nretryPolicy := curator.NewExponentialBackoffRetry(time.Second, 3, 15*time.Second)\n\nclient := curator.NewClient(connString, retryPolicy)\n\nclient.Start()\ndefer client.Close()\t\n```\n\nThe client must be started (and closed when no longer needed).\n\n## Calling ZooKeeper Directly\n\nOnce you have a CuratorFramework instance, you can make direct calls to ZooKeeper in a similar way to using the raw ZooKeeper object provided in the ZooKeeper distribution. E.g.:\n\n```\nclient.Create().ForPathWithData(path, payload)\n```\n\nThe benefit here is that Curator manages the ZooKeeper connection and will retry operations if there are connection problems.\n\n## Recipes\n### Distributed Lock\n\n```\nlock := curator.NewInterProcessMutex(client, lockPath)\n\nif ( lock.Acquire(maxWait, waitUnit) ) \n{\n    defer lock.Release()\n\n    // do some work inside of the critical section here\n}\n```\n\n### Leader Election\n\n```\nlistener := curator.NewLeaderSelectorListener(func(CuratorFramework client) error {\n    // this callback will get called when you are the leader\n    // do whatever leader work you need to and only exit\n    // this method when you want to relinquish leadership\n}))\n\nselector := curator.NewLeaderSelector(client, path, listener)\nselector.AutoRequeue()  // not required, but this is behavior that you will probably expect\nselector.Start()\n```\n\n# Examples\nThis module contains example usages of various Curator features. Each directory in the module is a separate example.\n\n- [leader](examples/leader/) Example leader selector code \n- [cache](examples/cache/) Example PathChildrenCache usage\n- [locking](examples/locking/) Example of using InterProcessMutex\n- [discovery](examples/discovery/) Example usage of the Curator's ServiceDiscovery\n- [framework](examples/framework/) A few examples of how to use the CuratorFramework class\n\nSee the [examples](examples/) source repo for each example.\n\n# Components\n\n- [Recipes](doc/recipes.md) Implementations of some of the common ZooKeeper \"recipes\". The implementations are built on top of the Curator Framework.\n- [Framework](doc/framework.md) The Curator Framework is a high-level API that greatly simplifies using ZooKeeper. It adds many features that build on ZooKeeper and handles the complexity of managing connections to the ZooKeeper cluster and retrying operations.\n- [Utilities](doc/utilities.md) Various utilities that are useful when using ZooKeeper.\n- [Client](doc/client.md) A replacement for the bundled ZooKeeper class that takes care of some low-level housekeeping and provides some useful utilities.\n- [Errors](doc/errors.md) How Curator deals with errors, connection issues, recoverable exceptions, etc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflier%2Fcurator.go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflier%2Fcurator.go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflier%2Fcurator.go/lists"}