persistance

package
v0.0.0-...-032d74d Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToMap

func ToMap(fields, values *[]string) map[string]string

func ToSql

func ToSql(values *[]string, wrap bool) string

Types

type DBBackendName

type DBBackendName string
const (
	Postgres DBBackendName = "postgres"
	MongoDB  DBBackendName = "mongodb"
	MySql    DBBackendName = "mysql"
	MSSql    DBBackendName = "sqlserver"
	Sqlite   DBBackendName = "sqlite3"
)

type DatabaseConfig

type DatabaseConfig struct {
	NeedsHeaders bool
	ConnString   string
	Backend      DBBackendName
	Username     string
	Password     string
}

func NewDatabaseConfig

func NewDatabaseConfig(connString string) (*DatabaseConfig, error)

type DatabaseWriter

type DatabaseWriter struct {
	Config            *DatabaseConfig
	PurgeBeforeWrite  bool
	CompactAfterWrite bool
	DryRun            bool
	Logger            *cli.Logger
}

type GenericSQLWriter

type GenericSQLWriter struct {
	DatabaseWriter
}

func (GenericSQLWriter) Purge

func (w GenericSQLWriter) Purge(tableName string) (*Result, error)

func (GenericSQLWriter) Write

func (w GenericSQLWriter) Write(tableData *datafile.TableData) (*Result, error)

type MongoDBWriter

type MongoDBWriter struct {
	DatabaseWriter
}

func (MongoDBWriter) Purge

func (w MongoDBWriter) Purge(tableName string) (*Result, error)

func (MongoDBWriter) Write

func (w MongoDBWriter) Write(tableData *datafile.TableData) (*Result, error)

type Result

type Result struct {
	ResultCode int
	Message    string
}

ErroCodes 0: All OK 1: No data to write 2: data is available but did not get pushed under dry run 3: headers are required

type Writer

type Writer interface {
	// Ensure whatever is return has Write Method
	Write(*datafile.TableData) (*Result, error)
	Purge(string) (*Result, error)
}

func NewWriter

func NewWriter(dbConfig *DatabaseConfig, options *cli.Options, logger *cli.Logger) (Writer, error)

Jump to

Keyboard shortcuts

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