{"id":22332720,"url":"https://github.com/xgfone/zkproxy","last_synced_at":"2025-03-26T07:22:09.410Z","repository":{"id":57624222,"uuid":"110348693","full_name":"xgfone/zkproxy","owner":"xgfone","description":"A ZooKeeper proxy based on HTTP+JSON.","archived":false,"fork":false,"pushed_at":"2017-11-29T09:12:58.000Z","size":33,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-04T04:20:15.637Z","etag":null,"topics":["http-json","http-json-proxy","http-proxy","proxy","zk","zk-proxy","zookeeper","zookeeper-proxy"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xgfone.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-11-11T13:46:03.000Z","updated_at":"2017-11-13T03:48:47.000Z","dependencies_parsed_at":"2022-08-26T22:11:58.261Z","dependency_job_id":null,"html_url":"https://github.com/xgfone/zkproxy","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xgfone%2Fzkproxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xgfone%2Fzkproxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xgfone%2Fzkproxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xgfone%2Fzkproxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xgfone","download_url":"https://codeload.github.com/xgfone/zkproxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236489507,"owners_count":19157013,"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":["http-json","http-json-proxy","http-proxy","proxy","zk","zk-proxy","zookeeper","zookeeper-proxy"],"created_at":"2024-12-04T04:19:28.717Z","updated_at":"2025-01-31T08:43:50.661Z","avatar_url":"https://github.com/xgfone.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zkproxy\nA ZooKeeper proxy based on HTTP+JSON.\n\n## Install \u0026 Start\n```bash\n$ go get github.com/xgfone/zkproxy\n$ cd $GOPATH/src/github.com/xgfone/zkproxy\n$ dep ensure\n$ go build -ldflags \"-X main.reversion=`git rev-parse HEAD` -X main.version=`git tag -l | tail -n 1`\" .\n$ ./zkproxy -zk_addrs 192.168.1.1:2181,192.168.1.2:2181,192.168.1.3:2181\n```\n\nNotice:\n1. The package manager is [dep](https://github.com/golang/dep), which will be added into the go tool chain in future.\n2. The go version should be 1.7+.\n3. The log uses [glog](https://github.com/golang/glog), so the arguments about log are given by `CLI`, and others support `CLI` and the `ini` configuration file. For the `ini` configuration file, you can assign it by the CLI option `-config-file`.\n4. You can see the usage by `zkproxy -h`.\n5. You can use the script `build.sh` to build the binary executable program.\n\n## Example\n```bash\n$ curl http://127.0.0.1/zk -X POST -d '{\"cmd\":\"create\", \"path\":\"/test\", \"data\":\"test\"} -H \"Content-Type: application/json\"'\n```\nOutput:\n```json\n{\"path\": \"/test\"}\n```\n\n## HTTP API\n\n### Method\nYou can use any HTTP method: `GET`, `POST`, `PUT`, `OPTION`, even `DELETE`. But suggest to use `POST`.\n\n### URL\nThe request url is `http(s)://host[:port]/zk`.\n\n### The Request Body\nThe request body is JSON, which must contain the field `cmd`.\n\n### The Response Status Code and Body.\n- 200: OK. If there is the body, it's JSON.\n- 400: The request body arguments is wrong.\n- 404: The path/node does not exist.\n- 406: The path/node has existed, or the version argument is not consistent with the server..\n- 500: The server error or other errors.\n- 501: The CMD is not implementation.\n\n**Notice:** If the status code is not 200, the body is an error string.\n\nFor the request and response body, except `cmd`, `exist`, `data`, `children`, the name and meaning of the other arguments are same as the java implementation of ZK. Please refer to the Java Doc.\n\n#### 1. AddAuthInfo\n**Request Body**\n\n|  Field  |  Type  | Required | Value\n|---------|--------|----------|----------------\n| cmd     | string | Y        | `add_auth_info`\n| scheme  | string | Y        |\n| auth    | string | Y        |\n\n**Response Body**\n\nNone.\n\n#### 2. Create\n**Request Body**\n\n|    Field   |  Type  | Required | Value\n|------------|--------|----------|---------\n| cmd        | string | Y        | `create`\n| path       | string | Y        |\n| data       | string | Y        |\n| ephemeral  | bool   | N        |\n| sequential | bool   | N        |\n| acl        | array  | N        |\n\nThe format of each element of the array `acl` is JSON:\n\n| Field  |  Type  | Required\n|--------|--------|---------\n| id     | string | Y\n| scheme | string | Y\n| perms  | int    | Y\n\n**Notice:** `ephemeral` is allowed to assign, but you should not use it, the lifecycle of which is associated with the session between the ZK client and server, that's this proxy and the ZK cluster. When using it, you should understand and consider whether it is what you need.\n\n**Response Body**\n\n| Field | Type\n|-------|--------\n| path  | string\n\n#### 3. Exists\n**Request Body**\n\n| Field |  Type  | Required | Value\n|-------|--------|----------|----------\n| cmd   | string | Y        | `exists`\n| path  | string | Y        |\n\n**Response Body**\n\nIf the path exists, the JSON is\n\n| Field | Type | Value\n|-------|------|--------\n| exist | bool | `true`\n| czxid | int |\n| mzxid | int |\n| pzxid | int |\n| ctime | int |\n| mtime | int |\n| version  | int |\n| cversion | int |\n| aversion | int |\n| data_length  | int |\n| num_children | int |\n| ephemeral_owner | int |\n\nIf the path does not exist, the JSON is\n\n| Field | Type | Value\n|-------|------|-------\n| exist | bool | `false`\n\n#### 4. GetChildren\n**Request Body**\n\n| Field |  Type  | Required | Value\n|-------|--------|----------|---------\n| cmd   | string | Y        | `get_children`\n| path  | string | Y        |\n\n**Response Body**\n\n| Field | Type\n|-------|------\n| children | array\\\u003cstring\u003e\n| czxid | int\n| mzxid | int\n| pzxid | int\n| ctime | int\n| mtime | int\n| version  | int\n| cversion | int\n| aversion | int\n| data_length  | int\n| num_children | int\n| ephemeral_owner | int\n\n#### 5. GetData\n**Request Body**\n\n| Field |  Type  | Required | Value\n|-------|--------|----------|---------\n| cmd   | string | Y        | `get_data`\n| path  | string | Y        |\n\n**Response Body**\n\n| Field | Type\n|-------|------\n| data | string\n| czxid | int\n| mzxid | int\n| pzxid | int\n| ctime | int\n| mtime | int\n| version  | int\n| cversion | int\n| aversion | int\n| data_length  | int\n| num_children | int\n| ephemeral_owner | int\n\n#### 6. SetData\n**Request Body**\n\n| Field |  Type  | Required | Value\n|-------|--------|--------- |----------\n| cmd   | string | Y        | `set_data`\n| path  | string | Y        |\n| data  | string | Y        |\n| version | int  | Y        |\n\n**Response Body**\n\n| Field | Type\n|-------|------\n| czxid | int\n| mzxid | int\n| pzxid | int\n| ctime | int\n| mtime | int\n| version  | int\n| cversion | int\n| aversion | int\n| data_length  | int\n| num_children | int\n| ephemeral_owner | int\n\n#### 7. GetACL\n**Request Body**\n\n| Field |  Type  | Required | Value\n|-------|--------|----------|----------\n| cmd   | string | Y        | `get_acl`\n| path  | string | Y        |\n\n**Response Body**\n\n| Feild | Type\n|-------|------\n| acl   | array\n| czxid | int\n| mzxid | int\n| pzxid | int\n| ctime | int\n| mtime | int\n| version  | int\n| cversion | int\n| aversion | int\n| data_length  | int\n| num_children | int\n| ephemeral_owner | int\n\nThe format of each element of the array `acl` is JSON:\n\n| Field  |  Type\n|--------|--------\n| id     | string\n| scheme | string\n| perms  | int\n\n#### 8. SetACL\n**Request Body**\n\n| Field |  Type  | Required | Value\n|-------|--------|--------- |----------\n| cmd   | string | Y        | `set_acl`\n| path  | string | Y        |\n| version | int  | Y        |\n| acl   | array  | Y        |\n\nThe format of each element of the array `acl` is JSON:\n\n| Field  |  Type  | Required\n|--------|--------|---------\n| id     | string | Y\n| scheme | string | Y\n| perms  | int    | Y\n\n**Response Body**\n\n| Field | Type\n|-------|------\n| czxid | int\n| mzxid | int\n| pzxid | int\n| ctime | int\n| mtime | int\n| version  | int\n| cversion | int\n| aversion | int\n| data_length  | int\n| num_children | int\n| ephemeral_owner | int\n\n#### 9. Delete\n**Request Body**\n\n| Field |  Type  | Required | Value\n|-------|--------|----------|----------\n| cmd   | string | Y        | `delete`\n| path  | string | Y        |\n| version | int  | Y        |\n\n**Response Body**\n\nNone.\n\n**Notice:** The watch api of `Exists`, `GetData`, `GetChildren`, and `Multi` are not implemented.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxgfone%2Fzkproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxgfone%2Fzkproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxgfone%2Fzkproxy/lists"}