Skip to content

Commit

Permalink
Fix remarks and add Readme
Browse files Browse the repository at this point in the history
Signed-off-by: dusanb94 <[email protected]>
  • Loading branch information
dborovcanin committed Jan 11, 2021
1 parent fd3005c commit 1cbbc65
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
19 changes: 9 additions & 10 deletions consumers/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Writers
# Consumers

Writers provide an implementation of various `message writers`.
Message writers are services that normalize (in `SenML` format)
Mainflux messages and store them in specific data store.
Consumers provide an abstraction of various `Mainflux consumers`.
Mainflux consumer is a generic service that can handle received messages - consume them.
The message is not necessarily a Mainflux message - before consuming, Mainflux message can
be transformed into any valid format that specific consumer can understand. For example,
writers are consumers that can take a SenML or JSON message and store it.

Writers are optional services and are treated as plugins. In order to
run writer services, core services must be up and running. For more info
on the platform core services with its dependencies, please check out
the [Docker Compose][compose] file.
Consumers are optional services and are treated as plugins. In order to
run consumer services, core services must be up and running.

For an in-depth explanation of the usage of `writers`, as well as thorough
For an in-depth explanation of the usage of `consumers`, as well as thorough
understanding of Mainflux, please check out the [official documentation][doc].

[doc]: http://mainflux.readthedocs.io
[compose]: ../docker/docker-compose.yml
2 changes: 1 addition & 1 deletion consumers/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ package consumers
// Consumer specifies message consuming API.
type Consumer interface {
// Consume method is used to consumed received messages.
// A non-nil error is returned to indicate operation failure.
// A non-nil error is returned to indicate operation failure.
Consume(messages interface{}) error
}
4 changes: 2 additions & 2 deletions consumers/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func Start(sub messaging.Subscriber, consumer Consumer, transformer transformers
}

for _, subject := range subjects {
if err := sub.Subscribe(subject, handle(transformer, consumer)); err != nil {
if err := sub.Subscribe(subject, handler(transformer, consumer)); err != nil {
return err
}
}
return nil
}

func handle(t transformers.Transformer, c Consumer) messaging.MessageHandler {
func handler(t transformers.Transformer, c Consumer) messaging.MessageHandler {
return func(msg messaging.Message) error {
m := interface{}(msg)
var err error
Expand Down

0 comments on commit 1cbbc65

Please sign in to comment.