Skip to content

feat: implement etcd gRPC gateway for HTTP JSON-RPC compatibility#38

Merged
axfor merged 1 commit intoaxfor:mainfrom
yantingqiu:main
Jan 12, 2026
Merged

feat: implement etcd gRPC gateway for HTTP JSON-RPC compatibility#38
axfor merged 1 commit intoaxfor:mainfrom
yantingqiu:main

Conversation

@yantingqiu
Copy link
Copy Markdown
Collaborator

test:
1、member list

curl -v -X POST http://127.0.0.1:22379/v3/cluster/member/list -d '{}' |  jq
{
  "header": {
    "cluster_id": "1",
    "member_id": "1",
    "revision": "3",
    "raft_term": "5"
  },
  "members": [
    {
      "ID": "1",
      "name": "node-1",
      "peerURLs": [
        "http://127.0.0.1:9021"
      ],
      "clientURLs": [
        "http://127.0.0.1:9121"
      ]
    }
        "http://127.0.0.1:9021"
      ],
      "clientURLs": [
        "http://127.0.0.1:9121"
      ]
    }
      ]
    }
  ]
}

2、put key

curl -X POST http://localhost:22379/v3/kv/range   -H "Content-Type: application/json"   -d '{"key": "Zm9v"}' | jq
{
  "header": {
    "cluster_id": "1",
    "member_id": "1",
    "revision": "3",
    "raft_term": "5"
  },
  "kvs": [
    {
      "key": "Zm9v",
      "create_revision": "3",
      "mod_revision": "3",
      "version": "1",
      "value": "YmFy"
    }
  ],
  "count": "1"
}

.... and all other api

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements an etcd gRPC gateway that enables HTTP/JSON access to etcd v3 API endpoints via grpc-gateway, providing compatibility for clients that prefer HTTP/JSON over native gRPC.

Key changes:

  • Added optional etcd grpc-gateway configuration that proxies HTTP requests under /v3/** to the etcd gRPC service
  • Integrated gateway handler into the HTTP server with path-based routing
  • Modified cmux matchers to support both gRPC and HTTP/JSON traffic on the same port

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
pkg/config/config.go Added EtcdGatewayConfig struct with enable flag and endpoint, plus environment variable overrides and validation
configs/config.yaml Added example etcd_gateway configuration section with enable flag and endpoint
cmd/metastore/main.go Integrated gateway handler creation and setup (appears in both memory and rocksdb storage branches)
api/http/server.go Added gateway handler field and routing logic to intercept /v3/ prefixed requests
api/etcdgateway/gateway.go Core gateway implementation that registers etcd v3 service handlers and normalizes endpoints
api/etcdgateway/logging.go HTTP middleware for logging gateway requests
Makefile Minor whitespace cleanup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@axfor axfor merged commit 9e02c10 into axfor:main Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants