New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cocaine

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cocaine - npm Package Compare versions

Comparing version 0.3.1-22 to 0.4.0-6

lib/channel/channel.js

25

lib/client/base_service.js
var __assert = require('assert')
var channel_binding = require('bindings')('nodejs_cocaine_framework').communicator
var channel_binding = require('../channel/channel').Channel
var _ = require('../errno'), ERRNO = _.errno, _ERRNO = _.code

@@ -18,2 +18,5 @@ var FSM = require('../fsm')

methods:{
__init__: function(){
this._sessions = {}
},
_send: function(message){

@@ -52,21 +55,7 @@ var buf = mp.pack(message)

__assert(typeof endpoint[0] === 'string' && typeof endpoint[1] === 'number', "endpoint is ['host|ip', port]")
try{
var channelHandle = new channel_binding(endpoint[0], endpoint[1])
} catch (e){
if(typeof e === 'number'){
e = new Error(_ERRNO[e])
}
throw e
}
var channelHandle = new channel_binding(endpoint[0], endpoint[1])
this._setHandle(channelHandle)
} else {
__assert(typeof endpoint === 'string', "assume endpoint is a string path to unix socket")
try{
var channelHandle = new channel_binding(endpoint)
} catch(e){
if(typeof e === 'number'){
e = new Error(_ERRNO[e])
}
throw e
}
__assert(typeof endpoint === 'string', "assume endpoint is a string path to a unix socket")
var channelHandle = new channel_binding(endpoint)
this._setHandle(channelHandle)

@@ -73,0 +62,0 @@ }

@@ -164,4 +164,6 @@

close: function(){
var e = new Error('Locator client closed')
e.code = 'ECONNRESET'
this._close()
this._resetRequests()
this._resetRequests(e)
},

@@ -186,3 +188,3 @@

this._locator.removeListener('error', this._handlers.connectError)
this._locator.on('error', this._handlers.socketError)
this._locator.once('error', this._handlers.socketError)

@@ -195,4 +197,5 @@ Object.keys(this._requests).forEach(this._resolve, this)

this._locator.removeListener('connect', this._handlers.connect)
this.emit('error', ['connect', err])
var h = this.getErrorHandler() || ['failConnect', [err]]
err.condition = 'connect'
this.emit('error', err)
var h = this.getErrorHandler() || ['fail', [err]]
this._handlers[h[0]].apply(this, h[1])

@@ -206,2 +209,3 @@ },

