-
Notifications
You must be signed in to change notification settings - Fork 28
NOISSUE - Decouple mainflux/mproxy and mainflux/mainflux #30
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need to implement a logger. It's OK to use the Mainflux logger in examples - it's a separate package anyways. So, we only need a logger interface specified. The same goes for errors - error handling in mProxy is rather simple - can we avoid having a copy of the Mainflux errors package?
@dborovcanin I'm not sure to understand. Logger is also used in the main.go. About errors package, we are using |
For logger, I meant simply defining the logger interface and taking implementation from Mainflux. In examples and in func wrap(err error, dir direction) error {
if err == io.EOF {
return err
}
switch dir {
case up:
return errors.New(errClient.Error() + ":" + err.Error())
case down:
return errors.New(errBroker.Error() + ":" + err.Error())
default:
return err
}
} |
…rors and logger) Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
pkg/mqtt/mqtt.go
Outdated
@@ -90,7 +90,7 @@ func (p Proxy) ListenTLS(tlsCfg *tls.Config) error { | |||
|
|||
l, err := tls.Listen("tcp", p.address, tlsCfg) | |||
if err != nil { | |||
return errors.Wrap(errCreateListener, err) | |||
return errors.New(errCreateListener.Error() + ":" + err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this errCreateListener
, return an error directly.
pkg/session/session.go
Outdated
switch dir { | ||
case up: | ||
return errors.Wrap(errClient, err) | ||
return errors.New(errClient.Error() + ":" + err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for errors, you can use strings constants instead like:
return errors.New(errClient + err.Error())
I quickly benchmarked errors.New(errClient + err.Error())
vs fmt.Errorf
and for this simple case, it looks like simple +
is the most efficient.
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Manuel Imperiale manuel.imperiale@gmail.com