Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有没有自定义http请求的返回时间 #1695

Open
sumilaw opened this issue Feb 13, 2025 · 3 comments
Open

有没有自定义http请求的返回时间 #1695

sumilaw opened this issue Feb 13, 2025 · 3 comments

Comments

@sumilaw
Copy link

sumilaw commented Feb 13, 2025

我使用workflow处理http请求,在这期间希望非阻塞的访问数据库,因此会出现void process(WFHttpTask *server_task)函数结束了,数据库的数据还没有访问到,同时http请求就被直接返回了,因此想知道有没有办法显式的控制http请求的返回,能让我在得到数据库数据并处理完成后,再将请求返回

@sumilaw
Copy link
Author

sumilaw commented Feb 13, 2025

我用的数据库是postgresql,该如何把一个对于该数据库的访问任务添加到series里

@Barenboim
Copy link
Contributor

Barenboim commented Feb 13, 2025

可以的啊。使用WFCounterTask(或WFMailboxTask,相比counter可以传达一个void *的信息)把series堵住,另外一个线程的postgres任务返回之后,打开counter就可以了。可以看一下这个文档:https://github.com/sogou/workflow/blob/master/docs/about-counter.md#server%E4%B8%8E%E5%85%B6%E5%AE%83%E5%BC%82%E6%AD%A5%E5%BC%95%E6%93%8E%E7%BB%93%E5%90%88%E4%BD%BF%E7%94%A8

之前有用户实现过workflow的postgres的client,不过没有看他开源。否则就可以像mysql一样直接访问了。

@Barenboim
Copy link
Contributor

你的场景确实使用WFMailboxTask会好一点,方便传递信息。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants