Documentation ¶
Overview ¶
Package manager contains the domain concept definitions needed to support Mainflux manager service functionality.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrConflict indicates usage of the existing email during account // registration. ErrConflict error = errors.New("email already taken") // ErrMalformedEntity indicates malformed entity specification (e.g. // invalid username or password). ErrMalformedEntity error = errors.New("malformed entity specification") // when accessing a protected resource. ErrUnauthorizedAccess error = errors.New("missing or invalid credentials provided") // ErrNotFound indicates a non-existent entity request. ErrNotFound error = errors.New("non-existent entity") )
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct { Owner string `json:"-"` ID string `json:"id"` Name string `json:"name,omitempty"` Connected []string `json:"connected"` }
Channel represents a Mainflux "communication group". This group contains the clients that can exchange messages between eachother.
type ChannelRepository ¶
type ChannelRepository interface { // Save persists the channel. Successful operation is indicated by unique // identifier accompanied by nil error response. A non-nil error is // returned to indicate operation failure. Save(Channel) (string, error) // Update performs an update to the existing channel. A non-nil error is // returned to indicate operation failure. Update(Channel) error // One retrieves the channel having the provided identifier, that is owned // by the specified user. One(string, string) (Channel, error) // All retrieves the channels owned by the specified user. All(string) []Channel // Remove removes the channel having the provided identifier, that is owned // by the specified user. Remove(string, string) error // HasClient determines whether the client with the provided identifier, is // "connected" to the specified channel. HasClient(string, string) bool }
ChannelRepository specifies a channel persistence API.
type Client ¶
type Client struct { Owner string `json:"-"` ID string `json:"id"` Type string `json:"type"` Name string `json:"name,omitempty"` Key string `json:"key"` Meta map[string]string `json:"meta,omitempty"` }
Client represents a Mainflux client. Each client is owned by one user, and it is assigned with the unique identifier and (temporary) access key.
type ClientRepository ¶
type ClientRepository interface { // Id generates new resource identifier. Id() string // Save persists the client. Successful operation is indicated by non-nil // error response. Save(Client) error // Update performs an update to the existing client. A non-nil error is // returned to indicate operation failure. Update(Client) error // One retrieves the client having the provided identifier, that is owned // by the specified user. One(string, string) (Client, error) // All retrieves the clients owned by the specified user. All(string) []Client // Remove removes the client having the provided identifier, that is owned // by the specified user. Remove(string, string) error }
ClientRepository specifies a client persistence API.
type Hasher ¶
type Hasher interface { // Hash generates the hashed string from plain-text. Hash(string) (string, error) // Compare compares plain-text version to the hashed one. An error should // indicate failed comparison. Compare(string, string) error }
Hasher specifies an API for generating hashes of an arbitrary textual content.
type IdentityProvider ¶
type IdentityProvider interface { // TemporaryKey generates the temporary access token. TemporaryKey(string) (string, error) // PermanentKey generates the non-expiring access token. PermanentKey(string) (string, error) // Identity extracts the entity identifier given its secret key. Identity(string) (string, error) }
IdentityProvider specifies an API for identity management via security tokens.
type Service ¶
type Service interface { // Register creates new user account. In case of the failed registration, a // non-nil error value is returned. Register(User) error // Login authenticates the user given its credentials. Successful // authentication generates new access token. Failed invocations are // identified by the non-nil error values in the response. Login(User) (string, error) // Identity retrieves Client ID for a given client token Identity(string) (string, error) // AddClient adds new client to the user identified by the provided key. AddClient(string, Client) (string, error) // UpdateClient updates the client identified by the provided ID, that // belongs to the user identified by the provided key. UpdateClient(string, Client) error // ViewClient retrieves data about the client identified with the provided // ID, that belongs to the user identified by the provided key. ViewClient(string, string) (Client, error) // ListClients retrieves data about all clients that belongs to the user // identified by the provided key. ListClients(string) ([]Client, error) // RemoveClient removes the client identified with the provided ID, that // belongs to the user identified by the provided key. RemoveClient(string, string) error // CreateChannel adds new channel to the user identified by the provided key. CreateChannel(string, Channel) (string, error) // UpdateChannel updates the channel identified by the provided ID, that // belongs to the user identified by the provided key. UpdateChannel(string, Channel) error // ViewChannel retrieves data about the channel identified by the provided // ID, that belongs to the user identified by the provided key. ViewChannel(string, string) (Channel, error) // ListChannels retrieves data about all clients that belongs to the user // identified by the provided key. ListChannels(string) ([]Channel, error) // RemoveChannel removes the client identified by the provided ID, that // belongs to the user identified by the provided key. RemoveChannel(string, string) error // CanAccess determines whether or not the channel can be accessed with the // provided key. CanAccess(string, string) bool }
Service specifies an API that must be fullfiled by the domain service implementation, and all of its decorators (e.g. logging & metrics).
func NewService ¶
func NewService(users UserRepository, clients ClientRepository, channels ChannelRepository, hasher Hasher, idp IdentityProvider) Service
NewService instantiates the domain service implementation.
type User ¶
User represents a Mainflux user account. Each user is identified given its email and password.
type UserRepository ¶
type UserRepository interface { // Save persists the user account. A non-nil error is returned to indicate // operation failure. Save(User) error // One retrieves user by its unique identifier (i.e. email). One(string) (User, error) }
UserRepository specifies an account persistence API.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
|
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations. |
Package bcrypt provides a hasher implementation utilising bcrypt.
|
Package bcrypt provides a hasher implementation utilising bcrypt. |
Package cassandra contains Cassandra-specific repository implementations.
|
Package cassandra contains Cassandra-specific repository implementations. |
Package client provides a manager service client intended for internal service communication.
|
Package client provides a manager service client intended for internal service communication. |
Package jwt provides a JWT identity provider.
|
Package jwt provides a JWT identity provider. |