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

Cleanup: eliminating stopCh defined everywhere #497

Closed
hzxuzhonghu opened this issue Jul 5, 2024 · 3 comments · Fixed by #506
Closed

Cleanup: eliminating stopCh defined everywhere #497

hzxuzhonghu opened this issue Jul 5, 2024 · 3 comments · Fixed by #506
Assignees

Comments

@hzxuzhonghu
Copy link
Member

This is the searching result.

https://github.com/search?q=repo%3Akmesh-net%2Fkmesh%20make(chan%20struct%7B%7D)&type=code

By passing stop channel to each module's Start/Run method, we can control each module globally. And even more, by doing so, we could further eliminate defer stop stuff

	c := controller.NewController(configs, bpfLoader.GetBpfKmeshWorkload(), configs.BpfConfig.BpfFsPath, configs.BpfConfig.EnableBpfLog)
	if err := c.Start(); err != nil {
		return err
	}
	log.Info("controller Start successful")
	defer c.Stop()
@Okabe-Rintarou-0
Copy link
Member

Okabe-Rintarou-0 commented Jul 5, 2024

What about using context.WithCancel, it's a native way to simplify goroutine canceling.

@Okabe-Rintarou-0
Copy link
Member

/assign

@hzxuzhonghu
Copy link
Member Author

No much difference, ctx also good

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

Successfully merging a pull request may close this issue.

2 participants