Documentation
¶
Index ¶
- Constants
- func GetName(c Controller) string
- type BridgePayload
- type Color
- type ColorController
- func (cc *ColorController) Add(db *bolt.DB, color []byte) error
- func (cc *ColorController) AddMultiple(db *bolt.DB, colors []byte) error
- func (cc *ColorController) Get(db *bolt.DB, identifier interface{}) (interface{}, error)
- func (cc *ColorController) GetAll(db *bolt.DB) ([]interface{}, error)
- func (cc *ColorController) Initialize(db *bolt.DB) error
- type Controller
- type DBHandler
- func (h *DBHandler) Add(controller string, singleton []byte) error
- func (h *DBHandler) AddMultiple(controller string, set []byte) error
- func (h *DBHandler) CreatePayload(devices []Device) []BridgePayload
- func (h *DBHandler) Get(controller string, id interface{}) (interface{}, error)
- func (h *DBHandler) GetAll(controller string) ([]interface{}, error)
- type Device
- type DeviceController
- func (dc *DeviceController) Add(db *bolt.DB, dev []byte) error
- func (dc *DeviceController) AddMultiple(db *bolt.DB, devs []byte) error
- func (dc *DeviceController) Get(db *bolt.DB, identifier interface{}) (interface{}, error)
- func (dc *DeviceController) GetAll(db *bolt.DB) ([]interface{}, error)
- func (dc *DeviceController) Initialize(db *bolt.DB) error
- type Mode
- type VoteController
- func (vc *VoteController) Add(db *bolt.DB, votes []byte) error
- func (vc VoteController) AddMultiple(db *bolt.DB, votes []byte) error
- func (vc *VoteController) Get(db *bolt.DB, _ interface{}) (interface{}, error)
- func (vc VoteController) GetAll(db *bolt.DB) ([]interface{}, error)
- func (vc *VoteController) Initialize(db *bolt.DB) error
- type VoteResult
Constants ¶
const ( // Normal indicates that the device is operating in light output mode. Normal = iota // Vote indicates that the device is currently in a voting mode. Vote )
Variables ¶
This section is empty.
Functions ¶
func GetName ¶
func GetName(c Controller) string
GetName gets the default bucket name (or tableName) of the given struct.
Types ¶
type BridgePayload ¶
type BridgePayload struct {
ID uint8 `json:"id"`
Mode Mode `json:"mode"`
ColorSequence []uint32 `json:"colorsequence"`
}
BridgePayload contains the information required by the bridge to send to each of the bands.
type Color ¶
type Color struct {
ID uint8 `json:"id"`
Name string `json:"name"`
Sequence []uint32 `json:"sequence"`
}
Color contains color information for the bands.
func (*Color) MarshalJSON ¶
MarshalJSON implements the JSON interface for Color.
func (*Color) UnmarshalJSON ¶
UnmarshalJSON implements the JSON interface for Color.
type ColorController ¶
type ColorController struct {
// contains filtered or unexported fields
}
ColorController is a struct containing information on the Colors bucket.
func (*ColorController) Add ¶
func (cc *ColorController) Add(db *bolt.DB, color []byte) error
Add method adds a single color to the database.
func (*ColorController) AddMultiple ¶
func (cc *ColorController) AddMultiple(db *bolt.DB, colors []byte) error
AddMultiple adds multiple color sequences to the database.
func (*ColorController) Get ¶
func (cc *ColorController) Get(db *bolt.DB, identifier interface{}) (interface{}, error)
Get gets a single Color from the database based on given ID.
func (*ColorController) GetAll ¶
func (cc *ColorController) GetAll(db *bolt.DB) ([]interface{}, error)
GetAll method gets a list of all color sequences from the database.
func (*ColorController) Initialize ¶
func (cc *ColorController) Initialize(db *bolt.DB) error
Initialize creates the Colors bucket required for this controller.
type Controller ¶
type Controller interface {
Initialize(*bolt.DB) error
// Generic get methods.
Get(*bolt.DB, interface{}) (interface{}, error)
GetAll(*bolt.DB) ([]interface{}, error)
// Generic add/update methods
Add(*bolt.DB, []byte) error
AddMultiple(*bolt.DB, []byte) error
}
Controller interface provides a list of methods that a controller should implement.
type DBHandler ¶
type DBHandler struct {
// contains filtered or unexported fields
}
DBHandler acts as an interface for bbolt.
func (*DBHandler) AddMultiple ¶
AddMultiple runs the AddMultiple interface method on the controller with the given name.
func (*DBHandler) CreatePayload ¶
func (h *DBHandler) CreatePayload(devices []Device) []BridgePayload
CreatePayload creates a communication payload for the bridge.
type Device ¶
type Device struct {
ID uint8 `json:"id"`
Mode Mode `json:"mode"`
ColorScheme uint8 `json:"color"`
}
Device contains device-specific information about individual bands.
func (*Device) MarshalJSON ¶
MarshalJSON is the interface method for json.Marshall for the Device struct.
func (*Device) UnmarshalJSON ¶
UnmarshalJSON is the interface method for json.Unmarshal for the Device struct. This method also provides some validation.
type DeviceController ¶
type DeviceController struct {
// contains filtered or unexported fields
}
DeviceController is a struct containing bucket information as well as required interface methods.
func (*DeviceController) Add ¶
func (dc *DeviceController) Add(db *bolt.DB, dev []byte) error
Add method adds a single device based on the inputs from a JSON byte stream.
func (*DeviceController) AddMultiple ¶
func (dc *DeviceController) AddMultiple(db *bolt.DB, devs []byte) error
AddMultiple method adds multiple devices from a JSON byte stream.
func (*DeviceController) Get ¶
func (dc *DeviceController) Get(db *bolt.DB, identifier interface{}) (interface{}, error)
Get method gets a single device from the Devices bucket that matches the passed integer ID.
func (*DeviceController) GetAll ¶
func (dc *DeviceController) GetAll(db *bolt.DB) ([]interface{}, error)
GetAll method gets a list of all devices.
func (*DeviceController) Initialize ¶
func (dc *DeviceController) Initialize(db *bolt.DB) error
Initialize creates the bucket required for the "Devices" controller.
type VoteController ¶
type VoteController struct {
// contains filtered or unexported fields
}
VoteController is a struct containing information on the Votes bucket.
func (*VoteController) Add ¶
func (vc *VoteController) Add(db *bolt.DB, votes []byte) error
Add method updates the vote count from the input of a JSON byte stream.
func (VoteController) AddMultiple ¶
func (vc VoteController) AddMultiple(db *bolt.DB, votes []byte) error
AddMultiple is an alias for the Add method.
func (*VoteController) Get ¶
func (vc *VoteController) Get(db *bolt.DB, _ interface{}) (interface{}, error)
Get method gets all of the votes from the database.
func (VoteController) GetAll ¶
func (vc VoteController) GetAll(db *bolt.DB) ([]interface{}, error)
GetAll method is an alias for Get method except the output is packaged into a slice.
func (*VoteController) Initialize ¶
func (vc *VoteController) Initialize(db *bolt.DB) error
Initialize sets the fields of the passed VoteController and create the required bucket.
type VoteResult ¶
VoteResult contains the results from voting in the database.