How push a task with SpecId in firebase-queue with nodejs?

自作多情 提交于 2019-12-04 19:04:17

tl;dr the start_statefor the spec should match the _state of the task.

You need push the definition of each spec to the Firebase queue. For e.g.

  ref.child('queue/specs').set({
    new_user: {
     start_state: 'add_new_user',
     in_progress_state: 'add_new_user_in_progress'
    }
  });

Here new_user is the specId that you have specified for the queue. Now when you push a task, you need to set the _state to the start_state for the spec. For e.g.

var task = {'userId': "0338ba4d-191f-4044-9af0-4c76f47aeef9", '_state': 'add_new_user'};
ref.child("queue").child("tasks").push(task);

Now this task should be picked up the queue that is created to handled tasks with specId new_user

Read this and this in the official firebase queue documentation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!