Documentation
¶
Index ¶
- type Connection
- type FeedbackStore
- type Index
- type RedisRegistry
- func (registry *RedisRegistry) AllocateRegistration(details RegistrationRequest) error
- func (registry *RedisRegistry) AuthorizeToken(deviceID, token string, permission uint) bool
- func (registry *RedisRegistry) CreateToken(deviceID, tokenName string, permission uint) (TokenDetails, error)
- func (registry *RedisRegistry) Do(commandName string, args ...interface{}) (reply interface{}, err error)
- func (registry *RedisRegistry) FillRegistration(secret, uuid string) error
- func (registry *RedisRegistry) FindDevice(query string) (RegistrationDetails, error)
- func (registry *RedisRegistry) FindToken(token string) (TokenDetails, error)
- func (registry *RedisRegistry) ListFeedback(id string, count int) ([]interchange.FeedbackMessage, error)
- func (registry *RedisRegistry) ListRegistrations() ([]RegistrationDetails, error)
- func (registry *RedisRegistry) ListTokens(query string) ([]TokenDetails, error)
- func (registry *RedisRegistry) LogFeedback(message interchange.FeedbackMessage) error
- func (registry *RedisRegistry) RemoveDevice(id string) error
- type RegistrationDetails
- type RegistrationRequest
- type RegistrationStream
- type Registry
- type StreamerConnection
- type TokenDetails
- type TokenGenerator
- type TokenStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface { Send(interchange.DeviceMessage) error Receive() (io.Reader, error) GetID() string Close() error }
Connection defines an interface that describes the capabilities of a device connected to the api - send + receive
type FeedbackStore ¶
type FeedbackStore interface { LogFeedback(interchange.FeedbackMessage) error ListFeedback(string, int) ([]interchange.FeedbackMessage, error) }
FeedbackStore defines an interface that logs device state into a persisted store.
type Index ¶
type Index interface { RemoveDevice(string) error FindDevice(string) (RegistrationDetails, error) }
The Index interface defines a store that is used to add, remove and lookup string based elements
type RedisRegistry ¶
type RedisRegistry struct { *logging.Logger *redis.Pool TokenGenerator }
RedisRegistry implements the `Registry` interface w/ a redis backend
func (*RedisRegistry) AllocateRegistration ¶
func (registry *RedisRegistry) AllocateRegistration(details RegistrationRequest) error
AllocateRegistration reserves a spot in the registry to be filled later
func (*RedisRegistry) AuthorizeToken ¶
func (registry *RedisRegistry) AuthorizeToken(deviceID, token string, permission uint) bool
AuthorizeToken approves the token + permission for the given device id
func (*RedisRegistry) CreateToken ¶
func (registry *RedisRegistry) CreateToken(deviceID, tokenName string, permission uint) (TokenDetails, error)
CreateToken creates a new auth token for a given device id
func (*RedisRegistry) Do ¶
func (registry *RedisRegistry) Do(commandName string, args ...interface{}) (reply interface{}, err error)
Do attempts to get an available connection from the pool and execute a command against it.
func (*RedisRegistry) FillRegistration ¶
func (registry *RedisRegistry) FillRegistration(secret, uuid string) error
FillRegistration searches the pending registrations and adds the new uuid to the index
func (*RedisRegistry) FindDevice ¶
func (registry *RedisRegistry) FindDevice(query string) (RegistrationDetails, error)
FindDevice searches the registry based on a query string for the first matching device id
func (*RedisRegistry) FindToken ¶
func (registry *RedisRegistry) FindToken(token string) (TokenDetails, error)
FindToken searches the token store for the token details given the token key.
func (*RedisRegistry) ListFeedback ¶
func (registry *RedisRegistry) ListFeedback(id string, count int) ([]interchange.FeedbackMessage, error)
ListFeedback retrieves the latest feedback for a given device id.
func (*RedisRegistry) ListRegistrations ¶
func (registry *RedisRegistry) ListRegistrations() ([]RegistrationDetails, error)
ListRegistrations prints out a list of all the registered devices
func (*RedisRegistry) ListTokens ¶
func (registry *RedisRegistry) ListTokens(query string) ([]TokenDetails, error)
ListTokens searches the token store for the token details given the token key.
func (*RedisRegistry) LogFeedback ¶
func (registry *RedisRegistry) LogFeedback(message interchange.FeedbackMessage) error
LogFeedback inserts a feedback item into the redis store.
func (*RedisRegistry) RemoveDevice ¶
func (registry *RedisRegistry) RemoveDevice(id string) error
RemoveDevice executes the LREM command to the redis connection
type RegistrationDetails ¶
RegistrationDetails holds the information about a given device connection
type RegistrationRequest ¶
type RegistrationRequest struct { Name string `json:"name"` }
RegistrationRequest holds the information for a pending registration
type RegistrationStream ¶
type RegistrationStream chan Connection
RegistrationStream a channel that sends along new device connections after they've been upgrated to websockets
type Registry ¶
type Registry interface { Index ListRegistrations() ([]RegistrationDetails, error) FillRegistration(string, string) error AllocateRegistration(RegistrationRequest) error }
Registry is an interface for allocating and filling registration requests
type StreamerConnection ¶
type StreamerConnection struct { logging.LeveledLogger defs.Streamer defs.Signer // contains filtered or unexported fields }
StreamerConnection is an implementation of the device.Connection interface using a websocket
func NewStreamerConnection ¶
func NewStreamerConnection(stream defs.Streamer, sign defs.Signer, id uuid.UUID) *StreamerConnection
NewStreamerConnection returns a device connection who's underlying IO is managed through a streamer interface
func (*StreamerConnection) GetID ¶
func (connection *StreamerConnection) GetID() string
GetID returns the unique identifier created for this connection as a string
func (*StreamerConnection) Receive ¶
func (connection *StreamerConnection) Receive() (io.Reader, error)
Receive returns the next available reader from the underlying streamer interface
func (*StreamerConnection) Send ¶
func (connection *StreamerConnection) Send(message interchange.DeviceMessage) error
Send writes the provided byte data to the next available writer from the underlying streamer interface
type TokenDetails ¶
type TokenDetails struct { TokenID string `json:"token_id"` DeviceID string `json:"device_id"` Token string `json:"token"` Name string `json:"name"` Permission uint `json:"permission"` }
TokenDetails holds permission information for a given device token.
type TokenGenerator ¶
TokenGenerator defines an interface for generating random tokens.
type TokenStore ¶
type TokenStore interface { CreateToken(string, string, uint) (TokenDetails, error) ListTokens(string) ([]TokenDetails, error) AuthorizeToken(string, string, uint) bool }
TokenStore defines the interface for creating tokens.