fix error when add stream

This commit is contained in:
Nam Huynh 2021-10-08 11:33:32 +07:00
parent 5e55d86e7e
commit 18da2c1372
1 changed files with 2 additions and 7 deletions

View File

@ -10,15 +10,10 @@ import (
// AddStream add new stream, with default config
func AddStream(name string, subjects []string) error {
// Get info about the stream
stream, err := natsJS.StreamInfo(name)
if err != nil {
msg := fmt.Sprintf("error getting stream info: %s", err.Error())
return errors.New(msg)
}
stream, _ := natsJS.StreamInfo(name)
// If stream not found, create new
if stream == nil {
_, err = natsJS.AddStream(&nats.StreamConfig{
_, err := natsJS.AddStream(&nats.StreamConfig{
Name: name,
Subjects: subjects,
Storage: nats.FileStorage,