Skip to content
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

Implement transaction builder #4

Merged
merged 5 commits into from
Apr 15, 2017
Merged

Implement transaction builder #4

merged 5 commits into from
Apr 15, 2017

Conversation

connor4312
Copy link
Member

This lets us do things such as distributed locks, like so:

function lock() {
  return client.if('my_lock', 'createdAt', '==', 0)
    .then(client.put('my_lock').value(id))
    .else(client.get('my_lock'))
    .commit()
    .then(result => console.log(result.succeeded === id ? 'lock acquired' : 'already locked'));
}

function unlock() {
  return client.if('my_lock', 'value', '==', 0)
    .then(client.delete().key('my_lock'))
    .commit();
}

@@ -48,6 +48,32 @@ const enum State {

/**
* Lease is a high-level manager for etcd leases.
* Leases are great for things like service discovery:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or make that @example

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea....

Copy link
Member Author

@connor4312 connor4312 Apr 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typedoc in general is disappointing, but there's no way I'm going to manually typedef all those RPC interfaces for esdoc.

@connor4312 connor4312 merged commit b7df085 into master Apr 15, 2017
@connor4312 connor4312 deleted the txn branch April 15, 2017 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants