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

Why don't you just use func for logic in existing frameworks? #4147

Open
Luoxin opened this issue May 13, 2024 · 2 comments
Open

Why don't you just use func for logic in existing frameworks? #4147

Luoxin opened this issue May 13, 2024 · 2 comments

Comments

@Luoxin
Copy link

Luoxin commented May 13, 2024

The default code generation generates a NewXXXLogic inside the handler, which then calls the relevant methods. Why not just generate a func to call it instead of creating a new object. In highly concurrent scenarios, the creation of such a new object without adding sync.pool is likely to result in additional memory requests and destruction, which would not occur if the func was used directly.

@kevwan
Copy link
Contributor

kevwan commented May 14, 2024

Recommend to use sync.Pool only when you really need it.

@Luoxin
Copy link
Author

Luoxin commented May 15, 2024

Recommend to use sync.Pool only when you really need it.

The core of my question is not sync.Pool, but why the design should use oop instead of func, so there will be some performance loss, is not it? And here the struct is not a transaction that must exist, because the design itself has been designed for the monolithic service scenario to do the design of the sub-package, and for micro-services, the function is the service, there is no need to use the struct. I'm trying to understand what special considerations are involved in using such a complex technical solution that I hadn't considered before.

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