Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guidesmiths/worksmith_etcd
Etcd activites for worksmith
https://github.com/guidesmiths/worksmith_etcd
hacktoberfest
Last synced: 22 days ago
JSON representation
Etcd activites for worksmith
- Host: GitHub
- URL: https://github.com/guidesmiths/worksmith_etcd
- Owner: guidesmiths
- License: mit
- Created: 2015-05-26T21:50:30.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-11-27T15:01:19.000Z (about 1 year ago)
- Last Synced: 2024-12-18T09:45:26.545Z (29 days ago)
- Topics: hacktoberfest
- Language: JavaScript
- Size: 29.3 KB
- Stars: 0
- Watchers: 12
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# worksmith_etcd
Etcd activities for [worksmith](http://npmjs.com/package/worksmith)
This package contains the following activities/tasks:
name | description
--- | ---
[createClient](#createClient-activity) | Creates an etcd client
[lock](#lock-activity) | Creates a distributed lock using etcd
[unlock](#unlock-activity) | Releases a distributed lock created with the lock activity### createClient activity
Creates an etcd client
##### params
name | type | description
--- | --- | ---
hosts | array | Array of hosts##### example
```javascript
var worksmith = require('worksmith')
worksmith.use('etcd', require('worksmith_etcd'))
var workflow = worksmith({task:"sequence", items : [{
task:'etcd/createClient',
hosts: ['localhost:4001']
resultTo: 'etcd'
}])
```### lock activity
Creates a distributed lock using etcd
##### params
name | type | description
--- | --- | ---
etcd | etcd client | The etcd client (if not specified expected to be in the context 'etcd' property)
key | string | The etcd key to be used in the lock
value | string | Optional value for the lock, defaults to a uuid
ttl | integer | Optional time in secords before the lock automatically expires##### example
```javascript
var worksmith = require('worksmith')
worksmith.use('etcd', require('worksmith_etcd'))
var workflow = worksmith({task:"sequence", items : [{
task:'etcd/createClient',
hosts: ['localhost:4001']
resultTo: 'etcd'
}, {
task:"etcd/lock",
key:"record_12345"
resultTo: "lock.value"
}])
```### unlock activity
Releases a distributed lock created with the lock activity##### params
name | type | description
--- | --- | ---
etcd | etcd client | The etcd client (if not specified expected to be in the context 'etcd' property)
key | string | The etcd key to be used in the lock
value | string | Optional value for the lock. If specified both the key and lock must match##### example
```javascript
var worksmith = require('worksmith')
worksmith.use('etcd', require('worksmith_etcd'))
var workflow = worksmith({task:"sequence", items : [{
task:'etcd/createClient',
hosts: ['localhost:4001']
resultTo: 'etcd'
}, {
task:"etcd/unlock",
key:"record_12345"
}])
```### Running tests
You need an etcd server running on localhost:4001 for the tests to pass. If you have docker and docker-compose installed simply run ```docker-compose up``` in the route of this project, however watch out for [this bug](https://github.com/docker/compose/issues/919).