|
| 1 | +# swift-etcd-client-gsoc |
| 2 | + |
| 3 | +A Swift package for interacting with etcd, providing client functionalities such as setting, getting, deleting key-value pairs, and watching keys. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This package includes the following key components: |
| 8 | + |
| 9 | +- **EtcdClient:** A client for interacting with an etcd server. |
| 10 | +- **KeyValue:** A struct representing a key-value pair in the etcd server. |
| 11 | +- **RangeRequest:** A struct for fetching a range of key-value pairs from the etcd server. |
| 12 | +- **DeleteRangeRequest:** A struct for deleting a range of key-value pairs from the etcd server. |
| 13 | +- **WatchAsyncSequence:** A struct for handling asynchronous sequences of watch events. |
| 14 | +- **WatchEvent:** A struct representing an event in the etcd watch mechanism. |
| 15 | + |
| 16 | +## Components |
| 17 | + |
| 18 | +### EtcdClient |
| 19 | + |
| 20 | +`EtcdClient` is the primary interface for interacting with the etcd server. It allows you to set, get, delete, and watch key-value pairs. |
| 21 | + |
| 22 | +#### Initialization |
| 23 | + |
| 24 | +```swift |
| 25 | +public init(host: String, port: Int, eventLoopGroup: EventLoopGroup) |
| 26 | +``` |
| 27 | +* host The host address of the etcd server. |
| 28 | +* port: The port number of the etcd server. |
| 29 | +* eventLoopGroup: The event loop group to use for this connection. |
| 30 | + |
| 31 | +#### Methods |
| 32 | +* set(_:value:) - Sets a value for a specified key. |
| 33 | +* getRange(_:) - Fetches a range from the etcd server. |
| 34 | +* deleteRange(_:) - Deletes the value for a range from the etcd server. |
| 35 | +* put(_:value:) - Puts a value for a specified key, creating a new key-value pair if it doesn't exist. |
| 36 | +* watch(::): - Watches a specified key for changes. |
| 37 | + |
| 38 | +### KeyValue |
| 39 | + |
| 40 | +`KeyValue` represents a key-value pair in the etcd server. |
| 41 | + |
| 42 | +#### Initialization |
| 43 | + |
| 44 | +```swift |
| 45 | +public init(key: Data, createRevision: Int, modRevision: Int, version: Int, value: Data, lease: Int) |
| 46 | +``` |
| 47 | +* key: The key in bytes. |
| 48 | +* createRevision: Revision of the last creation on the key. |
| 49 | +* modRevision: Revision of the last modification on the key. |
| 50 | +* version: The version of the key. |
| 51 | +* value: The value in bytes. |
| 52 | +* lease: The ID of the lease attached to the key. |
| 53 | + |
| 54 | + |
| 55 | +### RangeRequest |
| 56 | + |
| 57 | +`RangeRequest` is used to fetch a range of key-value pairs from the etcd server. |
| 58 | + |
| 59 | +#### Initialization |
| 60 | + |
| 61 | +```swift |
| 62 | +public init(key: Data, rangeEnd: Data? = nil) |
| 63 | +``` |
| 64 | +* key: The key to start the range fetch. |
| 65 | +* rangeEnd: The key to end the range fetch. |
| 66 | + |
| 67 | + |
| 68 | +### DeleteRangeRequest |
| 69 | + |
| 70 | +`DeleteRangeRequest` is used to delete a range of key-value pairs from the etcd server. |
| 71 | + |
| 72 | +#### Initialization |
| 73 | + |
| 74 | +```swift |
| 75 | +public init(key: Data, rangeEnd: Data? = nil, prevKV: Bool = false) |
| 76 | +``` |
| 77 | +* key: The key of the range to delete. |
| 78 | +* rangeEnd: The key to end the range deletion. |
| 79 | +* prevKV: When set, return the contents of the deleted key-value pairs. |
| 80 | + |
| 81 | +### WatchAsyncSequence |
| 82 | + |
| 83 | +`WatchAsyncSequence` handles asynchronous sequences of watch events from the etcd server. |
| 84 | + |
| 85 | +### WatchEvent |
| 86 | + |
| 87 | +`WatchEvent` represents an event in the etcd watch mechanism. |
| 88 | + |
| 89 | +```swift |
| 90 | +public init(keyValue: KeyValue, previousKeyValue: KeyValue?) |
| 91 | +``` |
| 92 | +* keyValue: The current key-value pair associated with the event. |
| 93 | +* previousKeyValue: The previous key-value pair before the event occurred. |
0 commit comments