<commit_before>etcd-lock
=========

For version 0.4.0 of etcd the module lock has been deprecated.

This is a basic client implementation of lock based on the logics in mod/lock

This library doesn't provide the `*etcd.Client` because it doesn't want to
manage the condfiguration of it (TLS or not, endpoints etc.) So a client has to
exist previously

```go
l, err := lock.Acquire(client, "/name", 60)
if lockErr, ok := err.(*lock.Error); ok {
  // Key already locked
  fmt.Println(lockErr)
  return
} else if err != nil {
  // Communication with etcd has failed or other error
  panic(err)
}

// It's ok, lock is granted for 60 secondes

// When the opration is done we release the lock
err = l.Release()
if err != nil {
  // Something wrong can happen during release: connection problem with etcd
  panic(err)
}
```<commit_msg>Add testing section in readme<commit_after>etcd-lock
=========

For version 0.4.0 of etcd the module lock has been deprecated.

This is a basic client implementation of lock based on the logics in mod/lock

This library doesn't provide the `*etcd.Client` because it doesn't want to
manage the condfiguration of it (TLS or not, endpoints etc.) So a client has to
exist previously

```go
l, err := lock.Acquire(client, "/name", 60)
if lockErr, ok := err.(*lock.Error); ok {
  // Key already locked
  fmt.Println(lockErr)
  return
} else if err != nil {
  // Communication with etcd has failed or other error
  panic(err)
}

// It's ok, lock is granted for 60 secondes

// When the opration is done we release the lock
err = l.Release()
if err != nil {
  // Something wrong can happen during release: connection problem with etcd
  panic(err)
}
```

Testing
-------

You need a etcd instance running on `localhost:4001`, then:

```
go test ./...
```
{'fraction_non_alphanumeric': 0.11098591549295775, 'fraction_numerical': 0.010140845070422535, 'mean_word_length': 3.577319587628866, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6010018', 'n_tokens_mistral': 567, 'n_tokens_neox': 532, 'n_words': 248}