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

* Init commit - implement errors package on things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * things service errors issue Signed-off-by: Ivan Milošević <iva@blokovi.com> * Decode errors Add authn service to run script Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * service_test Signed-off-by: Ivan Milošević <iva@blokovi.com> * debug lines Signed-off-by: Ivan Milošević <iva@blokovi.com> * Regulate tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Improve errors in Redis Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove dead code Inline if conditions Rename err var Signed-off-by: Ivan Milošević <iva@blokovi.com> * Transform errors messages to lowercase Signed-off-by: Ivan Milošević <iva@blokovi.com> * improve errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * modify wrap method inline wrapping errors in redis Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add copyright to errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * wrapping nil error returns wrapper (instead of nil) Signed-off-by: Ivan Milošević <iva@blokovi.com> * move response messages in test to vars Signed-off-by: Ivan Milošević <iva@blokovi.com> * golangcibot review fix Signed-off-by: Ivan Milošević <iva@blokovi.com> * golangbot fix review in transport Signed-off-by: Ivan Milošević <iva@blokovi.com>
84 lines
2.8 KiB
Go
84 lines
2.8 KiB
Go
// Copyright (c) Mainflux
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package things
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// Channel represents a Mainflux "communication group". This group contains the
|
|
// things that can exchange messages between eachother.
|
|
type Channel struct {
|
|
ID string
|
|
Owner string
|
|
Name string
|
|
Metadata map[string]interface{}
|
|
}
|
|
|
|
// ChannelsPage contains page related metadata as well as list of channels that
|
|
// belong to this page.
|
|
type ChannelsPage struct {
|
|
PageMetadata
|
|
Channels []Channel
|
|
}
|
|
|
|
// ChannelRepository specifies a channel persistence API.
|
|
type ChannelRepository interface {
|
|
// Save persists multiple channels. Channels are saved using a transaction. If one channel
|
|
// fails then none will be saved. Successful operation is indicated by non-nil
|
|
// error response.
|
|
Save(context.Context, ...Channel) ([]Channel, error)
|
|
|
|
// Update performs an update to the existing channel. A non-nil error is
|
|
// returned to indicate operation failure.
|
|
Update(context.Context, Channel) error
|
|
|
|
// RetrieveByID retrieves the channel having the provided identifier, that is owned
|
|
// by the specified user.
|
|
RetrieveByID(context.Context, string, string) (Channel, error)
|
|
|
|
// RetrieveAll retrieves the subset of channels owned by the specified user.
|
|
RetrieveAll(context.Context, string, uint64, uint64, string, Metadata) (ChannelsPage, error)
|
|
|
|
// RetrieveByThing retrieves the subset of channels owned by the specified
|
|
// user and have specified thing connected to them.
|
|
RetrieveByThing(context.Context, string, string, uint64, uint64) (ChannelsPage, error)
|
|
|
|
// Remove removes the channel having the provided identifier, that is owned
|
|
// by the specified user.
|
|
Remove(context.Context, string, string) error
|
|
|
|
// Connect adds things to the channel's list of connected things.
|
|
Connect(context.Context, string, []string, []string) error
|
|
|
|
// Disconnect removes thing from the channel's list of connected
|
|
// things.
|
|
Disconnect(context.Context, string, string, string) error
|
|
|
|
// HasThing determines whether the thing with the provided access key, is
|
|
// "connected" to the specified channel. If that's the case, it returns
|
|
// thing's ID.
|
|
HasThing(context.Context, string, string) (string, error)
|
|
|
|
// HasThingByID determines whether the thing with the provided ID, is
|
|
// "connected" to the specified channel. If that's the case, then
|
|
// returned error will be nil.
|
|
HasThingByID(context.Context, string, string) error
|
|
}
|
|
|
|
// ChannelCache contains channel-thing connection caching interface.
|
|
type ChannelCache interface {
|
|
// Connect channel thing connection.
|
|
Connect(context.Context, string, string) error
|
|
|
|
// HasThing checks if thing is connected to channel.
|
|
HasThing(context.Context, string, string) bool
|
|
|
|
// Disconnects thing from channel.
|
|
Disconnect(context.Context, string, string) error
|
|
|
|
// Removes channel from cache.
|
|
Remove(context.Context, string) error
|
|
}
|