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

use .ref key value as a point to determine changes #77

Closed
123BLiN opened this issue Apr 27, 2016 · 1 comment
Closed

use .ref key value as a point to determine changes #77

123BLiN opened this issue Apr 27, 2016 · 1 comment

Comments

@123BLiN
Copy link

123BLiN commented Apr 27, 2016

Hello,

Thank you for this greate project!
Not an issue but strange question, we try to use KV as source for our nginx configuration, we use git2consul with expand_keys, all works like a charm, we use also custom script with long polling to consul KV to determine changes in KV branch (managed by git2consul) the problem is that when git2consul is starting to change KV after commit our script triggers on very first change and we get invalid nginx configuration, however after some seconds if I run it manually again - all is ok, because git2-consul has updated all needed keys. So the question is could I determine the moment when all changes done to query new proper configuration. I'm thinking of using .ref key that is created by git2consul in needed branch, but I wanted to clarify if it is updated after all changes are done?

Thanks!
Roman

@123BLiN
Copy link
Author

123BLiN commented Apr 28, 2016

Sorry I've found it here https://github.com/Cimpress-MCP/git2consul/blob/master/lib/consul/index.js

  // First, check to see what the current ref is for this branch.
  branch.getCurrentRef(function(err, ref) {
    /* istanbul ignore if */
    if (err) return cb("Failed to get current ref for branch " + branch.name + " due to " + err);

    /**
     * Given a set of records, process them and update the branch manager to the current ref if successful.
     */
    var handle_records = function(err, records) {
      /* istanbul ignore if */
      if (err) return cb(err);
      process_records(branch, records, function(errs) {
        if (errs) {
          return cb("Some consul updates failed:\n" + errs.join('\n'));
        }
        // Note: This is a bit dangerous.  We only update most recent ref if all consul writes are successful.
        // If there's a bug that causes a certain consul write to always fail, we will always create our diffs
        // from the ref before that file was added.
        exports.setLastProcessedRef(branch, ref, function(err) {
          return cb(err);
        });
      });
    };

Thanks! Closing.

@123BLiN 123BLiN closed this as completed Apr 28, 2016
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

No branches or pull requests

1 participant