// Close closes each of the underlying writers. func (mmw MultiMessageWriter) Close() error { errs := errset.ErrSet{} for _, w := range mmw.Writers { if err := w.Close(); err != nil { errs = append(errs, err) } } return errs.ReturnValue() }
// WriteMessage writes the message `m` to each of the fanout MessageWriters. If // any of the writers fail, the others are still tried. Returns a non-nil error // if any of the writers fail. func (mmw MultiMessageWriter) WriteMessage(m Message) error { errCh := make(chan error, len(mmw.Writers)) for _, w := range mmw.Writers { go func(w MessageWriter) { errCh <- w.WriteMessage(m) }(w) } errs := errset.ErrSet{} for _ = range mmw.Writers { err := <-errCh if err != nil { errs = append(errs, err) } } return errs.ReturnValue() }