refactor(proxy): isolate event bus panics
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
8a321e2467
commit
619b3c500d
1 changed files with 9 additions and 1 deletions
10
core_impl.go
10
core_impl.go
|
|
@ -52,6 +52,9 @@ func getSplitterFactory(mode string) (func(*Config, *EventBus) Splitter, bool) {
|
|||
// LoadConfig reads and unmarshals a JSON config file.
|
||||
//
|
||||
// cfg, result := LoadConfig("config.json")
|
||||
// if !result.OK {
|
||||
// return
|
||||
// }
|
||||
func LoadConfig(path string) (*Config, Result) {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
|
|
@ -143,7 +146,12 @@ func (b *EventBus) Dispatch(e Event) {
|
|||
handlers := append([]EventHandler(nil), b.listeners[e.Type]...)
|
||||
b.mu.RUnlock()
|
||||
for _, handler := range handlers {
|
||||
handler(e)
|
||||
func() {
|
||||
defer func() {
|
||||
_ = recover()
|
||||
}()
|
||||
handler(e)
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue