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

fix officialaccount part in Issue 590 #591

Merged
merged 3 commits into from Aug 8, 2022
Merged

Conversation

waro163
Copy link
Contributor

@waro163 waro163 commented Jul 31, 2022

主要是修改了公众号中获取各个能力部分,采用单例模式。避免每次获取都重新创建。
除公众号外,在其他部分中也同样存在该问题。

@waro163
Copy link
Contributor Author

waro163 commented Aug 5, 2022

@silenceper @houseme 有任何其他想法或者需要讨论的么?还是有别的设计思路可以解决?

@houseme
Copy link
Collaborator

houseme commented Aug 5, 2022

@silenceper @houseme 有任何其他想法或者需要讨论的么?还是有别的设计思路可以解决?

并发的时候,会不会重复
singleflight.Group

@waro163
Copy link
Contributor Author

waro163 commented Aug 6, 2022

@silenceper @houseme 有任何其他想法或者需要讨论的么?还是有别的设计思路可以解决?

并发的时候,会不会重复 singleflight.Group

对于只是初始化一个实例来说,使用singleflight也太重了,而且也会增加复杂性。
如果考虑并发可能会导致重复,那是否Once.do是一个更加合适的选择?

或者更加简洁的方式就是在初始化OfficialAccount的时候,全部都初始化一次,这样操作起来最简便。
这样就无需关心并发重复初始化的问题,但是该方式相对懒加载的方式来说,带来的就是轻微的内存消耗,不过这种消耗我个人觉得是没有太大关系的。

@houseme houseme requested a review from silenceper August 6, 2022 08:25
Copy link
Owner

@silenceper silenceper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以的

@silenceper silenceper merged commit 27e18b6 into silenceper:v2 Aug 8, 2022
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

Successfully merging this pull request may close these issues.

None yet

3 participants