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.12.0-alpha3 to 0.12.1-r01

benchmark/memcp.js

1

index.js

@@ -27,1 +27,2 @@

exports.compat = require('./lib/compat')

145

lib/channel/channel.js

@@ -9,4 +9,7 @@

var util = require('../util')
var inspect = require("util").inspect
var _ = require('util')
var fmt = _.format
var inspect = _.inspect
var _mp = require('./mp')

@@ -18,3 +21,3 @@ var unpackMessage = _mp.unpackMessage

var debug = require('../util').debug('co:channel')
var debug = require('debug')('co:channel')

@@ -66,2 +69,3 @@ function notImplemented(){

send: function(buf){
debug('send', buf)
__assert(this._socket && Buffer.isBuffer(buf), 'this._socket && Buffer.isBuffer(buf)')

@@ -72,7 +76,10 @@ this._socket.write(buf)

sendTerminate: function(sid, code, message){
__assert(arguments.length === 3
&& typeof sid === 'number'
&& typeof code === 'number'
&& typeof message === 'string',
"arguments.length === 3 && typeof sid === 'number' && typeof code === 'number' && typeof message === 'string'")
debug('sendTerminate', sid, code, message)
var t = true
__assert(t = (arguments.length === 3
&& typeof sid === 1
&& typeof code === 'number'
&& typeof message === 'string'),
t || fmt("arguments.length`%s` === 3 && sid`%s` === 1 && typeof code`%s` === 'number' && typeof message`%s` === 'string'",
arguments.length, sid, code, message))
this._socket.send(mp.pack([sid, this._RPC.terminate, [code, message]]))

@@ -82,2 +89,3 @@ },

close: function(){
debug('close')
if(this._socket){

@@ -120,4 +128,8 @@ this._socket.end()

_destroySocket: function(){
debug('_destroySocket',(new Error('sample')).stack)
if(this._socket){
var s = this._socket
if(0 < s.bufferSize){
debug('destroying socket with non-sent data')
}
this._socket = null

@@ -175,3 +187,4 @@ s.removeListener('connect', this._hdl.connect)

debug('channel.hdl.message', m)
if(!(typeof m === 'object' && m.length === 3)){
if(!(typeof m === 'object' && typeof m.length === 'number'
&& m.length <= 3)){
debug('RPC message is not a tuple', m)

@@ -189,6 +202,24 @@ this._hdl.error({code: 'EBADMSG'})

}
switch(mid){
var owner = this.owner
if(!owner){
debug('discarding message `%s` on channel with no owner', m)
return false
}
case this._RPC.heartbeat: {
if(owner.__sid < sid){
owner.__sid = sid
debug('case this._RPC.invoke')
var event = args[0]
if(!(typeof event === 'string',
"typeof event === 'string'")){
debug('bad RPC.invoke message')
} else {
this.on_invoke(sid, event)
}
} else if (sid === 1) {
// system session
if(mid === 0){
// heartbeat
debug('case this._RPC.heartbeat')

@@ -200,18 +231,17 @@ if(!(args.length === 0)){

}
break
}
case this._RPC.invoke: {
debug('case this._RPC.invoke')
var event = args[0]
if(!(typeof event === 'string',
"typeof event === 'string'")){
debug('bad RPC.invoke message')
} else if (mid === 1){
// terminate
debug('case this._RPC.terminate')
var code = args[0], reason = args[1]
if(!(typeof code === 'number' && typeof reason === 'string')){
debug('bad RPC.terminate message', m)
} else {
this.on_invoke(sid, event)
this.on_terminate(code, reason)
}
break
}
case this._RPC.chunk: {
} else if (sid <= owner.__sid){
if(mid === 0){
// write
debug('case this._RPC.chunk')

@@ -224,6 +254,19 @@ var buf = args[0]

}
break
}
case this._RPC.choke: {
} else if (mid === 1){
// error
debug('case this._RPC.error')
var error = args[0], message = args[1]
if(!(typeof error === 'object' && error.length === 2
&& typeof error[0] === 'number' && typeof error[1] === 'number')){
debug('bad RPC.error message', m)
} else {
var error_category = error[0]
var errno0 = error[1]
this.on_error(sid, error_category, errno0, message)
}
} else if (mid === 2){
// close
debug('case this._RPC.choke')
if(!(args.length === 0)){

@@ -234,29 +277,9 @@ debug('bad RPC.choke message')

}
break
}
case this._RPC.error: {
var errno0 = args[0], message = args[1]
if(!(typeof errno0 === 'number' && typeof message === 'string')){
debug('bad RPC.error message', m)
} else {
this.on_error(sid, errno0, message)
}
break
}
case this._RPC.terminate: {
var code = args[0], reason = args[1]
if(!(typeof code === 'number' && typeof reason === 'string')){
debug('bad RPC.terminate message', m)
} else {
this.on_terminate(code, reason)
}
break
}
default: {
} else {
debug('discarding a message of unknown type', m)
}
}
return true

@@ -276,11 +299,17 @@ },

}
var m
var owner = this.owner
if(!owner){
debug("won't decode message on channel with no owner, buffering")
return
}
while(true){
m = unpackMessage(this._inBuffer, this._RPC)
debug('unpacked message', inspect(m, {depth:null}))
var m = unpackMessage(this._inBuffer, this._RPC, owner.__sid+1)
if(!m){
debug('not complete/falsish message `%s`', m)
break
}
debug('channel got message', m)
debug('channel got message', inspect(m, {depth:null}))

@@ -292,6 +321,4 @@ if(m === _mpFail){

} else {
debug('unpackMessage.bytesParsed', unpackMessage.bytesParsed)
var remaining = this._inBuffer.length - unpackMessage.bytesParsed
debug('remaining', remaining)
debug('unpackMessage.bytesParsed`%s`, remaining`%s`', unpackMessage.bytesParsed, remaining)

@@ -309,7 +336,7 @@ }

if(0 < remaining){
debug('remaining buffer', this._inBuffer.slice(unpackMessage.bytesParsed))
debug('remaining buffer `%s`...', this._inBuffer.slice(unpackMessage.bytesParsed, unpackMessage.bytesParsed+10))
this._inBuffer = this._inBuffer.slice(this._inBuffer.length - remaining)
} else {
this._inBuffer = null
return
return
}

@@ -316,0 +343,0 @@ }

@@ -10,7 +10,8 @@

var trace = 0
var debug = require('../util').debug('co:mp')
var debug = require('debug')('co:mp')
var inspect = require('util').inspect
function unpackMessage(buf, _RPC){
function unpackMessage(buf, _RPC, invokeBoundary){
debug('function unpackMessage(buf, _RPC, invokeBoundary){', buf.slice(0,10), '{..}', invokeBoundary)
if(buf.length === 0){

@@ -20,3 +21,3 @@ return

if(!(buf[0] === 0x93)){
if(!((buf[0] & 0xF0) === 0x90)){
return fail

@@ -51,6 +52,7 @@ }

if(method === _RPC.chunk){
//if(method === _RPC.chunk){
if(sessionId < invokeBoundary && method === 0){
if(!buf[parsed] === 0x91){
debug('buf[parsed] === 0x91 '+buf.slice(parsed).toString())
debug('!(buf[parsed] === 0x91) '+buf.slice(parsed).toString())
return fail

@@ -57,0 +59,0 @@ }

@@ -5,2 +5,3 @@

var util = require('util')
var inspect = util.inspect
var makeError = require('../util').makeError

@@ -15,2 +16,4 @@

var debug = require('debug')('co:base_service')
function BaseService(){

@@ -27,2 +30,3 @@ this.__sid = 1

// || (this._channel && !this._connecting)
this._effectiveEndpoint = undefined
var self = this

@@ -44,7 +48,6 @@ this._hdl = {

// consecutively connect to endpoints
if(this._channel){
console.log('this._channel', new Error().stack)
}
__assert(!this._channel)
debug('connect to endpoints ', endpoints)
__assert(!this._channel, 'should not connect with existing channel')
var self = this

@@ -59,2 +62,5 @@

self._effectiveEndpoint = endpoint
debug('connecting to ', self._effectiveEndpoint)
self._channel = new Channel(endpoint[0], endpoint[1])

@@ -150,2 +156,3 @@ self._channel.owner = this

_send: function(m){
debug('._send( %s )', inspect(m))
this._channel.send(mp.pack(m))

@@ -158,2 +165,4 @@ },

debug('<BaseService>._call method', methodName)
var methodDef = this.__graph[methodName]

@@ -164,2 +173,5 @@ var mid = methodDef[0]

debug('txGraph', txGraph)
debug('rxGraph', txGraph)
var s = new Session(this.__sid++, txGraph, rxGraph)

@@ -172,2 +184,4 @@ s._owner = this

this._sessions[s._id] = s
} else {
debug('method not found', methodName)
}

@@ -174,0 +188,0 @@

var net = require('net')
var mp = require('msgpack')
var mpb = require('msgpack-buf')
var __assert = require('assert')
var debug = require('../util').debug('co:client:channel')
var debug = require('debug')('co:client:channel')
var inspect = require('util').inspect

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

if(!(buf[0] === 0x93 || buf[0] === 0x94)){
if(!((buf[0] & 0xF0) === 0x90)){
return fail

@@ -75,2 +78,3 @@ }

__assert(this._socket && Buffer.isBuffer(buf), 'this._socket && Buffer.isBuffer(buf)')
debug('sending', buf)
this._socket.write(buf)

@@ -161,3 +165,3 @@ },

debug('channel.hdl.message', m)
if(!(typeof m === 'object' && (m.length === 3 || m.length === 4))){
if(!(typeof m === 'object' && typeof m.length === 'number' && m.length <= 3)){
debug('message is not a tuple', m)

@@ -182,4 +186,4 @@ this._hdl.error({code: 'EBADMSG'})

data: function(buf){
debug('channel got data', buf)
__assert(Buffer.isBuffer(buf), 'Buffer.isBuffer(buf)')
debug('channel got data', buf)

@@ -186,0 +190,0 @@ if(this._inBuffer){

@@ -12,3 +12,3 @@

for(idx in graph){
for(var idx in graph){
var idx0 = parseInt(idx)

@@ -39,3 +39,3 @@ var methodName = graph[idx][0]

for(idx in graph){
for(var idx in graph){
var idx0 = parseInt(idx)

@@ -42,0 +42,0 @@ var methodName = graph[idx][0]

var util = require('util')
var fmt = util.format
var EventEmitter = require('events').EventEmitter

@@ -25,3 +27,5 @@ var __assert = require('assert')

function Locator(endpoints){
endpoints = endpoints || [['127.0.0.1', 10053], ['::', 10053]]
endpoints = endpoints || [['127.0.0.1', 10053], ['::1', 10053]]
__assert(typeof endpoints === 'object' && typeof endpoints.length === 'number',
"typeof endpoints === 'object' && typeof endpoints.length === 'number'")
var S = this._service = new BaseService()

@@ -44,2 +48,3 @@ S._setGraph(locatorGraph)

self._service.removeListener('connect', _onConnect)
self._service.removeListener('error', _onError)
self.emit('connect')

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

__assert(this._connected)
this._service._call('resolve', [name]).recv({
var self = this
var x = this._service._call('resolve', [name]).recv({
value: function(endpoints, version, graph){

@@ -64,3 +70,11 @@ cb(null, endpoints, version, graph)

error: function(code, message){
var err = new Error(message)
var err = new Error(fmt('error resolving service `%s` at %s: %s',
name, self._service._effectivelEndpoint, message))
if(x._stack){
err.stack =
err.stack +
'\n----------------\n' +
x._stack
}
if(message === 'service is not available'){

@@ -67,0 +81,0 @@ err.code = 'ENOTFOUND'

@@ -6,3 +6,4 @@

var debug = require('../util').debug('co:logger')
var debug = require('debug')('co:logger')
var Service = require('./service').Service

@@ -25,3 +26,4 @@

var message = format.apply(null, args)
this._logging.emit(priority, this._target, message, attrs)
var set = Object.keys(attrs).map(function(k){return [k, attrs[k]]})
this._logging.emit(priority, this._target, message, set)
} else {

@@ -35,4 +37,5 @@ var message = format.apply(null, arguments)

function Logger(app){
function Logger(app, options){
EventEmitter.apply(this, arguments)
this._options = options || {}
this._logging = null

@@ -52,3 +55,3 @@ this._client = null

this._state = 'connecting'
this._logging = Service('logging')
this._logging = Service('logging', this._options)
if(this._client){

@@ -55,0 +58,0 @@ this._logging._client = this._client

@@ -5,6 +5,7 @@

var util = require('util')
var fmt = util.format
var Locator = require('./locator').Locator
var BaseService = require('./base_service').BaseService
var debug = require('../util').debug('co:client:service')
var debug = require('debug')('co:client:service')

@@ -21,4 +22,18 @@ var slice = Array.prototype.slice

__assert(typeof cb === 'function')
if(typeof locator === 'object' && typeof locator.length === 'number'){
if(typeof locator[0] === 'string' && typeof locator[1] === 'number'){
var endpoints = [locator]
} else if (typeof locator[0] === 'object' && typeof locator[0].length === 'number'){
var endpoints = locator
} else {
throw new TypeError(fmt('endpoints should be specified as [host, port] or [[host,port], [host,port]], got %s instead', locator))
}
var L = new Locator(endpoints)
} else {
var L = locator || new Locator()
}
var L = locator || new Locator()
var done = false

@@ -68,4 +83,6 @@

function Service(name){
function Service(name, options){
debug('constructing service %s with options %s', name, options)
function ServiceClient(){

@@ -77,2 +94,3 @@ this._name = name

this._connecting = false
this._options = options || {}
}

@@ -108,4 +126,13 @@

this._connecting = true
var self = this
resolve(this._name, function(err, endpoints, version, graph){
if(this._options.locator){
debug('resolving with specified locator', this._options.locator)
resolve(this._name, this._options.locator, _onResolve)
} else {
debug('resolving with default locator')
resolve(this._name, _onResolve)
}
function _onResolve(err, endpoints, version, graph){
if(err){

@@ -141,6 +168,13 @@ self._emit('error', err)

}
})
}
}
},
_call: function(){
__assert(this._connected)
return this._service._call.apply(this._service, arguments)
},
close: function(){

@@ -157,2 +191,13 @@ if(this._connected){

this._endpoints = endpoints
},
_getMethods: function(){
__assert(this._connected)
var graph = this.__graph
return Object.keys(graph).map(function(k){
return graph[k][0]
})
}

@@ -159,0 +204,0 @@

@@ -11,5 +11,7 @@

var trace = 0
var debug = require('debug')('co:client:session')
var trace = 1
function Session(sid, txGraph, rxGraph){

@@ -23,5 +25,12 @@

trace && console.log('rxFacet', util.inspect(rxFacet, {depth:null}))
trace && console.log('txFacet', util.inspect(txFacet, {depth:null}))
debug('rxFacet', util.inspect(rxFacet, {depth:null}))
debug('txFacet', util.inspect(txFacet, {depth:null}))
this._stack = ''
if(trace){
var stacktrace = new Error().stack
var idx = stacktrace.indexOf('\n')
this._stack = stacktrace.slice(idx+1)
}
this._rxMethod = rxFacet.method

@@ -45,3 +54,3 @@ this._rxTransition = rxFacet.transition

_send: function(m){
trace && console.log('send', util.inspect(m,{depth:null}))
debug('send', util.inspect(m,{depth:null}))
this._owner._send(m)

@@ -55,3 +64,3 @@ },

if(txFacet === __stop){
trace && console.log('stop!', new Error().stack)
debug('stop!', new Error().stack)
this._txMethod = undefined

@@ -58,0 +67,0 @@ this._txTransition = undefined

@@ -146,3 +146,3 @@

_E = []
var _E = []

@@ -149,0 +149,0 @@ Object.keys(E).some(function(k){

@@ -23,2 +23,6 @@

var ERROR_CATEGORY = {
application_error: 42
}
module.exports = {

@@ -25,0 +29,0 @@ RPC:RPC,

var v = process.version.slice(1).split('.')
if(v[1] === '10'){
if(0 < parseInt(v[0]) || v[1] === '10' || v[1] === '12'){
module.exports = require('./session2')

@@ -5,0 +6,0 @@ } else if(v[1] === '8'){

@@ -84,6 +84,8 @@

if(Buffer.isBuffer(data)){
var msg = mp.pack([this._id,this._RPC.chunk,[data]])
//var msg = mp.pack([this._id,this._RPC.chunk,[data]])
var msg = mp.pack([this._id, 0, [data]])
} else {
__assert(typeof data === 'string')
var msg = mp.pack([this._id,this._RPC.chunk,[Buffer(data)]])
//var msg = mp.pack([this._id,this._RPC.chunk,[Buffer(data)]])
var msg = mp.pack([this._id, 0, [Buffer(data)]])
}

@@ -100,3 +102,4 @@ var hdl = this.owner._handle

var hdl = this.owner._handle
hdl.send(mp.pack([this._id,this._RPC.choke,[]]))
//hdl.send(mp.pack([this._id,this._RPC.choke,[]]))
hdl.send(mp.pack([this._id, 2, []]))
this.close()

@@ -108,3 +111,4 @@ },

typeof message === 'string')
hdl.send(mp.pack([this._id,this._RPC.error,[code,message]]))
//hdl.send(mp.pack([this._id,this._RPC.error,[code,message]]))
hdl.send(mp.pack([this._id, 1, [[ERROR_CATEGORY.application_error, code], message]]))
this.close()

@@ -111,0 +115,0 @@ },

@@ -8,2 +8,3 @@

var RPC = protocol.RPC
var ERROR_CATEGORY = protocol.ERROR_CATEGORY

@@ -32,2 +33,3 @@ var util = require('./util')

pushChunk:function(chunk){
console.log('pushChunk', chunk)
__assert(Buffer.isBuffer(chunk), 'Buffer.isBuffer(chunk)')

@@ -37,2 +39,3 @@ this.push(chunk)

pushChoke:function(){
console.log('pushChoke')
__assert(!this.choked)

@@ -43,2 +46,3 @@ this.choked = true

pushError:function(code,message){
console.log('pushError', code, message)
var e = new Error(message)

@@ -55,15 +59,21 @@ e.code = code

_write:function(chunk,encoding,cb){
console.log('session._write', chunk)
if(Buffer.isBuffer(chunk)){
var msg = mp.pack([this._id,this._RPC.chunk,[chunk]])
//var msg = mp.pack([this._id,this._RPC.chunk,[chunk]])
var msg = mp.pack([this._id, 0, [chunk]])
} else {
__assert(typeof chunk === 'string'
&& typeof encoding === 'string')
var msg = mp.pack([this._id,this._RPC.chunk,[new Buffer(chunk,encoding)]])
//var msg = mp.pack([this._id,this._RPC.chunk,[new Buffer(chunk,encoding)]])
var msg = mp.pack([this._id, 0, [new Buffer(chunk,encoding)]])
}
this.owner._handle.send(msg)
cb()
},
end:function(){
console.log('session.end')
var r = Duplex.prototype.end.apply(this,arguments)
this.owner._handle.send(mp.pack([this._id,this._RPC.choke,[]]))
//this.owner._handle.send(mp.pack([this._id,this._RPC.choke,[]]))
this.owner._handle.send(mp.pack([this._id, 2, []]))
return r

@@ -74,3 +84,4 @@ },

var hdl = this.owner._handle
hdl.send(mp.pack([this._id,this._RPC.error,[code,message]]))
//hdl.send(mp.pack([this._id,this._RPC.error,[code,message]]))
hdl.send(mp.pack([this._id, 1, [[ERROR_CATEGORY.application_error, code], message]]))
this.close()

@@ -77,0 +88,0 @@ },

@@ -10,2 +10,5 @@

module.exports = {
__uid: function(){
return Math.floor(Math.random()*0x100000000).toString(36)
},
makeError: function(errno, message){

@@ -94,4 +97,6 @@ message = message || _ERRNO[errno] || 'unknown'

}
}
},
fmt: format
}

@@ -5,4 +5,6 @@

var jp = require('jampack')
var jp = require('@nojs/jampack')
var debug = require('debug')('co:handles')
var util = require('../util')

@@ -157,3 +159,8 @@

if(!this._connected){
debug('!this._connected')
if(this._listenHandle){
debug('this._listenHandle.push()')
this._listenHandle.push(this)

@@ -165,2 +172,3 @@ this._connected = true

if(this._closing){
debug('this._closing')
return

@@ -170,2 +178,3 @@ }

if(chunk === null){
debug('chunk === null, so set this._read_ended = true')
this._read_ended = true

@@ -176,13 +185,18 @@ }

if(chunk){
debug('// HACK: transform the only request chunk to usual http request')
__assert(!this._meta,'got two request chunks in http request, which is absolutely not in 0.10 cocaine fashion')
this._meta = chunk
chunk = bakeRequest(chunk)
debug('and request is ----\n%s\n--------', chunk.toString())
}
if(this._paused){
debug('this._paused, so this._read_chunks.push(chunk)')
this._read_chunks.push(chunk)
} else {
if(!this._read_ended){
debug('!this._read_ended, so this.onread(chunk,0,chunk.length)', chunk,0,chunk.length)
this.onread(chunk,0,chunk.length)
} else {
debug('this._pushClose()')
this._pushClose()

@@ -203,2 +217,3 @@ }

__assert(Buffer.isBuffer(chunk))
debug('pushChunk', chunk)
this.push(chunk)

@@ -242,9 +257,13 @@ },

// HACK: pack all but first outgoing chunks
// HACK: prepare to remove the above hack: first outgoing is packed
// elsewhere, and we don't pack any following chunks
if(!this._first_outgoing){
this._first_outgoing = chunk
} else {
chunk = mp.pack(chunk)
// HACK: don't pack. see note above.
//chunk = mp.pack(chunk)
}
this._worker._handle.send(mp.pack([this._id,RPC.chunk,[chunk]]))
//this._worker._handle.send(mp.pack([this._id, RPC.chunk, [chunk]]))
this._worker._handle.send(mp.pack([this._id, 0, [chunk]]))
var req = new WriteReq(this,chunk)

@@ -274,3 +293,4 @@ this._write_reqs.push(req)

this._worker._handle.send(mp.pack([this._id,RPC.choke,[]]))
//this._worker._handle.send(mp.pack([this._id, RPC.choke, []]))
this._worker._handle.send(mp.pack([this._id, 2, []]))
if(typeof cb === 'function'){

@@ -277,0 +297,0 @@ this.close = cb // the exact behavior of node::HandleWrap::Close

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

var trace = 1
var debug = require('debug')('co:worker')

@@ -124,4 +124,5 @@ var Worker = FSM.define({

__assert(this._state === 'connected', "this._state === 'connected'")
var sid = this.__sid++
this._handle.send(mp.pack([sid, RPC.heartbeat, []]))
var sid = 1
// RPC.heartbeat
this._handle.send(mp.pack([sid, 0, []]))
this._heartbeatTimer = setTimeout(this._handlers.sendNextHeartbeat, this._heartbeatInterval)

@@ -138,3 +139,3 @@ }

connect: function(endpoint){
trace && console.log('connect', arguments)
debug('connect', arguments)
endpoint = endpoint || this._endpoint

@@ -167,4 +168,5 @@ if(Array.isArray(endpoint)){

var _this = this.owner
var sid = _this.__sid++
_this._handle.send(mp.pack([sid, RPC.handshake, [_this._uuid]]))
// RPC.handshake
var sid = 1
_this._handle.send(mp.pack([sid, 0, [_this._uuid]]))
_this._setState('connected')

@@ -196,6 +198,6 @@ _this._handlers.sendNextHeartbeat()

}
var sid = this.__sid++
var msg = mp.pack([sid, RPC.terminate, [state, reason]])
console.log('sending terminate message')
console.log(msg)
// RPC.terminate
var sid = 1
var msg = mp.pack([sid, 1, [state, reason]])
debug('sending terminate message', msg)
this._handle.send(msg)

@@ -243,7 +245,7 @@ this._setState('selfTerminated')

on_invoke: function(sid, event){
trace && console.log('on_invoke sss', sid, event)
debug('on_invoke sss', sid, event)
var _this = this.owner
var lh = _this._listenHandles[event]
if(lh){
trace && console.log('got listen handle')
debug('got listen handle')
var s = lh.createStreamHandle(sid, event)

@@ -261,3 +263,3 @@ _this._sessions[s._id] = s

on_chunk: function(sid, data){
trace && console.log('on_chunk', sid, data)
debug('on_chunk', sid, data)
var _this = this.owner

@@ -267,2 +269,4 @@ var s = _this._sessions[sid]

s.pushChunk(data)
} else {
debug('session %s not found, dropping message', sid)
}

@@ -273,3 +277,3 @@ },

on_choke: function(sid){
trace && console.log('on_choke', sid)
debug('on_choke', sid)
var _this = this.owner

@@ -284,4 +288,4 @@ var s = _this._sessions[sid]

// `error message for some session
on_error: function(sid, code, message){
trace && console.log('on_error', sid, code, message)
on_error: function(sid, category, code, message){
debug('on_error', sid, [category, code], message)
var _this = this.owner

@@ -302,4 +306,5 @@ var s = _this._sessions[sid]

terminate: function(){
var sid = this.__sid++
var msg = mp.encode([sid, RPC.terminate, [TERMINATE.normal, 'worker shut down']])
// RPC.terminate
var sid = 1
var msg = mp.pack([sid, 1, [TERMINATE.normal, 'worker shut down']])
this._handle.send(msg)

@@ -312,3 +317,3 @@ this._setState('terminated')

close: function(){
// TODO: shouldn't we just call .terminate here?
// XXX: shouldn we just call .terminate here?
this._closeHandle()

@@ -315,0 +320,0 @@ this._setState('closed')

{
"name": "cocaine",
"version": "0.12.0-alpha3",
"version": "0.12.1-r01",
"description": "Node.js framework for Cocaine platform",

@@ -16,14 +16,24 @@ "author": "Cocaine Project <cocaine@yandex-team.ru>",

"dependencies": {
"bindings": "~1.0.0",
"debug": "*",
"hexy": "^0.2.6",
"jampack": "0.0.7",
"msgpack-bin": "0.2.x",
"msgpack": "0.1.*",
"msgpack-buf": "^0.1.8",
"optimist": "~0.4",
"q": "~0.9"
"q": "1.*",
"@nojs/jampack": "0.0.8"
},
"devDependencies": {
"mocha":"1.20.x",
"msgpack-buf": "0.1.8",
"node-uuid":"1.4.x"
"mocha": "1.20.x",
"node-uuid": "1.4.x",
"co": "*",
"chai": "*",
"@nojs/msgpack-socket": "*",
"babel": "*"
},
"scripts": {
"_postinstall": "rm -f node_modules/cocaine && ln -s .. node_modules/cocaine",
"__test": "node_modules/.bin/mocha --compilers js:babel/register",
"test": "mocha --compilers js:babel/register --reporter spec --timeout 60000",
"_test": "mocha --compilers js:babel/register --timeout 600000 --debug-brk"
}
}
var Service = require('../lib/client/service').Service
var mp = require('msgpack')
var locatorEndpoint = ['coke-r04-6-1.haze.yandex.net', 10053]

@@ -8,17 +8,15 @@

var log = Service('logging')
var Logger = require('../lib/client/logger').Logger
var log = new Logger('some/app/poijpisdf', {locator: locatorEndpoint})
//var log = Service('logging', {locator: locatorEndpoint})
log.connect()
log.on('connect', function(){
console.log('log._connected', log._connected)
log.verbosity().recv({
value: function(verbosity){
console.log('verbosity', verbosity)
},
error: function(){
console.log('error', arguments)
}
})
log.emit(0, 'bla', 'blabla', {aaa:'bbb'})
console.log('log._connected')
log.emit(0, 'bla', 'blabla', [['aaapoijp-pdsoifjpaosdif', 'bbb']])
//log.emit(0, 'bla', 'blabla')

@@ -28,3 +26,3 @@ setTimeout(function(){

log.close()
}, 1000)
}, 1000000)

@@ -31,0 +29,0 @@ })

var cocaine = require('../')

@@ -4,0 +3,0 @@

Sorry, the diff of this file is not supported yet

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