Documentation ¶
Index ¶
- Constants
- func Connect(s Settings) (*gorm.DB, error)
- func NewID() string
- type AccessKey
- type AccessKeyPermission
- type AccessKeyStore
- type Flame
- type Index
- type Key
- type PostgresIndex
- type PostgresIndexes
- type Query
- type Record
- func (r *Record) BeforeSave() error
- func (r *Record) GetProperties() (map[string]interface{}, error)
- func (r *Record) MustGetProperties() map[string]interface{}
- func (r *Record) MustSetProperties(properties map[string]interface{})
- func (r *Record) SetProperties(properties map[string]interface{}) error
- type SSLMode
- type Settings
Constants ¶
const DefaultPort = 5432
DefaultPort is the default Postgres listen port
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccessKey ¶
type AccessKey struct { ID string `json:"id" gorm:"size:64;primary_key;unique_index"` RefID string `json:"ref_id" gorm:"size:64;index"` Name string `json:"name" gorm:"size:64"` Permission string `json:"permission" gorm:"size:64"` CreatedAt time.Time `json:"created_at"` Secret string `json:"value" gorm:"size:100"` }
AccessKey is a database entry allowing access to FlameDB
func NewAccessKey ¶
func NewAccessKey(name, refID string, perm AccessKeyPermission) (*AccessKey, string, error)
NewAccessKey initializes a new AccessKey with a random secret value. The AccessKey model is returned along with the plaintext value which should be stored externally.
type AccessKeyPermission ¶
type AccessKeyPermission string
AccessKeyPermission defines the access level associated with an access key
const ( // Denied access Denied AccessKeyPermission = "" // ReadOnly grant ReadOnly AccessKeyPermission = "r" // ReadWrite grant ReadWrite AccessKeyPermission = "rw" // ServiceRead provides read access from an external service ServiceRead AccessKeyPermission = "sr" // ServiceReadWrite provides rw access from an external service ServiceReadWrite AccessKeyPermission = "srw" )
type AccessKeyStore ¶
type AccessKeyStore interface { // Get returns the access key with the given key ID Get(id string) (*AccessKey, error) }
AccessKeyStore is an interface to retrieve access permissions
func NewAccessKeyStore ¶
func NewAccessKeyStore(gormDB *gorm.DB) (AccessKeyStore, error)
NewAccessKeyStore returns an initialized access key store
type Flame ¶
type Flame interface { // Get a Record using the key Get(Key) (*Record, error) // Save the Record Save(*Record) error // Delete the Record Delete(*Record) error // List Records matching the query List(Query) ([]*Record, error) // GetIndexes returns a list of existing indexes GetIndexes() ([]Index, error) // CreateIndex creates a new index on the specified field or property CreateIndex(Index) error // DeleteIndex deletes the index DeleteIndex(Index) error // HasIndex returns true if the Index already exists HasIndex(Index) (bool, error) // DropTable removes the table from the database, deleting all records DropTable() error // Migrate the database schema Migrate() error }
Flame is the database interface
type Index ¶
Index on a specified Record property used to ensure efficient queries. Optionally a Parent path may be specified to create the Index only on a subset of Records with that Parent path.
type PostgresIndex ¶
type PostgresIndex struct { TableName string `gorm:"tablename"` IndexName string `gorm:"indexname"` IndexDef string `gorm:"indexdef"` }
PostgresIndex is a record in PG describing a table index
type PostgresIndexes ¶
type PostgresIndexes []*PostgresIndex
PostgresIndexes is a slice of indexes
func (PostgresIndexes) Get ¶
func (indexes PostgresIndexes) Get(name string) *PostgresIndex
Get the index with the specified name
type Query ¶
type Query struct { Offset int Limit int Parent string Prefix string OrderBy string OrderByDesc bool OrderByProperty string OrderByPropertyDesc bool PropertyFilter map[string]string }
Query used to list records
type Record ¶
type Record struct { ID string `json:"id" gorm:"size:64;primary_key;unique_index"` Path string `json:"path" gorm:"size:320;unique_index"` Parent string `json:"parent" gorm:"size:256;index"` CreatedBy string `json:"created_by" gorm:"size:64"` UpdatedBy string `json:"updated_by" gorm:"size:64"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Properties postgres.Jsonb `json:"properties"` }
Record is an item with a unique ID stored in FlameDB at a specified Path. The Record has a handful of top-level meta attributes and a Properties field which may contain arbitrary JSON.
func (*Record) BeforeSave ¶
BeforeSave is called to validate the Record before saving it to the database
func (*Record) GetProperties ¶
GetProperties returns the record properties as a map
func (*Record) MustGetProperties ¶
MustGetProperties returns the record properties as a map. If they fail to unmarshal this panics.
func (*Record) MustSetProperties ¶
MustSetProperties sets properties and panics if marshaling fails
func (*Record) SetProperties ¶
SetProperties sets the properites in JSONB format
type Settings ¶
type Settings struct { Host string Port int User string Password string Name string SSLMode SSLMode SSLRootCert string SSLCert string SSLKey string }
Settings used to connect to the backing Postgres database
func GetSettings ¶
func GetSettings() Settings
GetSettings returns application configuration derived from command line options and environment variables.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package mock_database is a generated GoMock package.
|
Package mock_database is a generated GoMock package. |