frp
frp copied to clipboard
[Feature Request] Support Client Service Custom Context
Describe the feature request
First of all, this is a fantastic project. We use this as a library, and I hope that in the future it will be better designed to support usage as a library. When creating a new client service, I do not have the option to pass in my own context, rather the service struct creates and maintains it's own context.
func NewService(cfg config.ClientCommonConf, pxyCfgs map[string]config.ProxyConf, visitorCfgs map[string]config.VisitorConf, cfgFile string) (svr *Service, err error) {
ctx, cancel := context.WithCancel(context.Background())
svr = &Service{
It would be easier if I could specify my own context like this
svc := client.NewService(...)
svc.Run(ctx)
As it stands today, I have to hack my way around this
svc := client.NewService(...)
go func() {
<-ctx.Done()
svc.Close()
}
svc.Run()
Describe alternatives you've considered
No response
Affected area
- [ ] Docs
- [ ] Installation
- [ ] Performance and Scalability
- [ ] Security
- [X] User Experience
- [ ] Test and Release
- [ ] Developer Infrastructure
- [X] Client Plugin
- [ ] Server Plugin
- [ ] Extensions
- [ ] Others
Yes. We are doing some code refactoring. Used as a third-party library is also one of aims.
Unrelated but are there plans to clean up the logging implementation and use a simple interface rather than registering named loggers and then configuring which named logger to use?
Unrelated but are there plans to clean up the logging implementation and use a simple interface rather than registering named loggers and then configuring which named logger to use?
Good point.
Thank you!