一个队列上的Firebase队列多个规则都被执行或者错误的一个被选中

时间:2016-03-24 19:48:58

标签: node.js firebase angularfire firebase-realtime-database firebase-queue

我有一个Firebase队列和两个规范,在同一个队列和客户端我正在推动队列,启动状态只有read_write_start,默认情况下我的规范都被执行或执行了错误的规范即" read_start"规范被执行

客户端:

var readWriteTokenData = {};
                        readWriteTokenData ["_start"] = "read_write_start";
$firebaseArray(QueueRef.child('tasks')).$add(readWriteTokenData);

服务器端:

var queueRef = new Firebase('https://<INSTANCE>.firebaseio.com/queue');

    var specs: {
        "read_write_token": {
            "_start_state" : "read_write_start",
            "in_progress_state": "read_write_in_progress",
            "finished_state": "read_write_finished",
            "error_state": "read_write_error"
        },
        "read_token": {
            "_start_state" : "read_start",
            "in_progress_state": "read_in_progress",
            "finished_state": "read_finished",
            "error_state": "read_error"
        }
     }

    queueRef.child('specs').update(specs);

    var option1 = {
        'specId' : 'read_token',
        'numWorkers': 1
    };

    var option2 = {
        'specId' : 'read_write_token',
        'numWorkers': 1
    };

var ReadQueue = new Queue(queueRef,option1,function(data, progress, resolve, reject) {

    data.readToken = 'PQR';

    if(readToken){
        resolve(data);
    } else {
        reject(data);
    }
});

var ReadWriteQueue = new Queue(queueRef,option2,function(data, progress, resolve, reject) {

    data.readWriteToken = 'ABC';
    if(readWriteToken){
        resolve(data);
    } else {
        reject(data);
    }
});

我不确定我在这里缺少什么文件不清楚

我是否必须为每个规范实例化一个新的队列引用?规格只适用于链接工作吗?

我应该这样做吗

var queueRef1 = new Firebase('https://<INSTANCE>.firebaseio.com/read/queue');
var queueRef2 = new Firebase('https://<INSTANCE>.firebaseio.com/readwrite/queue');

0 个答案:

没有答案