pgdb

package
v0.0.0-...-0490640 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindKeyValue

func FindKeyValue(tags []*common.Kv, key string) *common.Kv

FindKeyValue finds a Tag object in the array based on key match

func KeyValueToRawMap

func KeyValueToRawMap(arr []*common.Kv) (json.RawMessage, error)

KeyValueToRawMap helps convert an array of KeyValues in a Map and convert it to json

func RawMapToKeyValue

func RawMapToKeyValue(rawJSON json.RawMessage) ([]*common.Kv, error)

RawMapToKeyValue helps convert an array of KeyValues in a Map and convert it to json

func RemoveKeyValue

func RemoveKeyValue(tags []*common.Kv, key string) []*common.Kv

RemoveKeyValue removes an item from the array base on key match

func Transact

func Transact(db *DB, txFunc func(*DBTrans) error) error

Transact wraps your calls in a transaction. If the call should fail with an error it will perform a rollback. Otherwise the transaction will be committed.

Types

type DB

type DB struct {
	*gorp.DbMap
}

func InitDB

func InitDB(connectionString string) (*DB, error)

func New

func New(conf *config.Postgres) (*DB, error)

func (*DB) AddJob

func (db *DB) AddJob(inJob *jobs.Job) (string, error)

func (*DB) DeleteJob

func (db *DB) DeleteJob(id string) error

func (*DB) GetJob

func (db *DB) GetJob(id string) (*jobs.Job, error)

func (*DB) GetJobName

func (db *DB) GetJobName(id string) (string, error)

func (*DB) GetJobResultByNodeId

func (db *DB) GetJobResultByNodeId(ctx context.Context, in *jobs.GetJobResultByNodeIdRequest) (*jobs.ResultsRow, error)

given a job id and node id, get the result from the results table

func (*DB) GetJobs

func (db *DB) GetJobs(sortField string, insortOrder jobs.Query_OrderType, pageNr int32, perPage int32, filters []*common.Filter) ([]*jobs.Job, int64, error)

func (*DB) ListInitiatedScans

func (db *DB) ListInitiatedScans(ctx context.Context, startTime *tspb.Timestamp) ([]string, error)

func (*DB) UpdateJob

func (db *DB) UpdateJob(inJob *jobs.Job) error

type DBTrans

type DBTrans struct {
	*gorp.Transaction
}

type JobNode

type JobNode struct {
	JobID  string `db:"job_id"`
	NodeID string `db:"node_id"`
}

JobNode used only to (de)serialize database access

type JobProfile

type JobProfile struct {
	JobID     string `db:"job_id"`
	ProfileID string `db:"profile_id"`
}

type JobTag

type JobTag struct {
	JobID string `db:"job_id"`
	TagID string `db:"tag_id"`
}

JobTag used only to (de)serialize database access

type ResultsRow

type ResultsRow struct {
	JobID     string    `db:"job_id" json:"job_id,omitempty"`
	NodeID    string    `db:"node_id" json:"node_id"`
	ReportID  string    `db:"report_id" json:"report_id"`
	Status    string    `db:"status" json:"status"`
	Result    string    `db:"result" json:"result"`
	StartTime time.Time `db:"start_time" json:"start_time"`
	EndTime   time.Time `db:"end_time" json:"end_time"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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