retryConnect: function(timeout){
console.log('retryConnect: function(timeout){')
this._close()

@@ -211,3 +215,3 @@ setTimeout(this._handlers._doConnect,timeout)

failConnect: function(err){
fail: function(err){
this._close()

@@ -218,11 +222,15 @@ this._resetRequests(err)

socketError: function(err){
this.emit('error', ['socket', err])
var h = this.getErrorHandler() || ['failConnect', [err]]
err.condition = 'socket'
this.emit('error', err)
var h = this.getErrorHandler() || ['fail', [err]]
this._handlers[h[0]].apply(this, h[1])
},
reconnect: function(timeout){
reconnect: function(timeout, err){
console.log('reconnect: function(timeout, err){')
this._close()
this._resetRequests(err)
console.log('setTimeout(this._handlers._doConnect, timeout)', timeout)
setTimeout(this._handlers._doConnect, timeout)
}

@@ -233,5 +241,7 @@ },

__assert(this._state !== 'closed', "this._state !== 'closed'")
this._state = 'closed'
if(this._locator._state !== 'closed'){
this._locator.close()
if(this._state !== 'closed'){
this._state = 'closed'
if(this._locator._state !== 'closed'){
this._locator.close()
}
}

@@ -238,0 +248,0 @@ },

@@ -28,3 +28,3 @@

if(VL.debug <= level){
console.log(message)
process.stderr.write(message+'\n')
}

@@ -31,0 +31,0 @@ }

@@ -15,3 +15,3 @@

function Session(id, cb){
function Session(id, cb, methodId, methodName){
var _this = this

@@ -21,3 +21,4 @@ this._cb = cb

this._owner = null
this._methodId = undefined
this._methodId = methodId
this._methodName = methodName
this._args = null

@@ -71,3 +72,3 @@ this._done = false

if(typeof this._cb === 'function'){
var err = new Error(util.format('%s\n in service %s method %s\n args: %s\n', message, owner._name, this._methodId, util.inspect(this._args)))
var err = new Error(util.format('<Service %s>.%s error: "%s" args: %s', owner._name, this._methodName, message, util.inspect(this._args)))
err.code = code

@@ -80,5 +81,5 @@ this._cb(err)

module.exports.unpackWith = function(unpacker){
return function(mid){
return function(methodId, methodName){
return function(){
trace && console.log('================ unpackWith, calling method %s', mid)
trace && console.log('================ unpackWith, calling method [%s]<%s>', methodId, methodName)
__assert(this._state === 'connected')

@@ -91,11 +92,10 @@ var args = slice.call(arguments)

args.pop()
var S = new Session(sid, cb)
var S = new Session(sid, cb, methodId, methodName)
S._unpacker = unpacker
S._owner = this
S._args = args
S._methodId = mid
this._sessions[sid] = S
}
}
this.send([mid, sid, args])
this.send([methodId, sid, args])
}

@@ -105,5 +105,5 @@ }

module.exports.unpacking = function(mid){
module.exports.unpacking = function(methodId, methodName){
return function(){
trace && console.log('================ unpacking, calling method %s', mid)
trace && console.log('================ unpackWith, calling method [%s]<%s>', methodId, methodName)
__assert(this._state === 'connected')

@@ -116,10 +116,9 @@ var args = slice.call(arguments)

args.pop()
var S = new Session(sid, cb)
var S = new Session(sid, cb, methodId, methodName)
S._owner = this
S._args = args
S._methodId = mid
this._sessions[sid] = S
}
}
this.send([mid, sid, args])
this.send([methodId, sid, args])
}

@@ -126,0 +125,0 @@ }

@@ -17,3 +17,3 @@

function Session(id, fiber){
function Session(id, fiber, methodId, methodName){
__assert(typeof id === 'number', 'no id passed to session')

@@ -24,3 +24,4 @@ __assert(fiber, 'no fiber passed to session')

this._owner = null
this._methodId = undefined
this._methodId = methodId
this._methodName = methodName
this._args = null

@@ -66,3 +67,3 @@ this._done = false

clearTimeout(this._callTimer)
var err = new Error(util.format('%s\n in service %s method %s\n args: %s\n', message, owner._name, this._methodId, util.inspect(this._args)))
var err = new Error(util.format('<Service %s>.%s error: "%s" args: %s', owner._name, this._methodName, message, util.inspect(this._args)))
err.code = code

@@ -75,13 +76,12 @@ this.fiber.thowInto(err)

unpackWith: function(unpacker){
return function(mid){
return function(methodId, methodName){
return function(){
var args = slice.call(arguments)
var sid = this.__sid++
var S = new Session(sid, Fiber.current)
var S = new Session(sid, Fiber.current, methodId, methodName)
S._unpacker = unpacker
S._owner = this
S._methodId = mid
S._args = args
this._sessions[S._id] = S
this._send([mid, S._id, args])
this._send([methodId, S._id, args])
return Fiber.yield()

@@ -91,12 +91,11 @@ }

},
unpacking: function(mid){
unpacking: function(methodId, methodName){
return function(){
var args = slice.call(arguments)
var sid = this.__sid++
var S = new Session(sid, Fiber.current)
var S = new Session(sid, Fiber.current, methodId, methodName)
S._owner = this
S._methodId = mid
S._args = args
this._sessions[S._id] = S
this._send([mid, S._id, args])
this._send([methodId, S._id, args])
return Fiber.yield()

@@ -103,0 +102,0 @@ }

@@ -17,3 +17,3 @@

function Session(id, deferred){
function Session(id, deferred, methodId, methodName){
__assert(typeof id === 'number', 'no id passed to session')

@@ -29,3 +29,4 @@ __assert(deferred, 'no deferred passed to session')

this._owner = null
this._methodId = undefined
this._methodId = methodId
this._methodName = methodName
var _this = this

@@ -66,3 +67,3 @@ this._timeoutHandler = function(){

clearTimeout(this._callTimer)
var err = new Error(util.format('%s\n in service %s method %s\n args: %s\n', message, owner._name, this._methodId, util.inspect(this._args)))
var err = new Error(util.format('<Service %s>.%s error: "%s" args: %s', owner._name, this._methodName, message, util.inspect(this._args)))
err.code = code

@@ -75,15 +76,14 @@ Promise.reject(this.deferred, err)

unpackWith: function(unpacker){
return function(mid){
return function(methodId, methodName){
return function(){
trace && console.log('================ unpackWith, calling method %s of service %s', mid, this._name)
trace && console.log('================ unpackWith, calling method %s of service %s', methodId, this._name)
var args = slice.call(arguments)
var d = Promise.defer()
var sid = this.__sid++
var S = new Session(sid, d)
var S = new Session(sid, d, methodId, methodName)
S._unpacker = unpacker
S._args = args
S._owner = this
S._methodId = mid
this._sessions[S._id] = S
this.send([mid, S._id, args])
this.send([methodId, S._id, args])
return Promise.promise(S.deferred)

@@ -93,14 +93,13 @@ }

},
unpacking: function(mid){
unpacking: function(methodId, methodName){
return function(){
trace && console.log('================ unpackWith, calling method %s of service %s', mid, this._name)
trace && console.log('================ unpackWith, calling method %s of service %s', methodId, this._name)
var args = slice.call(arguments)
var d = Promise.defer()
var sid = this.__sid++
var S = new Session(sid, d)
var S = new Session(sid, d, methodId, methodName)
S._args = args
S._owner = this
S._methodId = mid
this._sessions[S._id] = S
var msg = [mid, S._id, args]
var msg = [methodId, S._id, args]
this.send(msg)

@@ -107,0 +106,0 @@ return Promise.promise(S.deferred)

@@ -16,8 +16,10 @@

function ClientSession(id){
function ClientSession(sid, methodId, methodName){
Session.apply(this)
var _this = this
this._id = id
this._id = sid
this._done = false
this._callTimer = 0
this._methodId = methodId
this._methodName = methodName
this._timeoutHandler = function(){

@@ -41,14 +43,28 @@ __assert(!_this._done)

this.push(chunk)
},
pushChoke: function(){
var r = Session.apply(this, arguments)
this._owner = null
return r
},
pushError: function(code, message){
var owner = this._owner
this._owner = null
var err = new Error(util.format('<Service %s>.%s error: "%s" args: %s', owner._name, this._methodName, message, util.inspect(this._args)))
err.code = code
this.emit('error', err)
this.close()
}
}
module.exports = function(mid){
module.exports = function(methodId, methodName){
return function(){
trace && console.log('================ calling method %s', mid)
trace && console.log('================ calling method %s, id %s', methodName, methodId)
__assert(this._state === 'connected')
var args = slice.call(arguments)
var sid = this.__sid++
var S = new ClientSession(sid)
var S = new ClientSession(sid, methodId, methodName)
S._owner = this
this._sessions[S._id] = S
this.send([mid, sid, args])
this.send([methodId, sid, args])
return S

@@ -55,0 +71,0 @@ }

@@ -31,3 +31,4 @@

var proto = bakeServiceProto(name, result, def)
proto.__proto__ = BaseService.prototype,
proto.connect = serviceConnect
proto.__proto__ = BaseService.prototype

@@ -40,3 +41,2 @@ Client.prototype = proto

BaseService.apply(this, arguments)
this._sessions = {}
}

@@ -88,3 +88,3 @@

var M = ((_ = def.methods) && _[methodName]) || def.defaultMethod
proto[methodName] = M(mid)
proto[methodName] = M(mid, methodName)
}

@@ -115,3 +115,2 @@

BaseService.apply(this, arguments)
this._sessions = {}
this._lookingup = false

@@ -126,3 +125,3 @@ this._client = null

_name: name,
connect: serviceConnect
connect: serviceResolveConnect
}

@@ -144,9 +143,55 @@

this._lookingup = true
__assert(this._endpoint, 'this._endpoint')
_checkIP()
function _checkIP(){
trace && console.log('_checkIP', _this._endpoint)
if(Array.isArray(_this._endpoint) && !isIP(_this._endpoint[0])){
trace && console.log('not ip:', _this._endpoint[0])
dns.lookup(_this._endpoint[0], _lookupDone)
} else {
_connect()
}
}
function _lookupDone(err, address, family){
trace && console.log('_lookupDone', arguments)
if(err) return _handleError(err)
_this._endpoint[0] = address
_connect()
}
function _handleError(err){
trace && console.log('_handleError', arguments)
if(!done){
done = true
this._lookingup = false
_this.emit('error', err)
} else {
trace && console.log('_handleError called after done', arguments)
}
}
if(!this._endpoint){
_resolve()
} else {
_checkIP()
function _connect(){
trace && console.log('_connect')
if(!done){
done = true
_this._lookingup = false
baseServiceConnect.call(_this, _this._endpoint)
} else {
trace && console.log('_connect called after done')
}
}
}
function serviceResolveConnect(){
var _this = this
var done = false
if(this._lookingup) return
this._lookingup = true
_resolve()
function _resolve(){

@@ -153,0 +198,0 @@ trace && console.log('_resolve', _this._name, _this._endpoint)

@@ -27,3 +27,3 @@

pushChunk:function(chunk){
__assert(Buffer.isBuffer(chunk))
__assert(Buffer.isBuffer(chunk), 'Buffer.isBuffer(chunk)')
this.push(chunk)

@@ -30,0 +30,0 @@ },

var _ERRNO = require('./errno').code
var format = require('util').format

@@ -27,4 +28,15 @@

}
},
debug:function(subsys){
var re = new RegExp(subsys)
if(process.env.NODE_DEBUG && re.test(process.env.NODE_DEBUG)){
return function(){
var entry = format.apply(null, arguments)
console.log('%s:', subsys, entry)
}
} else {
return function(){}
}
}
}

@@ -15,4 +15,3 @@

// FIXME: such a bizarre naming is a source of confusion and misunderstanding
var channel_binding = require('bindings')('nodejs_cocaine_framework').communicator
var channel_binding = require('../channel/channel').Channel

@@ -19,0 +18,0 @@ var trace = 0

{
"name": "cocaine",
"version": "0.2.9-0",
"version": "0.4.0-alpha0",
"dependencies": {
"bindings": {
"version": "1.0.0",
"from": "https://registry.npmjs.org/bindings/-/bindings-1.0.0.tgz",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.0.0.tgz"
},
"hexy": {
"version": "0.2.6",
"from": "hexy@",
"resolved": "https://registry.npmjs.org/hexy/-/hexy-0.2.6.tgz"
},
"jampack": {
"version": "0.0.7",
"from": "jampack@0.0.7",
"resolved": "https://registry.npmjs.org/jampack/-/jampack-0.0.7.tgz"
},
"msgpack": {
"version": "0.1.11",
"from": "msgpack@0.1.11",
"from": "https://registry.npmjs.org/msgpack/-/msgpack-0.1.11.tgz",
"resolved": "https://registry.npmjs.org/msgpack/-/msgpack-0.1.11.tgz",

@@ -17,3 +32,3 @@ "dependencies": {

"version": "0.4.4",
"from": "tap@0.4.4",
"from": "https://registry.npmjs.org/tap/-/tap-0.4.4.tgz",
"resolved": "https://registry.npmjs.org/tap/-/tap-0.4.4.tgz",

@@ -33,3 +48,4 @@ "dependencies": {

"version": "1.1.5",
"from": "slide@1.1.5"
"from": "slide@1.1.5",
"resolved": "https://registry.npmjs.org/slide/-/slide-1.1.5.tgz"
},

@@ -39,2 +55,3 @@ "runforcover": {

"from": "runforcover@0.0.2",
"resolved": "https://registry.npmjs.org/runforcover/-/runforcover-0.0.2.tgz",
"dependencies": {

@@ -44,2 +61,3 @@ "bunker": {

"from": "bunker@0.1.2",
"resolved": "https://registry.npmjs.org/bunker/-/bunker-0.1.2.tgz",
"dependencies": {

@@ -49,6 +67,7 @@ "burrito": {

"from": "burrito@0.2.12",
"resolved": "https://registry.npmjs.org/burrito/-/burrito-0.2.12.tgz",
"dependencies": {
"traverse": {
"version": "0.5.2",
"from": "traverse@0.5.2",
"from": "https://registry.npmjs.org/traverse/-/traverse-0.5.2.tgz",
"resolved": "https://registry.npmjs.org/traverse/-/traverse-0.5.2.tgz"

@@ -58,3 +77,4 @@ },

"version": "1.1.1",
"from": "uglify-js@1.1.1"
"from": "uglify-js@1.1.1",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-1.1.1.tgz"
}

@@ -70,6 +90,8 @@ }

"from": "nopt@2.1.2",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-2.1.2.tgz",
"dependencies": {
"abbrev": {
"version": "1.0.4",
"from": "abbrev@1.0.4"
"from": "abbrev@1.0.4",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz"
}

@@ -80,3 +102,4 @@ }

"version": "0.3.5",
"from": "mkdirp@0.3.5"
"from": "mkdirp@0.3.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz"
},

@@ -86,6 +109,7 @@ "difflet": {

"from": "difflet@0.2.6",
"resolved": "https://registry.npmjs.org/difflet/-/difflet-0.2.6.tgz",
"dependencies": {
"traverse": {
"version": "0.6.3",
"from": "traverse@0.6.3",
"from": "https://registry.npmjs.org/traverse/-/traverse-0.6.3.tgz",
"resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.3.tgz"

@@ -95,7 +119,9 @@ },

"version": "0.1.2",
"from": "charm@0.1.2"
"from": "charm@0.1.2",
"resolved": "https://registry.npmjs.org/charm/-/charm-0.1.2.tgz"
},
"deep-is": {
"version": "0.1.2",
"from": "deep-is@0.1.2"
"from": "deep-is@0.1.2",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.2.tgz"
}

@@ -106,11 +132,13 @@ }

"version": "0.0.0",
"from": "deep-equal@0.0.0"
"from": "deep-equal@0.0.0",
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.0.0.tgz"
},
"buffer-equal": {
"version": "0.0.0",
"from": "buffer-equal@0.0.0"
"from": "buffer-equal@0.0.0",
"resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-0.0.0.tgz"
},
"glob": {
"version": "3.2.6",
"from": "glob@3.2.6",
"from": "https://registry.npmjs.org/glob/-/glob-3.2.6.tgz",
"resolved": "https://registry.npmjs.org/glob/-/glob-3.2.6.tgz",

@@ -121,10 +149,13 @@ "dependencies": {

"from": "minimatch@0.2.12",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.12.tgz",
"dependencies": {
"lru-cache": {
"version": "2.3.1",
"from": "lru-cache@2.3.1"
"from": "lru-cache@2.3.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.3.1.tgz"
},
"sigmund": {
"version": "1.0.0",
"from": "sigmund@1.0.0"
"from": "sigmund@1.0.0",
"resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.0.tgz"
}

@@ -135,3 +166,4 @@ }

"version": "2.0.1",
"from": "inherits@2.0.1"
"from": "inherits@2.0.1",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
}

@@ -141,2 +173,28 @@ }

}
},
"qbox": {
"version": "0.1.7"
},
"should": {
"version": "0.5.1"
},
"tap-assert": {
"version": "0.0.10"
},
"uglify-js": {
"version": "1.1.1"
},
"tap-producer": {
"version": "0.0.1",
"dependencies": {
"inherits": {
"version": "1.0.0"
},
"tap-results": {
"version": "0.0.2"
},
"yamlish": {
"version": "0.0.2"
}
}
}

@@ -147,10 +205,5 @@ }

},
"bindings": {
"version": "1.0.0",
"from": "bindings@1.0.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.0.0.tgz"
},
"optimist": {
"version": "0.4.0",
"from": "optimist@0.4.0",
"from": "https://registry.npmjs.org/optimist/-/optimist-0.4.0.tgz",
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.4.0.tgz",

@@ -160,3 +213,4 @@ "dependencies": {

"version": "0.0.2",
"from": "wordwrap@0.0.2"
"from": "wordwrap@0.0.2",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz"
}

@@ -167,10 +221,6 @@ }

"version": "0.9.6",
"from": "q@0.9.6",
"from": "https://registry.npmjs.org/q/-/q-0.9.6.tgz",
"resolved": "https://registry.npmjs.org/q/-/q-0.9.6.tgz"
},
"jampack": {
"version": "0.0.7",
"from": "jampack@0.0.7"
}
}
}
{
"name": "cocaine",
"version": "0.3.1-22",
"version": "0.4.0-6",
"description": "Node.js framework for Cocaine platform",
"author": "Cocaine Project <cocaine@yandex-team.ru>",
"contributors":[
"contributors": [
"Oleg Kutkov <olegkutkov@yandex-team.ru>",

@@ -17,11 +16,14 @@ "Dmitry Unkovsky <diunko@yandex-team.ru>"

"dependencies": {
"bindings": "~1.0.0",
"hexy": "^0.2.6",
"jampack": "0.0.7",
"msgpack": "~0.1.7",
"bindings": "~1.0.0",
"optimist": "~0.4",
"q":"~0.9",
"jampack":"0.0.7"
"q": "~0.9"
},
"devDependencies": {
"mocha":"1.20.x",
"msgpack-buf": "0.1.8",
"node-uuid":"1.4.x"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc