{"id":13800830,"url":"https://github.com/mingchuno/etcd4s","last_synced_at":"2025-04-13T09:33:09.740Z","repository":{"id":29451374,"uuid":"111095837","full_name":"mingchuno/etcd4s","owner":"mingchuno","description":"Scala etcd client implementing V3 APIs","archived":false,"fork":false,"pushed_at":"2024-10-12T03:56:11.000Z","size":108,"stargazers_count":31,"open_issues_count":13,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-18T15:32:12.516Z","etag":null,"topics":["akka","akka-streams","etcd","etcd-client","etcdv3","grpc","scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","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/mingchuno.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-17T11:26:19.000Z","updated_at":"2023-07-07T12:11:57.000Z","dependencies_parsed_at":"2023-12-14T18:50:05.664Z","dependency_job_id":"c8d7a22e-0ad1-4bf7-be0d-212d1d29652f","html_url":"https://github.com/mingchuno/etcd4s","commit_stats":{"total_commits":83,"total_committers":4,"mean_commits":20.75,"dds":"0.42168674698795183","last_synced_commit":"e8d1772a1b6d4d72d46ad8e66f0768097dd530ba"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mingchuno%2Fetcd4s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mingchuno%2Fetcd4s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mingchuno%2Fetcd4s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mingchuno%2Fetcd4s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mingchuno","download_url":"https://codeload.github.com/mingchuno/etcd4s/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248690949,"owners_count":21146238,"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":["akka","akka-streams","etcd","etcd-client","etcdv3","grpc","scala"],"created_at":"2024-08-04T00:01:16.737Z","updated_at":"2025-04-13T09:33:09.714Z","avatar_url":"https://github.com/mingchuno.png","language":"Scala","readme":"# etcd4s\n\n[![Build Status](https://travis-ci.org/mingchuno/etcd4s.svg?branch=master)](https://travis-ci.org/mingchuno/etcd4s)\n\nA Scala etcd client implementing V3 API using gRPC and ScalaPB with optional Akka Stream support. This project is in beta stage with basic test coverage and usable APIs.\n\n## Overview\n\nThis repo is a client library of [etcd](https://etcd.io/) implementing V3 [APIs](https://etcd.io/docs/v3.3.12/rfc/) using gRPC under the hood with optional Akka Stream support for stream APIs. This library implement the complete set of the APIs in the V3 protoal. More information about the APIs can be found here:\n\n* [etcd V3 API overview](https://etcd.io/docs/v3.3.12/rfc/)\n* [etcd V3 API Reference](https://etcd.io/docs/v3.3.12/dev-guide/api_reference_v3/)\n* [protobuf defination](https://github.com/mingchuno/etcd4s/tree/master/etcd4s-core/src/main/protobuf)\n\nNote that this library do not support gRPC json gateway and use raw gRPC call instead (underlying is java-grpc). This project cross build against Scala 2.12 and 2.13 and also tested against etcd 3.2.x, 3.3.x but fail under 3.4.x.\n\n## Getting Started\n\nThe core lib\n\n```scala\nlibraryDependencies += \"com.github.mingchuno\" %% \"etcd4s-core\" % \"0.4.0\"\n```\n\nTo include akka stream support for stream API\n\n```scala\nlibraryDependencies += \"com.github.mingchuno\" %% \"etcd4s-akka-stream\" % \"0.4.0\"\n```\n\n## Usage\n\n```scala\nimport org.etcd4s.{Etcd4sClientConfig, Etcd4sClient}\nimport org.etcd4s.implicits._\nimport org.etcd4s.formats._\nimport org.etcd4s.pb.etcdserverpb._\n\nimport scala.concurrent.ExecutionContext.Implicits.global\n\n// create the client\nval config = Etcd4sClientConfig(\n  address = \"127.0.0.1\",\n  port = 2379\n)\nval client = Etcd4sClient.newClient(config)\n\n// set a key\nclient.setKey(\"foo\", \"bar\") // return a Future\n\n// get a key\nclient.getKey(\"foo\").foreach { result =\u003e\n  assert(result == Some(\"bar\"))\n}\n\n// delete a key\nclient.deleteKey(\"foo\").foreach { result =\u003e\n  assert(result == 1)\n}\n\n// set more key\nclient.setKey(\"foo/bar\", \"Hello\")\nclient.setKey(\"foo/baz\", \"World\")\n\n// get keys with range\nclient.getRange(\"foo/\").foreach { result =\u003e\n  assert(result.count == 2)\n}\n\n// remember to shutdown the client\nclient.shutdown()\n```\n\nThe above is wrapper for simplified APIs. If you want to access all underlying APIs with full options. You can use the corresponding api instance to have more control.\n\n```scala\nclient.kvApi.range(...)\nclient.kvApi.put(...)\nclient.leaseApi.leaseGrant(...)\nclient.electionApi.leader(...)\n```\n\nIf you want the Akka Stream support for the stream APIs, you should add the `etcd4s-akka-stream` depns into your `build.sbt`\n\n```scala\nimport org.etcd4s.akkasupport._\nimport org.etcd4s.implicits._\nimport org.etcd4s.pb.etcdserverpb._\nimport akka.NotUsed\n\n// assume you have the implicit value and client needed in the scope\nval flow: Flow[WatchRequest, WatchResponse, NotUsed] = client.watchApi.watchFlow\nval request: WatchRequest = WatchRequest().withCreateRequest(WatchCreateRequest().withKey(\"foo\"))\nSource.single(request)\n  .via(flow)\n  .runForeach { resp =\u003e\n    println(resp)\n  }\n```\n\nMore example usage under the test dir in the repo.\n\n## Development\n\n### Requirment\n\n* Java 8+, Scala 12.12.X+, sbt and docker\n\n```bash\n# to start a background etcd for development\ndocker-compose up -d\n```\n\n### How to start?\n\nSimple! Just `sbt test`\n\n### Publish\n\nThis is to remind me how to publish and may switch to `sbt-release` later\n\n1. make sure you have `~/.sbt/gpg/` ready with pub/sec key paris\n2. make sure you have `~/.sbt/1.0/sonatype.sbt` ready with credentials\n3. `sbt \"+clean\" \"+compile\"`\n4. `sbt \"+publishSigned\"`\n5. `sbt sonatypeReleaseAll`\n","funding_links":[],"categories":["Table of Contents"],"sub_categories":["Database"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmingchuno%2Fetcd4s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmingchuno%2Fetcd4s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmingchuno%2Fetcd4s/lists"}