metadata

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2014 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database holds on to metadata. Wow!

func NewDatabase

func NewDatabase(url string, log *logrus.Logger) (*Database, error)

NewDatabase creates a (postgres) *Database from a database URL string

func (*Database) Init

func (db *Database) Init() error

Init runs initialization stuff so that stuff works

func (*Database) Lookup

func (db *Database) Lookup(jobID, path string) (*Metadata, error)

Lookup looks up some metadata

func (*Database) LookupAll

func (db *Database) LookupAll(jobID string) ([]*Metadata, error)

LookupAll returns all metadata associated with a given job ID

func (*Database) Migrate

func (db *Database) Migrate(log *logrus.Logger) error

Migrate runs any missing migrations for make great schema

func (*Database) Save

func (db *Database) Save(m *Metadata) error

Save saves some metadata

type LookupSaver

type LookupSaver interface {
	Save(*Metadata) error
	Lookup(string, string) (*Metadata, error)
	LookupAll(string) ([]*Metadata, error)
}

LookupSaver is the interface needed for reads and writes of metadata

type Metadata

type Metadata struct {
	ID          uint64
	JobID       string
	Size        uint64
	Path        string
	ContentType string
}

Metadata is the stuff we care about in the metadata database

func (*Metadata) MarshalJSON

func (md *Metadata) MarshalJSON() ([]byte, error)

MarshalJSON is all about the JSON, everything as a string per jsonapi

type NullLookupSaver

type NullLookupSaver struct {
	// contains filtered or unexported fields
}

NullLookupSaver is the "nullified" implementation of a lookup saver

func NewNullLookupSaver

func NewNullLookupSaver() *NullLookupSaver

NewNullLookupSaver builds a new NullLookupSaver

func (*NullLookupSaver) Lookup

func (nls *NullLookupSaver) Lookup(jobID, path string) (*Metadata, error)

Lookup gets the metadata from the in-memory internal mapping

func (*NullLookupSaver) LookupAll

func (nls *NullLookupSaver) LookupAll(jobID string) ([]*Metadata, error)

LookupAll returns all of the in-memory metadata

func (*NullLookupSaver) Save

func (nls *NullLookupSaver) Save(m *Metadata) error

Save adds the metadata to the in-memory internal mapping

Jump to

Keyboard shortcuts

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