-
Notifications
You must be signed in to change notification settings - Fork 610
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
Can wire help us to close server in order? #346
Comments
Hey, @somniapotato did you find any workflow that works for you? There are Cleanup functions but I'm thinking is it good for graceful stop or is there some limitations |
This is very useful. Now when I exit gracefully, |
@MistaTwista I tried testing cleanup functionality and you still have to manually call the cleanups. I think what @somniapotato is trying to say here is to automatically call the cleanups. Correct me if I am wrong here @MistaTwista This is what I tried. package main
import (
"fmt"
"github.com/google/wire"
)
type Foo struct {
Name string
}
func NewProvider() (Foo, func()) {
return Foo{Name: "hello!"}, func() {
fmt.Println("running cleanup for Foo!")
}
}
func main() {
foo, cleanup := InitializeEvent()
cleanup()
fmt.Println("The name is: ", foo.Name)
}
func InitializeEvent() (Foo, func()) {
wire.Build(NewProvider)
return Foo{}, func() {}
} |
For example, if my provider like this:
wire.Build(InitServer1, InitServer2, InitServer3)
Server3 depends on Server2
Server2 depends on Server1
When the whole server want to gracefully stop, can wire help us to close Server3 first, then Server2, Server1?
Considering that wire already know the injection sequence, I thought it could know the quit sequence too.
The text was updated successfully, but these errors were encountered: