fix(streams): handle non-string elements in slice source for NewStream

This commit is contained in:
Sergey Krashevich
2024-03-19 09:46:56 +03:00
parent 5fa31fe4d6
commit 9fc3d91a17
+7 -2
View File
@@ -22,8 +22,13 @@ func NewStream(source any) *Stream {
}
case []any:
s := new(Stream)
for _, source := range source {
s.producers = append(s.producers, NewProducer(source.(string)))
for _, src := range source {
str, ok := src.(string)
if !ok {
log.Error().Msgf("[stream] NewStream: Expected string, got %v", src)
continue
}
s.producers = append(s.producers, NewProducer(str))
}
return s
case map[string]any: