add graceful shutdown, add reconnect on connection loss
This commit is contained in:
18
internal/foundry/helpers.go
Normal file
18
internal/foundry/helpers.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package foundry
|
||||
|
||||
import "fmt"
|
||||
|
||||
func (f *FoundryApi) background(fn func()) {
|
||||
f.wg.Add(1)
|
||||
go func() {
|
||||
defer f.wg.Done()
|
||||
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
f.transport.Logger.Error(fmt.Sprintf("%s", err))
|
||||
}
|
||||
}()
|
||||
|
||||
fn()
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user