-
Notifications
You must be signed in to change notification settings - Fork 340
docs: add prerequisites, examples, and release info to locks tutorial #1121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,17 +9,39 @@ LOCK acquires a distributed mutex with a given name. Once the lock is acquired, | |
| ## Prerequisites | ||
|
|
||
| * Install [`etcd` and `etcdctl`](https://etcd.io/docs/v3.6/install/) | ||
| * A running etcd cluster (see [How to Set Up a Demo etcd Cluster](/docs/v3.6/tasks/operator/how-to-setup-cluster/)) | ||
|
|
||
| ## Creating a lock | ||
|
|
||
| `lock` for distributed lock: | ||
| Acquire a lock with a specified name: | ||
| ```shell | ||
| etcdctl --endpoints=$ENDPOINTS lock mutex1 | ||
| ``` | ||
|
|
||
|  | ||
| The lock will be held until the command is terminated with `Ctrl+C`. | ||
|
|
||
| ### Lock with command execution | ||
|
|
||
| You can also execute a command while holding the lock: | ||
| ```shell | ||
| etcdctl --endpoints=$ENDPOINTS lock mutex1 | ||
| etcdctl --endpoints=$ENDPOINTS lock mutex1 echo "Lock acquired" | ||
|
Comment on lines
-20
to
+27
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey, this example is wrong, because the original tutorial is wrong. For this form of the lock, you need to actually send etcd a command, like updating a key. |
||
| ``` | ||
|
|
||
| ### Options | ||
| - endpoints - defines a comma-delimited list of machine addresses in the cluster. | ||
| - ttl - time out in seconds of lock session. | ||
| When using this form, the lock is automatically released after the command completes. | ||
|
|
||
| ### Visual demonstration | ||
|
|
||
|  | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general, we don't recommend using GIF formats due to issues with maintainability, large file sizes, and lack of accessibility. Could you please consider explaining the guidance thoroughly in the written content first, and removing the GIF from this section? |
||
|
|
||
| ## Options | ||
|
|
||
| - `--endpoints` - Comma-delimited list of etcd cluster endpoints (default: `http://127.0.0.1:2379`) | ||
| - `--ttl` - Time to live in seconds for the lock session (default: 60) | ||
|
|
||
| ## Releasing a lock | ||
|
|
||
| Locks are released in the following ways: | ||
|
|
||
| - **Manual release**: Press `Ctrl+C` to terminate the etcdctl lock command | ||
| - **Automatic release**: When executing a command with the lock, it is released after the command completes | ||
| - **TTL expiration**: The lock automatically expires after the TTL period if not renewed | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see more here for setup. For example, the user will need to have multiple, separate shell sessions with etcdctl clients in order to try this out.