-
Notifications
You must be signed in to change notification settings - Fork 669
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 - Add SMPP notifier #1464
Conversation
Signed-off-by: Ivan Milosevic <iva@blokovi.com>
remove env file Signed-off-by: Ivan Milosevic <iva@blokovi.com>
Codecov Report
@@ Coverage Diff @@
## master #1464 +/- ##
==========================================
- Coverage 70.92% 70.90% -0.02%
==========================================
Files 123 123
Lines 9564 9565 +1
==========================================
- Hits 6783 6782 -1
- Misses 2254 2256 +2
Partials 527 527
Continue to review full report at Codecov.
|
consumers/notifiers/service.go
Outdated
@@ -28,7 +28,7 @@ var ( | |||
ErrSave = errors.New("failed to subscription") | |||
|
|||
// ErrNotFound indicates a non-existent entity request. | |||
ErrNotFound = errors.New("non-existent entity") | |||
ErrNotFound = errors.New("non-existent entityty") |
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.
Fix entityty
consumers/notifiers/service_test.go
Outdated
@@ -29,7 +29,8 @@ func newService() notifiers.Service { | |||
auth := mocks.NewAuth(map[string]string{exampleUser1: exampleUser1, exampleUser2: exampleUser2, invalidUser: invalidUser}) | |||
notifier := mocks.NewNotifier() | |||
idp := uuid.NewMock() | |||
return notifiers.New(auth, repo, idp, notifier) | |||
from := "" |
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.
Mayeb better to don't use an empty string here?
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.
I agree, simply use a string literal.
@@ -68,7 +68,8 @@ func newService(tokens map[string]string) notifiers.Service { | |||
repo := mocks.NewRepo(make(map[string]notifiers.Subscription)) | |||
idp := uuid.NewMock() | |||
notif := mocks.NewNotifier() | |||
return notifiers.New(auth, repo, idp, notif) | |||
from := "" |
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.
Mayeb better to don't use an empty string here?
consumers/notifiers/service_test.go
Outdated
@@ -29,7 +29,8 @@ func newService() notifiers.Service { | |||
auth := mocks.NewAuth(map[string]string{exampleUser1: exampleUser1, exampleUser2: exampleUser2, invalidUser: invalidUser}) | |||
notifier := mocks.NewNotifier() | |||
idp := uuid.NewMock() | |||
return notifiers.New(auth, repo, idp, notifier) | |||
from := "" |
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.
I agree, simply use a string literal.
consumers/notifiers/smpp/README.md
Outdated
| MF_SMTP_NOTIFY_LOG_LEVEL | Log level for SMT Notifier (debug, info, warn, error) | error | | ||
| MF_SMTP_NOTIFY_DB_HOST | Database host address | localhost | | ||
| MF_SMTP_NOTIFY_DB_PORT | Database host port | 5432 | | ||
| MF_SMTP_NOTIFY_DB_USER | Database user | mainflux | | ||
| MF_SMTP_NOTIFY_DB_PASS | Database password | mainflux | | ||
| MF_SMTP_NOTIFY_DB | Name of the database used by the service | subscriptions | | ||
| MF_SMTP_NOTIFY_WRITER_CONFIG_PATH | Database connection SSL mode (disable, require, verify-ca, verify-full) | disable | | ||
| MF_SMTP_NOTIFY_DB_SSL_MODE | Path to the PEM encoded certificate file | | | ||
| MF_SMTP_NOTIFY_DB_SSL_CERT | Path to the PEM encoded key file | | | ||
| MF_SMTP_NOTIFY_DB_SSL_KEY | Path to the PEM encoded root certificate file | | | ||
| MF_SMTP_NOTIFY_DB_SSL_ROOT_CERT | Users service HTTP port | 8180 | | ||
| MF_SMTP_NOTIFY_HTTP_PORT | Path to server certificate in pem format | | | ||
| MF_SMTP_NOTIFY_SERVER_CERT | Path to server cert in pem format | | | ||
| MF_SMTP_NOTIFY_SERVER_KEY | Path to server key in pem format | | |
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.
SMTP docs.
consumers/notifiers/smpp/README.md
Outdated
The Subscription service using SMTP Notifier is configured using the environment variables presented in the | ||
following table. Note that any unset variables will be replaced with their | ||
default values. | ||
|
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.
Please fix README.
consumers/notifiers/smpp/notifier.go
Outdated
fmt.Println(to) | ||
fmt.Println(len(to)) |
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.
Remove.
MF_NATS_URL: ${MF_NATS_URL} | ||
MF_JAEGER_URL: ${MF_JAEGER_URL} | ||
MF_AUTH_GRPC_URL: ${MF_AUTH_GRPC_URL} | ||
MF_AUTH_GRPC_TIMEOUT: ${MF_AUTH_GRPC_TIMEOUT} |
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.
You can group SMPP-related env vars by putting these on top of the environment
section.
Signed-off-by: Ivan Milosevic <iva@blokovi.com>
consumers/notifiers/smpp/notifier.go
Outdated
if err != nil { | ||
return err | ||
} | ||
fmt.Println("Message ID:", sm.RespID()) |
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.
Remove logs.
Signed-off-by: Ivan Milosevic <iva@blokovi.com>
consumers/notifiers/smpp/notifier.go
Outdated
var _ notifiers.Notifier = (*notifier)(nil) | ||
|
||
type notifier struct { | ||
t *smpp.Transmitter |
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.
I would consider calling this struct field transmitter
, and one below transformer
. When it comes to struct fields, I find it easier to read the code - example on one of the lines below n.t.Submit()
does not tell me much as n.transmitter.Submit()
.
@nmarcetic @dusanb94 opinions?
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.
For me, both are fine. Transmitter is a bit more self-explanatory, t is shorter. When reading the code, the one will probably need to check what it is in any case.
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.
Agree @drasko @dusanb94 , readability wins. I prefer to keep variable names short in scopes (like 1-3 letters), not struct fields where they should be obvious.
Signed-off-by: Ivan Milosevic <iva@blokovi.com>
consumers/notifiers/smpp/notifier.go
Outdated
@@ -18,8 +18,8 @@ import ( | |||
var _ notifiers.Notifier = (*notifier)(nil) | |||
|
|||
type notifier struct { | |||
t *smpp.Transmitter | |||
tr transformers.Transformer | |||
transmiter *smpp.Transmitter |
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.
Typo: transmitter
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
* Add SMPP notifier Signed-off-by: Ivan Milosevic <iva@blokovi.com> * fix readme remove env file Signed-off-by: Ivan Milosevic <iva@blokovi.com> * resolve conversations Signed-off-by: Ivan Milosevic <iva@blokovi.com> * Remove debug log Signed-off-by: Ivan Milosevic <iva@blokovi.com> * Rename transmiter and transformer fields in struct Signed-off-by: Ivan Milosevic <iva@blokovi.com> * fix typo Signed-off-by: Ivan Milosevic <iva@blokovi.com>
* Add SMPP notifier Signed-off-by: Ivan Milosevic <iva@blokovi.com> * fix readme remove env file Signed-off-by: Ivan Milosevic <iva@blokovi.com> * resolve conversations Signed-off-by: Ivan Milosevic <iva@blokovi.com> * Remove debug log Signed-off-by: Ivan Milosevic <iva@blokovi.com> * Rename transmiter and transformer fields in struct Signed-off-by: Ivan Milosevic <iva@blokovi.com> * fix typo Signed-off-by: Ivan Milosevic <iva@blokovi.com>
* Add SMPP notifier Signed-off-by: Ivan Milosevic <iva@blokovi.com> * fix readme remove env file Signed-off-by: Ivan Milosevic <iva@blokovi.com> * resolve conversations Signed-off-by: Ivan Milosevic <iva@blokovi.com> * Remove debug log Signed-off-by: Ivan Milosevic <iva@blokovi.com> * Rename transmiter and transformer fields in struct Signed-off-by: Ivan Milosevic <iva@blokovi.com> * fix typo Signed-off-by: Ivan Milosevic <iva@blokovi.com>
* Add SMPP notifier Signed-off-by: Ivan Milosevic <iva@blokovi.com> * fix readme remove env file Signed-off-by: Ivan Milosevic <iva@blokovi.com> * resolve conversations Signed-off-by: Ivan Milosevic <iva@blokovi.com> * Remove debug log Signed-off-by: Ivan Milosevic <iva@blokovi.com> * Rename transmiter and transformer fields in struct Signed-off-by: Ivan Milosevic <iva@blokovi.com> * fix typo Signed-off-by: Ivan Milosevic <iva@blokovi.com>
Signed-off-by: Ivan Milosevic iva@blokovi.com
What does this do?
Adds an implementation of SMPP Notifier (capability of sending SMS notifications).