Messaging: send warnings and errors to ui (#6351)

This commit is contained in:
andig 2023-02-21 21:30:39 +01:00 • committed by GitHub
parent d35170955e
commit ff7ae36967
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 71 additions and 34 deletions

View file

@ -203,25 +203,26 @@ func configureEEBus(conf map[string]interface{}) error {
}
// setup messaging
func configureMessengers(conf messagingConfig, valueChan chan util.Param, cache *util.Cache) (chan push.Event, error) {
messageChan := make(chan push.Event, 1)
func configureMessengers(conf messagingConfig, eventChan <-chan push.Event, valueChan chan util.Param, cache *util.Cache) error {
pushHub, err := push.NewHub(conf.Events, cache)
if pushHub != nil {
go pushHub.Run(eventChan, valueChan)
}
messageHub, err := push.NewHub(conf.Events, cache)
if err != nil {
return messageChan, fmt.Errorf("failed configuring push services: %w", err)
return fmt.Errorf("failed configuring push services: %w", err)
}
for _, service := range conf.Services {
impl, err := push.NewFromConfig(service.Type, service.Other)
if err != nil {
return messageChan, fmt.Errorf("failed configuring push service %s: %w", service.Type, err)
return fmt.Errorf("failed configuring push service %s: %w", service.Type, err)
}
messageHub.Add(impl)
pushHub.Add(impl)
}
go messageHub.Run(messageChan, valueChan)
return messageChan, nil
return nil
}
func configureTariffs(conf tariffConfig) (tariff.Tariffs, error) {