Comments (8)
Because client’s main function terminates!
Please: wait_group.wait();
BTW, are you sure your encode() doesn’t have memleak?
from workflow.
About exit of the program: https://github.com/sogou/workflow/tree/master/docs/about-exit.md
from workflow.
Your implementation of append() cannot garentee you receive the whole message. You know that, right?
from workflow.
Your implementation of append() cannot garentee you receive the whole message. You know that, right?
Thanks for your reply!
For the append(): yes I know that, just want to see it works for now;
For the enocde(): I have to make the buffer a member of the message right?
from workflow.
Your implementation of append() cannot garentee you receive the whole message. You know that, right?
Thanks for your reply!
For the append(): yes I know that, just want to see it works for now;
For the enocde(): I have to make the buffer a member of the message right?
Yes. Make it a member of the message class, allocate memory in it's constructor or encode() function and release in it's destructor. But don't do this:
using NTF = WFNetworkTaskFactory<protocol::OrderMessage, protocol::OrderMessage>;
WFTestTask *task = NTF::create_client_task(TT_TCP, host, port,
retry_max,
std::move(callback));
task->set_keep_alive(30 * 1000);
task->get_resp()->buffer = new char[MAX]; // not very good.
return task;
This makes the response class non-RAII. But the response object may be destroyed and reconstructed during communication when retrial occurs. If it's not a RAII class, you have to set prepare function or make a derivation of WFNetworkTask.
from workflow.
Another question about the client: I see it is tasks that can be kept alive, but a task seems to be not thread safe. Then how to reuse the connections?
Say my architecture is Client <-> ServerA <-> ServerB, ServerA accepts stateless http requests from the Client, and passes them to ServerB on persistent tcp connections (10 for example). should I create 10 tasks and use locks to share them?
from workflow.
So you are writing a ServerA? Please refer to tutorial-05-http_proxy
Note: connections can be reused, but tasks cannot be reused by users.
from workflow.
task->set_keep_alive() sets the connection underneath to be reused or not, not the task.
For http protocol, adding http header “Connection” is a better way. Though both ways work.
from workflow.
Related Issues (20)
- 利用workflow 写了一个redis客户端程序,当传入的命令是brpop这种阻塞式命令后,redis server一段时间没数据返回就会报错 HOT 5
- 有个指针和引用问题,请教一下。 HOT 4
- C++语法问题请教一下。 HOT 2
- queue get HOT 3
- __poller_handle_listen, __poller_handle_read, __poller_handle_write等函数内部为什么都会有__poller_remove_node, 比如在__poller_handle_listen中的最后调用__poller_remove_node, 不就会把之前add进来的server fd删除了吗?
- 求一个基于 parallework 的 WFMysqlConnection demo HOT 1
- 关于redis-proxy 超时问题 HOT 8
- 关于会收到重复Http请求的问题 HOT 3
- workflow server能否在process中向另一个客户端创建http任务发送数据 还有对 workflow wait_group使用的问题 HOT 8
- 一个SeriesWork 使用上面的疑问 HOT 4
- 域名问题 HOT 5
- WFConditional可以加一个访问task的接口嘛 HOT 7
- http请求的body数据多了些内容? HOT 2
- Ubuntu23.04会有undefined reference to `SSL_ctrl'错误 HOT 4
- http server 如何将一个大文件分块传输给http client? HOT 3
- why create_repeater_task doesnt work,what I miss here? HOT 4
- windows分支使用VS2022编译成功后,_include下没有kafka相关的头文件 HOT 20
- Update Fedora CI image version HOT 1
- KAFKA客户端的几个问题 HOT 13
- 使用xmake构建遇到一样的问题 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from workflow.