Documentation ¶
Index ¶
Constants ¶
const (
// BlankUUID is the erronous return from _help_make_uuid
BlankUUID = "00000000-0000-0000-0000-000000000000"
)
const (
// DefaultConfigPath is the global default location to find a config for our service
DefaultConfigPath = "config.toml"
)
const SchemaSqlite3 = `` /* 252-byte string literal not displayed */
SchemaSqlite3 is the default schema for our Sqlite3 impl
const (
// Version for the application
Version = "0.0.1"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AssignRequest ¶
type AssignRequest struct { UUID string `db:"uuid"` // UUID (set internally) AccountID string `db:"account_id"` // The ID for the license request LicenseID string `db:"license_id"` // The ID for the license being requested }
AssignRequest is used to serialise the basic license request.
type Config ¶
type Config struct { // Database configuration Database struct { Driver string Name string } Email struct { Method string From string `toml:"from"` SMTPUser string `toml:"smtp_user"` SMTPPort int `toml:"smtp_port"` SMTPPass string `toml:"smtp_pass"` SMTPHost string `toml:"smtp_host"` } }
Config contains the service-wide configuration
func NewConfig ¶
NewConfig will return a new Config object preseeded from the default configuration path.
func (*Config) ShouldEmail ¶
ShouldEmail will return true if we should email the new licenses
type CreateRequest ¶
type CreateRequest struct { LicenseID string `db:"license_id"` // The ID of the license Description string `db:"description"` // Description of the license MaxUsers int `db:"max_users"` // Maximum number of users for the license }
CreateRequest is used for creating new licenses
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database wraps the underlying database connection and helps with the storage side of things.
func NewDatabase ¶
NewDatabase will attempt to open and initialise the database using the given Config instance.
func (*Database) Assign ¶
func (d *Database) Assign(req *AssignRequest) (string, error)
Assign will attempt to claim the given license request, and return the UUID for the allocation.
func (*Database) Close ¶
func (d *Database) Close()
Close will shutdown any resources associate with the database
func (*Database) GetInfo ¶
GetInfo will return an Info type populated with information on the given license. If the license doesn't exist, then no info will be returned, and the user cannot be assigned the license.
func (*Database) InsertLicense ¶
func (d *Database) InsertLicense(req CreateRequest) error
InsertLicense will insert a new license if possible
type Email ¶
type Email struct {
// contains filtered or unexported fields
}
Email is used to render and send HTML emails in batch
type Info ¶
type Info struct { Description string `json:"description"` // Description of the license CurrentUsers int `json:"current_users"` // Curent number of users for this license MaxUsers int `json:"max_users"` // Maximum number of users for this license RemainingUsers int `json:"remaining_users"` // Remaining number of users for this license FillRatio float64 `json:"fill_ratio"` // How 'full' our sales are }
Info type is used to validate a License entry and find out various facts about it.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
A Manager instace is responsible for the DB connection, and assigning license users as well as the input of new licenses.
func NewManager ¶
NewManager will create a new manager instance and start the ball rolling
func (*Manager) AssignLicense ¶
AssignLicense will attempt to assign the license_id to account_id, returning the UUID for the new subscription if successful.
func (*Manager) Close ¶
func (m *Manager) Close()
Close will close any underlying connections and resources
func (*Manager) CreateLicense ¶
CreateLicense will attempt to create the new named license within the database for subscription by users.