An etcd client built on top of gun and egrpc.

Features

  • [x] etcd v3 gRPC APIs.
    • etcdserverpb.KV
    • etcdserverpb.Watch
    • etcdserverpb.Lease
    • etcdserverpb.Auth
    • etcdserverpb.Cluster
    • etcdserverpb.Maintenance
  • [x] etcd v3 concurrency gRPC APIs.
    • v3electionpb.Election
    • v3lockpb.Lock
  • [x] gRPC health v1 API (via egrpc)
  • [x] unary and streaming interceptors for more flexible needs.
  • [x] etcd authentication and auto-token-refreshing.
  • [x] lease keep alive etcdgun_lease_keepalive.
  • [x] watcher with auto-reconnect etcdgun_watcher.
  • [x] auth-check etcd member list etcdgun_membership.
  • [x] etcd endpoints health check when dial.
  • [ ] health check for active channels in interval.
  • [ ] idle connection keep alive?

Generating etcd v3 API codes via the proto files in etcd v3.5.10, without changing their packets.

Extract ResponseHeader from rpc.proto into response_header.proto to avoid gpb to generate the same structure in multiple output pb modules.

Client APIs

Starting Client

Client = foo,
Opts = #{},
{ok, _Pid} = etcdgun:open(my_client, [{"127.0.0.1", 2379}], Opts),

%% Now you can use `my_client' to pick channels and call the etcd gRPC APIs.
{ok, Channel} = etcdgun_client:pick_channel(my_client).

%% Get etcd member list via v3 API
{ok, #{header := _, members := Members}} =
    etcdgun_etcdserverpb_cluster_client:member_list(Channel, #{}).

%% Check heath via egrpc provided standard health check API
{ok, #{status => 'SERVING'}} = egrpc_grpc_health_v1_health_client:check(Channel, #{}).

Client Options

See etcdgun:opts() for the available options.

Support unary interceptors and streaming interceptors.

API Call

Development

To Generate Protobuf Modules

rebar3 protobuf compile

To Generate the etcd gRPC Client Codes

rebar3 egrpc gen