store

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2017 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MAX_TAG_LENGTH = 3
View Source
const MIN_TAG_LENGTH = 1

Variables

View Source
var RecordNotFoundError = errors.New("record not found")
View Source
var Schemas = map[string][]string{
	"mysql": []string{
		`CREATE TABLE IF NOT EXISTS groups (
		id int NOT NULL AUTO_INCREMENT,
		guid varchar(255),
		UNIQUE (guid),
		PRIMARY KEY (id)
	);`,
		`CREATE TABLE IF NOT EXISTS destinations (
		id int NOT NULL AUTO_INCREMENT,
		group_id int REFERENCES groups(id),
		port int,
		protocol varchar(255),
		UNIQUE (group_id, port, protocol),
		PRIMARY KEY (id)
	);`,
		`CREATE TABLE IF NOT EXISTS policies (
		id int NOT NULL AUTO_INCREMENT,
		group_id int REFERENCES groups(id),
		destination_id int REFERENCES destinations(id),
		UNIQUE (group_id, destination_id),
		PRIMARY KEY (id)
	);`,
	},
	"postgres": []string{
		`CREATE TABLE IF NOT EXISTS groups (
		id SERIAL PRIMARY KEY,
		guid text,
		UNIQUE (guid)
	);`,
		`CREATE TABLE IF NOT EXISTS destinations (
		id SERIAL PRIMARY KEY,
		group_id int REFERENCES groups(id),
		port int,
		protocol text,
		UNIQUE (group_id, port, protocol)
	);`,
		`CREATE TABLE IF NOT EXISTS policies (
		id SERIAL PRIMARY KEY,
		group_id int REFERENCES groups(id),
		destination_id int REFERENCES destinations(id),
		UNIQUE (group_id, destination_id)
	);`,
	},
}

Functions

This section is empty.

Types

type Destination

type Destination struct {
}

func (*Destination) CountWhereGroupID

func (d *Destination) CountWhereGroupID(tx Transaction, group_id int) (int, error)

func (*Destination) Create

func (d *Destination) Create(tx Transaction, destination_group_id int, port int, protocol string) (int, error)

func (*Destination) Delete

func (d *Destination) Delete(tx Transaction, id int) error

func (*Destination) GetID

func (d *Destination) GetID(tx Transaction, destination_group_id int, port int, protocol string) (int, error)

type DestinationRepo

type DestinationRepo interface {
	Create(Transaction, int, int, string) (int, error)
	Delete(Transaction, int) error
	GetID(Transaction, int, int, string) (int, error)
	CountWhereGroupID(Transaction, int) (int, error)
}

type Group

type Group struct {
}

func (*Group) Create

func (g *Group) Create(tx Transaction, guid string) (int, error)

func (*Group) Delete

func (g *Group) Delete(tx Transaction, id int) error

func (*Group) GetID

func (g *Group) GetID(tx Transaction, guid string) (int, error)

type GroupRepo

type GroupRepo interface {
	Create(Transaction, string) (int, error)
	Delete(Transaction, int) error
	GetID(Transaction, string) (int, error)
}

type MetricsWrapper added in v0.17.0

type MetricsWrapper struct {
	Store         Store
	MetricsSender metricsSender
}

func (*MetricsWrapper) All added in v0.17.0

func (mw *MetricsWrapper) All() ([]models.Policy, error)

func (*MetricsWrapper) ByGuids added in v0.17.0

func (mw *MetricsWrapper) ByGuids(srcGuids, dstGuids []string) ([]models.Policy, error)

func (*MetricsWrapper) CheckDatabase added in v1.0.0

func (mw *MetricsWrapper) CheckDatabase() error

func (*MetricsWrapper) Create added in v0.17.0

func (mw *MetricsWrapper) Create(policies []models.Policy) error

func (*MetricsWrapper) Delete added in v0.17.0

func (mw *MetricsWrapper) Delete(policies []models.Policy) error

func (*MetricsWrapper) Tags added in v0.17.0

func (mw *MetricsWrapper) Tags() ([]models.Tag, error)

type MigrateAdapter added in v1.3.0

type MigrateAdapter struct {
}

func (*MigrateAdapter) Exec added in v1.3.0

type MigrationDb added in v1.3.0

type MigrationDb interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	DriverName() string
}

type Policy

type Policy struct {
}

func (*Policy) CountWhereDestinationID

func (p *Policy) CountWhereDestinationID(tx Transaction, destination_id int) (int, error)

func (*Policy) CountWhereGroupID

func (p *Policy) CountWhereGroupID(tx Transaction, source_group_id int) (int, error)

func (*Policy) Create

func (p *Policy) Create(tx Transaction, source_group_id int, destination_id int) error

func (*Policy) Delete

func (p *Policy) Delete(tx Transaction, source_group_id int, destination_id int) error

type PolicyRepo

type PolicyRepo interface {
	Create(Transaction, int, int) error
	Delete(Transaction, int, int) error
	CountWhereGroupID(Transaction, int) (int, error)
	CountWhereDestinationID(Transaction, int) (int, error)
}

type Store

type Store interface {
	Create([]models.Policy) error
	All() ([]models.Policy, error)
	Delete([]models.Policy) error
	Tags() ([]models.Tag, error)
	ByGuids([]string, []string) ([]models.Policy, error)
	CheckDatabase() error
}

func New

func New(dbConnectionPool db, migrator migrateAdapter, g GroupRepo, d DestinationRepo, p PolicyRepo, tl int, t time.Duration) (Store, error)

type Transaction

type Transaction interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	Commit() error
	Rollback() error
	Rebind(string) string
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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