core

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveRack added in v0.3.0

func SaveRack(configuration *Configuration, rack Rack) error

SaveRack writes the current Rack's data to the config file. If a Rack with the same label already exists, it will overwrite that entry.

func SaveShelf added in v0.3.0

func SaveShelf(configuration *Configuration, shelf Shelf) error

SaveShelf writes the current Schema's data to the config file.

func SaveWarehouse added in v0.3.0

func SaveWarehouse(configuration *Configuration, warehouse Warehouse) error

SaveWarehouse writes the Warehouse metadata to the config file. If a schema with the same ID already exists, it will overwrite that entry.

func WriteShelf added in v0.3.0

func WriteShelf(warehouse Warehouse, shelf Shelf, box Box) error

WriteShelf writes the table and its data to a warehouse.

Types

type Box

type Box struct {
	Label              string
	Flag               string
	Headers            []utils.Header
	Data               *[][]interface{}
	TableCreationQuery string
	InsertionQueries   []string
}

Box represents all the pieces of a digested data set needed for writing to a database.

func NewBox added in v0.2.4

func NewBox(label string, flag string, headers []utils.Header, data [][]interface{}) *Box

NewBox cleans incoming data and generates queries for table creation and insertion.

type Configuration

type Configuration struct {
	Path       string      `yaml:"path"`
	Warehouses []Warehouse `yaml:"warehouses"`
	Racks      []Rack      `yaml:"racks"`
	Shelves    []Shelf     `yaml:"shelves"`
}

Configuration is a structure that represents a Syllogi config.

func NewConfiguration added in v0.2.4

func NewConfiguration(path *string) (*Configuration, error)

NewConfiguration checks the filesystem for a valid configuration file, creates it if there isn't one, and loads that configuration into memory.

Takes a reference to a string representing a desired path, which is in a sense optional. If nil is passed in place of that path, it will default to ~/.syllogi. This amendment was added to support custom use and testing.

func (*Configuration) Read

func (configuration *Configuration) Read() error

func (*Configuration) Write

func (configuration *Configuration) Write() error

type Rack

type Rack struct {
	Warehouse string `yaml:"warehouse"`
	ID        string `yaml:"id"`
	Label     string `yaml:"label"`
}

Rack represents a schema metadata abstraction.

func GetRack added in v0.3.0

func GetRack(configuration *Configuration, label string) *Rack

GetRack reads the Rack data from the config file by the given label and loads it into the current instance.

func NewRack added in v0.2.4

func NewRack(configuration *Configuration, warehouse Warehouse, label string) (*Rack, error)

NewRack creates a new Rack instance from the given parameters.

type Shelf

type Shelf struct {
	Rack  string `yaml:"rack"`
	ID    string `yaml:"id"`
	Label string `yaml:"label"`
	Date  string `yaml:"date"`
}

Shelf represents a table metadata abstraction.

func GetShelf added in v0.3.0

func GetShelf(configuration *Configuration, label string) *Shelf

GetShelf reads the Shelf data from the config file by the given label and loads it into the current instance.

func NewShelf added in v0.2.4

func NewShelf(configuration *Configuration, warehouse Warehouse, box Box) (*Shelf, error)

NewShelf creates and populates a new table on the given warehouse and saves the metadata to the configuration file.

type Warehouse

type Warehouse struct {
	ID   string `yaml:"id"`
	Name string `yaml:"name"`
	URL  string `yaml:"url"`
}

Warehouse abstracts a database entity.

func GetWarehouse added in v0.3.0

func GetWarehouse(configuration *Configuration, name string) *Warehouse

GetWarehouse reads the Warehouse metadata from the config file by the given name and loads it into the current instance.

func NewWarehouse added in v0.2.4

func NewWarehouse(configuration *Configuration, name string, url string) (*Warehouse, error)

NewWarehouse creates a new Warehouse instance from the given parameters and writes it to the configuration file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL