mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-27 13:48:49 +08:00

* Add pagination to clients and channels endpoints Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com> * Refactor code Change method signature and rename Bulk methods back to All. Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com> * Rename transport_test.go to endpoint_test.go Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com> * Fix manager tests to support pagination Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com> * Add default offset and limit support Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com> * Update docs Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com> * Update tests to support pagination - Move maxLimitSize checking to request validation. - Add tests to support pagination. Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com> * Fix handling query params for pagination Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com> * Fix empty result set Return empty results if invalid offset and limit is passed to channel and client repository. Update tests accordingly. Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com> * Update manager API docs Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com> * Fix response to invalid limit query param Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com> * Remove offset and limmit checks in repository methods Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>
38 lines
973 B
Go
38 lines
973 B
Go
package ws
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/mainflux/mainflux"
|
|
)
|
|
|
|
var (
|
|
// ErrFailedMessagePublish indicates that message publishing failed.
|
|
ErrFailedMessagePublish = errors.New("failed to publish message")
|
|
|
|
// ErrFailedSubscription indicates that client couldn't subscribe to specified channel.
|
|
ErrFailedSubscription = errors.New("failed to subscribe to a channel")
|
|
|
|
// ErrFailedConnection indicates that service couldn't connect to message broker.
|
|
ErrFailedConnection = errors.New("failed to connect to message broker")
|
|
)
|
|
|
|
// Service specifies web socket service API.
|
|
type Service interface {
|
|
mainflux.MessagePublisher
|
|
// Subscribes to channel with specified id.
|
|
Subscribe(string, Channel) error
|
|
}
|
|
|
|
// Channel is used for receiving and sending messages.
|
|
type Channel struct {
|
|
Messages chan mainflux.RawMessage
|
|
Closed chan bool
|
|
}
|
|
|
|
// Close channel and stop message transfer.
|
|
func (channel Channel) Close() {
|
|
close(channel.Messages)
|
|
close(channel.Closed)
|
|
}
|