示例#1
0
 this.fetchTopic = function(args) {
     var request = std.extend({}, std.extend(args.name == undefined ? { name: args } : args, fetch_defaults))
     request.original_offset = bigint(request.offset)
     request.bytesRead = 0
     this._pushRequest({request: request})
     return this
 }
示例#2
0
 this.send = function(args, messages, callback) {
     var request = std.extend({}, std.extend(messages == undefined ? args : { topic: args, messages: messages}, send_defaults))
     if (!(request.messages instanceof Array)) request.messages = [request.messages]
     var cb = function() {
         this._msgs_sent++
         callback && callback()
     }.bind(this)
     this._msgs_requested++
     this._pushSendRequest({request: request, callback: cb})
     return this
 }
示例#3
0
	this._init = function(opts) {
		supr(this, '_init', arguments)
		opts = std.extend(opts, defaults)
		this._pollInterval = opts.pollInterval
		this._topic = opts.topic
		this._partition = opts.partition
		this._offset = opts.offset
		this._buffer = new Buffer(opts.maxSize)
	}
示例#4
0
	this.init = function(opts) {
		supr(this, 'init', arguments)
		opts = std.extend(opts, defaults)
		this._pollInterval = opts.pollInterval
		this._topics = []
		this._outstanding = 0
		this._shouldPoll = false
		
		this.on('lastmessage', std.bind(this, '_processLast'))
	}
示例#5
0
    this._init = function(opts) {
        supr(this, '_init', arguments)
        opts = std.extend(opts, defaults)
        this._pollInterval = opts.pollInterval
        this._reconnectInterval = opts.reconnectInterval
        this._topics = []
        this._outstanding = 0
        this._timerTicked = true
        
        this.on('message', std.bind(this, '_processMessage'))
        this.on('lastmessage', std.bind(this, '_processLast'))
        this.on('closed', std.bind(this, '_closed'))

        this._timeoutID = setTimeout(std.bind(this, '_tick'), this._pollInterval)
    }
示例#6
0
    this._init = function(opts) {
        supr(this, '_init', arguments)
        opts = std.extend(opts, defaults)
        this._buffer = new Buffer(opts.maxSize)
        fetch_defaults.encode = fetch_defaults.encode.bind(this)
        offset_defaults.encode = offset_defaults.encode.bind(this)
        send_defaults.encode = send_defaults.encode.bind(this)

        this._autoConnectOnWrite = opts.autoConnectOnWrite
        this._sendQueueLength = opts.sendQueueLength

        this.on('connected', std.bind(this, '_connected'))

        this._msgs_requested = 0
        this._msgs_sent = 0
        this._msgs_dropped = 0

        this._reset()
        this.clearRequests()
    }
示例#7
0
    this._init = function(opts) {
        supr(this, '_init', arguments)
        opts = std.extend(opts, defaults)
        this._buffer = new Buffer(opts.maxSize)
        fetch_defaults.encode = this._encodeFetchRequest.bind(this)
        offset_defaults.encode = this._encodeOffsetsRequest.bind(this)

        if(opts.compressionCodec > 0) {
            if(opts.compressionCodec != 2)
                throw "Only Snappy compression supported"

            this._encodeMessageCompressed = fetchEncodeMessageCompressed(opts.compressionCodec)
            this._compressionBatchSize = opts.compressionBatchSize

            if(opts.compressedTopics) {
                this._compressedTopics = opts.compressedTopics
                this._isCompressedTopic = function(topic){
                    return this._compressedTopics.indexOf(topic)
                }.bind(this)
            } else {
                this._isCompressedTopic = function(){
                    return true
                }
            }
            send_defaults.encode = this._encodeSendRequestCompressed.bind(this)
        } else {
            send_defaults.encode = this._encodeSendRequestUncompressed.bind(this)
        }

        this._autoConnectOnWrite = opts.autoConnectOnWrite
        this._sendQueueLength = opts.sendQueueLength

        this.on('connected', std.bind(this, '_connected'))

        this._msgs_requested = 0
        this._msgs_sent = 0
        this._msgs_dropped = 0

        this._reset()
        this.clearRequests()
    }
示例#8
0
文件: Logger.js 项目: ifwe/node-kafka
	this._init = function(opts) {
		opts = std.extend(opts, defaults)
		this._name = opts.name
		this._emailQueue = []
	}
示例#9
0
	this.subscribeTopic = function(opts) {
		var topic = opts.name == undefined ? { name:opts, offset:0, partition: 0 } : std.extend(opts, subscription_defaults)
		this._topics.push(topic)
		if (this._topics.length == 1) this._schedulePoll()
		return this
	}
示例#10
0
文件: Logger.js 项目: kaleb/std.js
	this._init = function(opts) {
		if (typeof opts == 'string') { opts = { name:opts } }
		opts = std.extend(opts, defaults)
		this._name = opts.name
		this._emailQueue = []
	}
示例#11
0
 this.fetchOffsets = function(args) {
     var request = std.extend({}, std.extend(args.name == undefined ? { name: args } : args, offset_defaults))
     this._pushRequest({request: request})
     return this
 }
示例#12
0
	this._init = function(opts) {
		supr(this, '_init', arguments)
		opts = std.extend(opts, defaults)
		this._partition = opts.partition
		this._topic = opts.topic
	}
示例#13
0
	this.init = function(opts) {
		opts = std.extend(opts, defaults)
		this._host = opts.host
		this._port = opts.port
	}
示例#14
0
 this._init = function(opts) {
     supr(this, '_init', arguments)
     opts = std.extend(opts, defaults)
     this._reconnectInterval = opts.reconnectInterval
     this.on('closed', std.bind(this, '_retry'))
 }