Skip to content
This repository was archived by the owner on Feb 6, 2019. It is now read-only.

Conversation

@ducdigital
Copy link

  • Add support for all compare ops
    • CompareValue
    • CompareLastRevision
    • CompareCreated
    • CompareVersion
  • Add support for all success/failure request
    • DeleteRangeRequest
    • RangeRequest
    • PutRequest

Example usage:

  let compareOps = [
    new CompareValue(
      CompareTypeDef.CompareResult.EQUAL,
      new Buffer('key-to-compare'),
      new Buffer('key-to-compare')
    )
  ];
  let successOps = [
    new PutRequest({
      key: new Buffer('put-if-true-key'),
      value: new Buffer('put-if-true-value'),
      lease: 0,
    })
  ];
  let failureOps = [
    new PutRequest({
      key: new Buffer('put-if-fail-key1'),
      value: new Buffer('put-if-fail-value1'),
      lease: 0,
    }),
    new PutRequest({
      key: new Buffer('put-if-fail-key2'),
      value: new Buffer('put-if-fail-value2'),
      lease: 0,
    })
  ];

  etcd.createTransaction(compareOps, successOps, failureOps).then(data => {
    console.log(data);
  });

PS: This is experimental just to kick start the idea. It works but the code is not as clean as the original code base. Might need some refactoring work.

@CitySim
Copy link
Owner

CitySim commented Mar 7, 2017

hi,
thanks for the pull request! 👍
I'll make sure to check it out this week

The problem with etcd proto is that if we use it's class in an OOP way
it does not really work.
Add Lock functionality
Fix problem of transaction cause of using nested classes of proto object. it does not really work
@ducdigital ducdigital changed the title Add support for KV.txn Add support for KV.txn and add a Lock class Mar 7, 2017
@ducdigital
Copy link
Author

Hey there I just update the Transaction class and add a Lock class. Lock class is "almost" direct implementation of the Python's version.

I also update Transaction class to fix the problem cause by nested proto class object (It does not really work that way and I am not sure why).

As soon as I change everything to a normal object It work very well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants