Skip to content

Commit

Permalink
refactor: update copyright header
Browse files Browse the repository at this point in the history
  • Loading branch information
XadillaX committed Dec 21, 2016
1 parent 1fd7d8d commit acc5e5b
Show file tree
Hide file tree
Showing 26 changed files with 361 additions and 286 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ Release
note.txt

test/_config.js
tags
10 changes: 7 additions & 3 deletions lib/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var _Consumer = require("../build/Release/ons").ONSConsumer;
* @param {String} [options.namesrvAddr] the ONS server address
* @param {Number} [options.threadNum] the thread count
* @param {Number} [options.sendTimeout] the send timeout (ms)
* @param {Boolean} [options.order] whether it will be `OrderConsumer`
* @constructor
*/
var Consumer = function ONSConsumer(cid, topic, tag, accessKey, secretKey, options) {
Expand Down Expand Up @@ -75,7 +76,8 @@ var Consumer = function ONSConsumer(cid, topic, tag, accessKey, secretKey, optio
util.inherits(Consumer, EventEmitter);

/**
* init
* Initialize for the consumer
*
* @param {Function} callback the callback function
*/
Consumer.prototype.init = function(callback) {
Expand Down Expand Up @@ -104,7 +106,7 @@ Consumer.prototype.init = function(callback) {
};

/**
* listen
* Start to listen to the queue
*/
Consumer.prototype.listen = function() {
this.consumer.listen();
Expand All @@ -117,7 +119,9 @@ Consumer.prototype.listen = function() {
};

/**
* stop
* Stop the consumer
*
* @param {Function} callback the callback function
*/
Consumer.prototype.stop = function(callback) {
if(this.keepTimer) {
Expand Down
9 changes: 6 additions & 3 deletions lib/producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var __ORDER_PARSER = "parseOrderSendArguments";
* @param {Object} [options] the options
* @param {String} [options.onsAddr] the fetching ONS server address
* @param {String} [options.namesrvAddr] the ONS server address
* @param {Boolean} [options.order] whether use order producer
* @param {Boolean} [options.order] whether it will be `OrderProducer`
* @constructor
*/
var Producer = function ONSProducer(producerId, accessKey, secretKey, options) {
Expand Down Expand Up @@ -63,7 +63,8 @@ var Producer = function ONSProducer(producerId, accessKey, secretKey, options) {
};

/**
* start
* Start the producer
*
* @param {Function} callback the callback function
*/
Producer.prototype.start = function(callback) {
Expand All @@ -80,7 +81,9 @@ Producer.prototype.start = function(callback) {
};

/**
* stop
* Stop the producer
*
* @param {Function} callback the callback function
*/
Producer.prototype.stop = function(callback) {
if(this.keepTimer) {
Expand Down
33 changes: 18 additions & 15 deletions src/consumer.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
/*
* =====================================================================================
/**
* ___
* | | |
* / \ | |
* |--o|===|-|
* |---| |n|
* / \ |o|
* | O | |d|
* | N |=|e|
* | S | | |
* |_______| |_|
* |@| |@| | |
* ___________|_|_
*
* Filename: consumer.cpp
* AliyunONS - Node.js SDK for Aliyun ONS (based on RocketMQ)
*
* Description: ONS consumer wrapper for node.js
* Copyright (c) 2016 XadillaX <i@2333.moe>
*
* Version: 1.0
* Created: 2015/12/18 13时23分04秒
* Revision: none
* Compiler: g++
*
* Author: XadillaX (ZKD), zhukaidi@souche.com
* Organization: Design & Development Center, Souche Car Service Co., Ltd, HANGZHOU
*
* =====================================================================================
* MIT LIcense <https://github.com/XadillaX/aliyun-ons/blob/master/LICENSE>
*/
#include "log_util.h"
#include "consumer.h"
Expand All @@ -40,6 +43,7 @@ ONSConsumerV8::ONSConsumerV8(
tag(_tag),
access_key(_access_key),
secret_key(_secret_key),
is_order(false),

initializing(false),
inited(false),
Expand All @@ -48,8 +52,7 @@ ONSConsumerV8::ONSConsumerV8(
real_consumer(NULL),
listener(NULL),

listener_func(),
is_order(false)
listener_func()
{
Nan::HandleScope scope;

Expand Down
29 changes: 16 additions & 13 deletions src/consumer.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
/*
* =====================================================================================
/**
* ___
* | | |
* / \ | |
* |--o|===|-|
* |---| |n|
* / \ |o|
* | O | |d|
* | N |=|e|
* | S | | |
* |_______| |_|
* |@| |@| | |
* ___________|_|_
*
* Filename: consumer.h
* AliyunONS - Node.js SDK for Aliyun ONS (based on RocketMQ)
*
* Description: ONS consumer wrapper for node.js
* Copyright (c) 2016 XadillaX <i@2333.moe>
*
* Version: 1.0
* Created: 2015/12/18 13时25分31秒
* Revision: none
* Compiler: g++
*
* Author: XadillaX (ZKD), zhukaidi@souche.com
* Organization: Design & Development Center, Souche Car Service Co., Ltd, HANGZHOU
*
* =====================================================================================
* MIT LIcense <https://github.com/XadillaX/aliyun-ons/blob/master/LICENSE>
*/
#ifndef __ONS_CONSUMER_H__
#define __ONS_CONSUMER_H__
Expand Down
29 changes: 16 additions & 13 deletions src/consumer_ack.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
/*
* =====================================================================================
/**
* ___
* | | |
* / \ | |
* |--o|===|-|
* |---| |n|
* / \ |o|
* | O | |d|
* | N |=|e|
* | S | | |
* |_______| |_|
* |@| |@| | |
* ___________|_|_
*
* Filename: consumer_ack.cpp
* AliyunONS - Node.js SDK for Aliyun ONS (based on RocketMQ)
*
* Description: ONS consumer ACK wrapper for node.js
* Copyright (c) 2016 XadillaX <i@2333.moe>
*
* Version: 1.0
* Created: 2016/01/25 11时37分20秒
* Revision: none
* Compiler: gcc
*
* Author: XadillaX (ZKD), zhukaidi@souche.com
* Organization: Design & Development Center, Souche Car Service Co., Ltd, HANGZHOU
*
* =====================================================================================
* MIT LIcense <https://github.com/XadillaX/aliyun-ons/blob/master/LICENSE>
*/
#include "consumer_ack.h"

Expand Down
31 changes: 17 additions & 14 deletions src/consumer_ack.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
/*
* =====================================================================================
/**
* ___
* | | |
* / \ | |
* |--o|===|-|
* |---| |n|
* / \ |o|
* | O | |d|
* | N |=|e|
* | S | | |
* |_______| |_|
* |@| |@| | |
* ___________|_|_
*
* Filename: consumer_ack.h
* AliyunONS - Node.js SDK for Aliyun ONS (based on RocketMQ)
*
* Description: ONS consumer ACK wrapper for node.js
* Copyright (c) 2016 XadillaX <i@2333.moe>
*
* Version: 1.0
* Created: 2016/01/25 11时16分17秒
* Revision: none
* Compiler: g++
*
* Author: XadillaX (ZKD), zhukaidi@souche.com
* Organization: Design & Development Center, Souche Car Service Co., Ltd, HANGZHOU
*
* =====================================================================================
* MIT LIcense <https://github.com/XadillaX/aliyun-ons/blob/master/LICENSE>
*/
#ifndef __ONS_CONSUMER_ACK_H__
#define __ONS_CONSUMER_ACK_H__
Expand Down Expand Up @@ -76,7 +79,7 @@ class ONSConsumerACKInner {
uv_mutex_unlock(&mutex);
}

int WaitResult()
COMMON_ACTION WaitResult()
{
uv_mutex_lock(&mutex);

Expand Down
4 changes: 2 additions & 2 deletions src/consumer_listener/base_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ COMMON_ACTION ONSConsumerBaseListener::Consume(Message& message)
async->data = (void*)param;
uv_async_send(async);

int result = ack_inner->WaitResult();
COMMON_ACTION result = ack_inner->WaitResult();

async->data = NULL;
param->ons = NULL;
Expand All @@ -159,7 +159,7 @@ COMMON_ACTION ONSConsumerBaseListener::Consume(Message& message)
// restore `uv_async_t` object
RestoreAsync(async);

return (COMMON_ACTION)result;
return result;
}

}
4 changes: 3 additions & 1 deletion src/consumer_listener/order_consumer_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ ONSOrderConsumerListener::~ONSOrderConsumerListener()

OrderAction ONSOrderConsumerListener::consume(Message& message, ConsumeOrderContext& context)
{
return (OrderAction)ONSConsumerBaseListener::Consume(message);
return ONSConsumerBaseListener::Consume(message) == COMMON_ACTION::SUCCESS ?
OrderAction::Success :
OrderAction::Suspend;
}
33 changes: 19 additions & 14 deletions src/consumer_listener/push_consumer_listener.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
/*
* =====================================================================================
/**
* ___
* | | |
* / \ | |
* |--o|===|-|
* |---| |n|
* / \ |o|
* | O | |d|
* | N |=|e|
* | S | | |
* |_______| |_|
* |@| |@| | |
* ___________|_|_
*
* Filename: consumer_listener.cpp
* AliyunONS - Node.js SDK for Aliyun ONS (based on RocketMQ)
*
* Description: Consumer listener class and function
* Copyright (c) 2016 XadillaX <i@2333.moe>
*
* Version: 1.0
* Created: 2016/07/13 15时15分32秒
* Revision: none
* Compiler: g++
*
* Author: XadillaX (zkd), i@2333.moe
* Organization: Design & Development Center, Souche Inc. CHINA
*
* =====================================================================================
* MIT LIcense <https://github.com/XadillaX/aliyun-ons/blob/master/LICENSE>
*/
#include "push_consumer_listener.h"

Expand All @@ -28,5 +31,7 @@ ONSPushConsumerListener::~ONSPushConsumerListener()

Action ONSPushConsumerListener::consume(Message& message, ConsumeContext& context)
{
return (Action)ONSConsumerBaseListener::Consume(message);
return ONSConsumerBaseListener::Consume(message) == COMMON_ACTION::SUCCESS ?
Action::CommitMessage :
Action::ReconsumeLater;
}
29 changes: 16 additions & 13 deletions src/consumer_listener/push_consumer_listener.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
/*
* =====================================================================================
/**
* ___
* | | |
* / \ | |
* |--o|===|-|
* |---| |n|
* / \ |o|
* | O | |d|
* | N |=|e|
* | S | | |
* |_______| |_|
* |@| |@| | |
* ___________|_|_
*
* Filename: consumer_listener.h
* AliyunONS - Node.js SDK for Aliyun ONS (based on RocketMQ)
*
* Description: Consumer listener class and function
* Copyright (c) 2016 XadillaX <i@2333.moe>
*
* Version: 1.0
* Created: 2016/07/13 15时14分09秒
* Revision: none
* Compiler: g++
*
* Author: XadillaX (zkd), i@2333.moe
* Organization: Design & Development Center, Souche Inc. CHINA
*
* =====================================================================================
* MIT LIcense <https://github.com/XadillaX/aliyun-ons/blob/master/LICENSE>
*/
#ifndef __CONSUMER_LISTENER_H__
#define __CONSUMER_LISTENER_H__
Expand Down
29 changes: 16 additions & 13 deletions src/consumer_workers/consumer_prepare_worker.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
/*
* =====================================================================================
/**
* ___
* | | |
* / \ | |
* |--o|===|-|
* |---| |n|
* / \ |o|
* | O | |d|
* | N |=|e|
* | S | | |
* |_______| |_|
* |@| |@| | |
* ___________|_|_
*
* Filename: consumer_prepare_worker.h
* AliyunONS - Node.js SDK for Aliyun ONS (based on RocketMQ)
*
* Description: Prepare worker for consumer
* Copyright (c) 2016 XadillaX <i@2333.moe>
*
* Version: 1.0
* Created: 2016/07/13 15时10分46秒
* Revision: none
* Compiler: g++
*
* Author: XadillaX (zkd), i@2333.moe
* Organization: Design & Development Center, Souche Inc. CHINA
*
* =====================================================================================
* MIT LIcense <https://github.com/XadillaX/aliyun-ons/blob/master/LICENSE>
*/
#ifndef __CONSUMER_PREPARE_WORKER_H__
#define __CONSUMER_PREPARE_WORKER_H__
Expand Down
Loading

0 comments on commit acc5e5b

Please sign in to comment.