Created
December 13, 2017 22:21
-
-
Save princesspretzel/cee58b0a426adbeb0b1d2ef5da5cbc17 to your computer and use it in GitHub Desktop.
/electric-moray/node_modules/moray/bin/batch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// -*- mode: js -*- | |
/* | |
* This Source Code Form is subject to the terms of the Mozilla Public | |
* License, v. 2.0. If a copy of the MPL was not distributed with this | |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
*/ | |
/* | |
* Copyright (c) 2017, Joyent, Inc. | |
*/ | |
var assert = require('assert-plus'); | |
var cmdutil = require('cmdutil'); | |
var moray = require('../lib'); | |
var moraycli = require('../lib/cmd'); | |
var uuid = require('node-uuid'); | |
var clientOptions, parser, client, requests; | |
var id = uuid.v4(); | |
cmdutil.configure({ | |
'usageMessage': 'update or delete batches of objects in Moray', | |
'synopses': [ moraycli.commonUsage + ' DATA' ] | |
}); | |
clientOptions = {}; | |
values = {}; | |
parser = moraycli.parseCliOptions({ | |
'argv': process.argv, | |
'env': process.env, | |
'errstream': process.stderr, | |
'extraOptStr': '', | |
'clientOptions': clientOptions, | |
'onUsage': cmdutil.usage | |
}); | |
requests = JSON.parse(process.argv[2]); | |
assert.arrayOfObject(requests, 'requests'); | |
client = moray.createClient(clientOptions); | |
client.on('error', cmdutil.fail); | |
client.on('connect', function onConnect() { | |
client.batch(requests, {req_id: id}, function callback(err) { | |
if (err) { | |
cmdutil.fail(err); | |
} | |
client.close(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment