Mainflux.mainflux/http/adapter.go

49 lines
1.1 KiB
Go
Raw Normal View History

// Copyright (c) Mainflux
// SPDX-License-Identifier: Apache-2.0
2018-05-11 07:00:10 +08:00
// Package http contains the domain concept definitions needed to support
// Mainflux http adapter service functionality.
package http
2019-07-18 21:01:09 +08:00
import (
"context"
"github.com/mainflux/mainflux"
NOISSUE - Refactor messaging (#1141) * Refactor messaging Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename SubscribeHandler to MessageHandler Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove `Auth` event logs Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update message pubsub APi Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix topics handling Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update CoAP adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update Twins service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update LoRa adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update OPC UA adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove broker package Package `broker` is conceptually renamed to package `nats`. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update makefile Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add comment explanation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix MQTT adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typo Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move NATS pub/sub implementation to pubsub pkg Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove an empty line in main methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move messaging-related code to messaging package Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Twins mocks Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change Occurred back to Created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix tranformer test Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix message proto commands Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Replace string literal with constant Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove alias from main method Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change messaging pubsub alias Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename occured to created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Handle NATS connection in the NATS PubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename n to pub/pubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2020-04-28 17:02:35 +08:00
"github.com/mainflux/mainflux/messaging"
2019-07-18 21:01:09 +08:00
)
NOISSUE - Create broker package for NATS (#1080) * NOISSUEE - Create broker package for NATS Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Create funcs to return NATS connection Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * mv os.exit to main Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix Reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix tests and typos Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix CI Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Unify Publisher and Subscriber interfaces Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Rename Nats interface Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Mv message.pb.go, messsage.proto and topics.go to broker directory Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix go.mod Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Use mainflux broker for writers and twins services Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix go.mod Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix twins tests Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix make proto Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix message.proto Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix golangcibot Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * regenerate message.pb.go Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix comment Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix comment Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix make proto Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Add NATS errors Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-04-02 03:22:13 +08:00
// Service specifies coap service API.
type Service interface {
// Publish Messssage
NOISSUE - Refactor messaging (#1141) * Refactor messaging Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename SubscribeHandler to MessageHandler Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove `Auth` event logs Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update message pubsub APi Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix topics handling Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update CoAP adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update Twins service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update LoRa adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update OPC UA adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove broker package Package `broker` is conceptually renamed to package `nats`. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update makefile Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add comment explanation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix MQTT adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typo Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move NATS pub/sub implementation to pubsub pkg Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove an empty line in main methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move messaging-related code to messaging package Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Twins mocks Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change Occurred back to Created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix tranformer test Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix message proto commands Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Replace string literal with constant Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove alias from main method Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change messaging pubsub alias Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename occured to created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Handle NATS connection in the NATS PubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename n to pub/pubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2020-04-28 17:02:35 +08:00
Publish(ctx context.Context, token string, msg messaging.Message) error
NOISSUE - Create broker package for NATS (#1080) * NOISSUEE - Create broker package for NATS Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Create funcs to return NATS connection Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * mv os.exit to main Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix Reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix tests and typos Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix CI Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Unify Publisher and Subscriber interfaces Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Rename Nats interface Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Mv message.pb.go, messsage.proto and topics.go to broker directory Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix go.mod Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Use mainflux broker for writers and twins services Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix go.mod Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix twins tests Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix make proto Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix message.proto Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix golangcibot Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * regenerate message.pb.go Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix comment Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix comment Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix make proto Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Add NATS errors Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-04-02 03:22:13 +08:00
}
var _ Service = (*adapterService)(nil)
type adapterService struct {
NOISSUE - Refactor messaging (#1141) * Refactor messaging Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename SubscribeHandler to MessageHandler Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove `Auth` event logs Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update message pubsub APi Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix topics handling Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update CoAP adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update Twins service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update LoRa adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update OPC UA adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove broker package Package `broker` is conceptually renamed to package `nats`. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update makefile Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add comment explanation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix MQTT adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typo Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move NATS pub/sub implementation to pubsub pkg Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove an empty line in main methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move messaging-related code to messaging package Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Twins mocks Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change Occurred back to Created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix tranformer test Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix message proto commands Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Replace string literal with constant Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove alias from main method Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change messaging pubsub alias Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename occured to created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Handle NATS connection in the NATS PubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename n to pub/pubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2020-04-28 17:02:35 +08:00
publisher messaging.Publisher
things mainflux.ThingsServiceClient
}
2018-05-11 07:00:10 +08:00
// New instantiates the HTTP adapter implementation.
NOISSUE - Refactor messaging (#1141) * Refactor messaging Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename SubscribeHandler to MessageHandler Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove `Auth` event logs Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update message pubsub APi Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix topics handling Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update CoAP adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update Twins service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update LoRa adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update OPC UA adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove broker package Package `broker` is conceptually renamed to package `nats`. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update makefile Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add comment explanation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix MQTT adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typo Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move NATS pub/sub implementation to pubsub pkg Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove an empty line in main methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move messaging-related code to messaging package Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Twins mocks Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change Occurred back to Created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix tranformer test Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix message proto commands Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Replace string literal with constant Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove alias from main method Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change messaging pubsub alias Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename occured to created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Handle NATS connection in the NATS PubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename n to pub/pubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2020-04-28 17:02:35 +08:00
func New(publisher messaging.Publisher, things mainflux.ThingsServiceClient) Service {
2019-07-18 21:01:09 +08:00
return &adapterService{
NOISSUE - Refactor messaging (#1141) * Refactor messaging Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename SubscribeHandler to MessageHandler Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove `Auth` event logs Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update message pubsub APi Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix topics handling Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update CoAP adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update Twins service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update LoRa adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update OPC UA adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove broker package Package `broker` is conceptually renamed to package `nats`. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update makefile Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add comment explanation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix MQTT adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typo Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move NATS pub/sub implementation to pubsub pkg Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove an empty line in main methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move messaging-related code to messaging package Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Twins mocks Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change Occurred back to Created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix tranformer test Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix message proto commands Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Replace string literal with constant Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove alias from main method Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change messaging pubsub alias Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename occured to created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Handle NATS connection in the NATS PubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename n to pub/pubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2020-04-28 17:02:35 +08:00
publisher: publisher,
things: things,
2019-07-18 21:01:09 +08:00
}
}
NOISSUE - Refactor messaging (#1141) * Refactor messaging Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename SubscribeHandler to MessageHandler Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove `Auth` event logs Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update message pubsub APi Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix topics handling Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update CoAP adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update Twins service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update LoRa adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update OPC UA adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove broker package Package `broker` is conceptually renamed to package `nats`. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update makefile Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add comment explanation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix MQTT adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typo Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move NATS pub/sub implementation to pubsub pkg Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove an empty line in main methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move messaging-related code to messaging package Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Twins mocks Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change Occurred back to Created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix tranformer test Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix message proto commands Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Replace string literal with constant Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove alias from main method Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change messaging pubsub alias Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename occured to created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Handle NATS connection in the NATS PubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename n to pub/pubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2020-04-28 17:02:35 +08:00
func (as *adapterService) Publish(ctx context.Context, token string, msg messaging.Message) error {
ar := &mainflux.AccessByKeyReq{
2019-07-18 21:01:09 +08:00
Token: token,
NOISSUE - Refactor messaging (#1141) * Refactor messaging Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename SubscribeHandler to MessageHandler Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove `Auth` event logs Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update message pubsub APi Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix topics handling Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update CoAP adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update Twins service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update LoRa adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update OPC UA adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove broker package Package `broker` is conceptually renamed to package `nats`. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update makefile Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add comment explanation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix MQTT adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typo Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move NATS pub/sub implementation to pubsub pkg Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove an empty line in main methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move messaging-related code to messaging package Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Twins mocks Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change Occurred back to Created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix tranformer test Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix message proto commands Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Replace string literal with constant Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove alias from main method Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change messaging pubsub alias Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename occured to created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Handle NATS connection in the NATS PubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename n to pub/pubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2020-04-28 17:02:35 +08:00
ChanID: msg.Channel,
2019-07-18 21:01:09 +08:00
}
thid, err := as.things.CanAccessByKey(ctx, ar)
2019-07-18 21:01:09 +08:00
if err != nil {
return err
}
msg.Publisher = thid.GetValue()
NOISSUE - Refactor messaging (#1141) * Refactor messaging Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename SubscribeHandler to MessageHandler Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove `Auth` event logs Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update message pubsub APi Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix topics handling Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update CoAP adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update Twins service Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update LoRa adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update OPC UA adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove broker package Package `broker` is conceptually renamed to package `nats`. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update makefile Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Add comment explanation Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix MQTT adapter Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typo Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move NATS pub/sub implementation to pubsub pkg Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove an empty line in main methods Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Move messaging-related code to messaging package Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix Twins mocks Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change Occurred back to Created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix tranformer test Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix message proto commands Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Replace string literal with constant Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove alias from main method Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Change messaging pubsub alias Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename occured to created Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Handle NATS connection in the NATS PubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Rename n to pub/pubSub Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix typos Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2020-04-28 17:02:35 +08:00
return as.publisher.Publish(msg.Channel, msg)
}