Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOISSUE - Fix writers loadSubjectsConfig if file is missing #1094

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions writers/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
"github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/transformers"
"github.com/mainflux/mainflux/transformers/senml"
nats "github.com/nats-io/nats.go"
"github.com/nats-io/nats.go"
)

var (
errOpenConfFile = errors.New("Unable to open configuration file")
errOpenConfFile = errors.New("Unable to open configuration file")
errParseConfFile = errors.New("Unable to parse configuration file")
)

Expand All @@ -40,7 +40,7 @@ func Start(nc *nats.Conn, repo MessageRepository, transformer transformers.Trans
logger: logger,
}

subjects, err := LoadSubjectsConfig(subjectsCfgPath)
subjects, err := loadSubjectsConfig(subjectsCfgPath)
if err != nil {
logger.Warn(fmt.Sprintf("Failed to load subjects: %s", err))
}
Expand All @@ -51,7 +51,7 @@ func Start(nc *nats.Conn, repo MessageRepository, transformer transformers.Trans
return err
}
}
return err
return nil
}

func (c *consumer) consume(m *nats.Msg) {
Expand Down Expand Up @@ -86,7 +86,7 @@ type subjectsConfig struct {
Subjects filterConfig `toml:"subjects"`
}

func LoadSubjectsConfig(subjectsConfigPath string) ([]string, error) {
func loadSubjectsConfig(subjectsConfigPath string) ([]string, error) {
data, err := ioutil.ReadFile(subjectsConfigPath)
if err != nil {
return []string{mainflux.InputChannels}, errors.Wrap(errOpenConfFile, err)
Expand All @@ -97,5 +97,5 @@ func LoadSubjectsConfig(subjectsConfigPath string) ([]string, error) {
return []string{mainflux.InputChannels}, errors.Wrap(errParseConfFile, err)
}

return subjectsCfg.Subjects.List, err
return subjectsCfg.Subjects.List, nil
}