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

* MF-1061 - Add PageMetadata to readers Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix merge conflicts Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Mv Total to MessagesPage Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix review Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix readers mock and add filters tests Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Add Total check and allow combinations of query parameters Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Use slices length as Total Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Simplify readers mock Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Add empty lines Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
45 lines
1.4 KiB
Go
45 lines
1.4 KiB
Go
// Copyright (c) Mainflux
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package readers
|
|
|
|
import "errors"
|
|
|
|
// ErrNotFound indicates that requested entity doesn't exist.
|
|
var ErrNotFound = errors.New("entity not found")
|
|
|
|
// MessageRepository specifies message reader API.
|
|
type MessageRepository interface {
|
|
// ReadAll skips given number of messages for given channel and returns next
|
|
// limited number of messages.
|
|
ReadAll(chanID string, pm PageMetadata) (MessagesPage, error)
|
|
}
|
|
|
|
// Message represents any message format.
|
|
type Message interface{}
|
|
|
|
// MessagesPage contains page related metadata as well as list of messages that
|
|
// belong to this page.
|
|
type MessagesPage struct {
|
|
PageMetadata
|
|
Total uint64
|
|
Messages []Message
|
|
}
|
|
|
|
// PageMetadata represents the parameters used to create database queries
|
|
type PageMetadata struct {
|
|
Offset uint64 `json:"offset,omitempty"`
|
|
Limit uint64 `json:"limit,omitempty"`
|
|
Subtopic string `json:"subtopic,omitempty"`
|
|
Publisher string `json:"publisher,omitempty"`
|
|
Protocol string `json:"protocol,omitempty"`
|
|
Name string `json:"name,omitempty"`
|
|
Value float64 `json:"v,omitempty"`
|
|
BoolValue bool `json:"vb,omitempty"`
|
|
StringValue string `json:"vs,omitempty"`
|
|
DataValue string `json:"vd,omitempty"`
|
|
From float64 `json:"from,omitempty"`
|
|
To float64 `json:"to,omitempty"`
|
|
Format string `json:"format,omitempty"`
|
|
}
|