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

Chore: 应用级很可用的 example,长久持有 client 并注释描述清楚 #222

Open
CherishCai opened this issue Apr 19, 2024 · 2 comments
Labels
chore Chore for code good first issue Good for newcomers

Comments

@CherishCai
Copy link
Collaborator

CherishCai commented Apr 19, 2024

新增一个应用级很可用的 example,不少用户在方法级构建客户端调 api 就完事了,这样不符合用法。

需要有样例长久持有 client 并添加注释描述清楚。

一般大部分情况下,应用下仅需一个客户端,而且需要长期持有直至应用停止。
因为它内部会初始化与服务端的长链接,后续的数据交互及变更订阅,都是实时地通过长链接告知客户端的。

@CherishCai CherishCai added chore Chore for code good first issue Good for newcomers labels Apr 19, 2024
@CherishCai CherishCai changed the title Chore: example 改成长久持有 client 并注释描述清楚 Chore: 应用级很可用的 example,长久持有 client 并注释描述清楚 Apr 19, 2024
@bell152
Copy link

bell152 commented Apr 19, 2024

刚刚遇到类似问题,通过Arc::new(Box::new(config_service)); 封装config_service到全局State中就可以了。

@CherishCai
Copy link
Collaborator Author

@bell152 现在用 std::sync::LazyLock 也很不错

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Chore for code good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants