{"id":14343633,"url":"https://github.com/swift-server/swift-etcd-client-gsoc","last_synced_at":"2025-08-20T05:33:04.959Z","repository":{"id":243227102,"uuid":"801078666","full_name":"swift-server/swift-etcd-client-gsoc","owner":"swift-server","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-16T11:41:18.000Z","size":62,"stargazers_count":10,"open_issues_count":1,"forks_count":4,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-12-16T12:34:08.426Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/swift-server.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2024-05-15T14:49:40.000Z","updated_at":"2024-12-16T11:41:24.000Z","dependencies_parsed_at":"2024-06-21T08:13:35.480Z","dependency_job_id":"7b0c7f81-516f-4718-a253-ff6bff57b493","html_url":"https://github.com/swift-server/swift-etcd-client-gsoc","commit_stats":null,"previous_names":["swift-server/swift-etcd-client-gsoc"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-server%2Fswift-etcd-client-gsoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-server%2Fswift-etcd-client-gsoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-server%2Fswift-etcd-client-gsoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-server%2Fswift-etcd-client-gsoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swift-server","download_url":"https://codeload.github.com/swift-server/swift-etcd-client-gsoc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230398734,"owners_count":18219491,"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-08-26T17:00:41.022Z","updated_at":"2024-12-19T07:30:28.069Z","avatar_url":"https://github.com/swift-server.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# 🚧WIP🚧: Swift ETCD client\n\nSwift ETCD is a Swift Package that provides a convenient way to communicate with [etcd](https://etcd.io) servers.\n\n## Getting Started\nTo depend on Swift ETCD within your own project, you can add a `dependencies` clause to your `Package.swift`\n```\ndependencies: [\n    .package(url: \"https://github.com/swift-server/swift-etcd-client-gsoc\")\n]\n```\n\n## Overview\nThe ETCD Client allows for communication with an ETCD Server. The Client takes care of establishing a connection, and handling asynchronous execution of commands.\n\nHere's an example of how you can use the ETCD Client\n\n```swift\nstruct Example {\n    static func main() async throws {\n        let eventLoopGroup = MultiThreadedEventLoopGroup.singleton\n        do {\n            let etcdClient = EtcdClient(host: \"localhost\", port: 2379, eventLoopGroup: eventLoopGroup)\n            try await withThrowingTaskGroup(of: Void.self) { group in\n                group.addTask {\n                    do {\n                        try await etcdClient.watch(\"foo\") { sequence in\n                            var iterator = sequence.makeAsyncIterator()\n                            while let event = try await iterator.next() {\n                                print(event)\n                            }\n                        }\n                    } catch {\n                        print(\"Error watching key: \\(error)\")\n                    }\n                }\n                // Sleeping for a second to let the watch above setup\n                try await Task.sleep(for: .seconds(1))\n                \n                try await etcdClient.set(\"foo\", value: \"bar\")\n                let key = \"foo\".data(using: .utf8)!\n                let rangeRequest = RangeRequest(key: key)\n                if let value = try await etcdClient.getRange(rangeRequest) {\n                    if let stringValue = String(data: value, encoding: .utf8) {\n                        print(\"Value is: \\(stringValue)\")\n                        let deleteRangeRequest = DeleteRangeRequest(key: key)\n                        try await etcdClient.deleteRange(deleteRangeRequest)\n                        print(\"Key deleted\")\n                        \n                        // Trying to get the value again\n                        let deletedValue = try await etcdClient.getRange(rangeRequest)\n                        if deletedValue == nil {\n                            print(\"Key not found after deletion\")\n                        } else {\n                            print(\"Value after deletion: \\(deletedValue!)\")\n                        }\n                    } else {\n                        print(\"Unable to get value\")\n                    }\n                } else {\n                    print(\"Key not found\")\n                }\n                try await Task.sleep(for: .seconds(2))\n                do {\n                    try await etcdClient.set(\"foo\", value: \"updated_value\")\n                } catch {\n                    print(\"Error setting updated value: \\(error)\")\n                }\n            }\n        } catch {\n            print(\"Error: \\(error)\")\n        }\n    }\n}\n\n```\n\n## Contributing\nTo contribute to this package, please look at [CONTRIBUTING.md](./CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswift-server%2Fswift-etcd-client-gsoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswift-server%2Fswift-etcd-client-gsoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswift-server%2Fswift-etcd-client-gsoc/lists"}