firebase / firebase/firebase-admin-node

[FR] Cloud Tasks Testing, Emulation, Management

Đang mở
#1,830 1 bình luận 4 reaction 1 người được giao Được @inlined nhận Xem trên GitHub
api: functions type: feature request
Ngôn ngữ chính
TypeScript
Star
1.7k
Fork
419
Merge trung bình
3 ngày 10 giờ
Pull request đã merge (30 ngày)
16

Mô tả

First of all, thx for improvements made for Firebase users with regards to Cloud Tasks product.

However there are few crucial missing pieces:

### Emulator support
Based on current documentation, only way to use cloud tasks within emulated environment is to call them via HTTP endpoint.

We can exploit this and make basic function to enqueue tasks in our code:
```
export async function enqueueTask(functionName: string, data: any) {
const url = `http://0.0.0.0:5001/${process.env.GCLOUD_PROJECT}/${process.env.FUNCTION_REGION}/${functionName}`;
console.log(url);
const res = await axios.default({
method: 'POST', url: url, data: {
'data': data,
}
},);

return res;
}
```

But this requires flags inside code, to not use internal SDK but this function. Surely we can have emulator support calling it in same manner, at least.

### Testing
Cloud Tasks cannot be "wrapped" in same manner as triggers / cloud functions to write integration tests.
Again, only option is to use function mentioned above to "call" task, but HTTP endpoint DOES NOT return any meaningful response.

It waits until task is completed, BUT it does NOT return task's payload, nor rejects/handles thrown Errors.

### Tasks Management
And finally, current equeue menthod DOES NOT return TaskID, and SDK does not provide any methods to:
- identify tasks
- cancel tasks
- check their status

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.