Documentation ¶
Index ¶
- Variables
- type Persistence
- func (db Persistence) AddCheckAsFinished(checkID uuid.UUID) (int64, error)
- func (db Persistence) Close() error
- func (db Persistence) CreateScan(id uuid.UUID, scan api.Scan) (int64, error)
- func (db Persistence) DeleteScanChecks(scanID uuid.UUID) error
- func (db Persistence) GetCheckByID(id uuid.UUID) (api.Check, error)
- func (db Persistence) GetCreatingScans() ([]string, error)
- func (db Persistence) GetScanByID(id uuid.UUID) (api.Scan, error)
- func (db Persistence) GetScanChecks(scanID uuid.UUID) ([]api.Check, error)
- func (db Persistence) GetScanChecksByStatus(scanID uuid.UUID, status string) ([]api.Check, error)
- func (db Persistence) GetScanIDForCheck(ID uuid.UUID) (uuid.UUID, error)
- func (db Persistence) GetScanStats(scanID uuid.UUID) (map[string]int, error)
- func (db Persistence) GetScanStatus(ID uuid.UUID) (api.Scan, error)
- func (db Persistence) GetScans(offset, limit uint32) ([]api.Scan, error)
- func (db Persistence) GetScansByExternalID(ID string, offset, limit uint32) ([]api.Scan, error)
- func (db Persistence) InsertCheckIfNotExists(c api.Check) (string, error)
- func (db Persistence) ReleaseScanLock(l *db.Lock) error
- func (db Persistence) TryLockScan(id string) (*db.Lock, error)
- func (db Persistence) UpdateScan(id uuid.UUID, scan api.Scan, updateStates []string) (int64, error)
- func (db Persistence) UpsertCheck(scanID, id uuid.UUID, check api.Check, updateStates []string) (int64, error)
- type ScansStore
Constants ¶
This section is empty.
Variables ¶
var ( // ErrChecksFinishedNotInitialized is returned by the AddCheckAsFinished when trying to add // a check finished to its scan. ErrChecksFinishedNotInitialized = errors.New("field checks_finished is not initialized") )
Functions ¶
This section is empty.
Types ¶
type Persistence ¶
type Persistence struct {
// contains filtered or unexported fields
}
Persistence implements ScansStore interface by using the underlying document store.
func NewPersistence ¶
func NewPersistence(s db.DB) Persistence
NewPersistence creates and initializes a store.
func (Persistence) AddCheckAsFinished ¶
func (db Persistence) AddCheckAsFinished(checkID uuid.UUID) (int64, error)
AddCheckAsFinished mark the given check as finished in the given scan by increasing the the number the field ChecksFinished in the giver scan. The operation is idempotent That is if for a given scanID and CheckID the operation will only increase the field ChecksFinished of the scan one time, no matters the number of times it is called.
func (Persistence) Close ¶
func (db Persistence) Close() error
Close closes the underlaying connection to the store.
func (Persistence) CreateScan ¶
CreateScan creates a new scan in the database.
func (Persistence) DeleteScanChecks ¶
func (db Persistence) DeleteScanChecks(scanID uuid.UUID) error
DeleteScanChecks deletes all the checks of a given scan.
func (Persistence) GetCheckByID ¶
GetCheckByID returns the check for the given ID.
func (Persistence) GetCreatingScans ¶
func (db Persistence) GetCreatingScans() ([]string, error)
func (Persistence) GetScanByID ¶
GetScanByID returns a scan given its ID.
func (Persistence) GetScanChecks ¶
GetScanChecks returns all checks of a scan.
func (Persistence) GetScanChecksByStatus ¶
GetScanChecksByStatus returns all checks of a scan that have the given status.
func (Persistence) GetScanIDForCheck ¶
func (Persistence) GetScanStats ¶
GetScanStats returns the number of checks by status for the given scan.
func (Persistence) GetScanStatus ¶
GetScanStatus returns a scan struct with only the fields: Status, CheckCount, ChecksFinished filled.
func (Persistence) GetScans ¶
func (db Persistence) GetScans(offset, limit uint32) ([]api.Scan, error)
GetScans returns the list of scans.
func (Persistence) GetScansByExternalID ¶
GetScansByExternalID returns scans with a given ExternalID applying the given offset and limit.
func (Persistence) InsertCheckIfNotExists ¶
func (db Persistence) InsertCheckIfNotExists(c api.Check) (string, error)
InsertCheckIfNotExists looks if a check exists in the database with the same ScanID and ScanIndex than the passed check. If it exists, the function returns the id of the check in the database. If it does not exist the function inserts the passed check and returns the id of the inserted check id.
func (Persistence) ReleaseScanLock ¶
func (db Persistence) ReleaseScanLock(l *db.Lock) error
func (Persistence) TryLockScan ¶
func (db Persistence) TryLockScan(id string) (*db.Lock, error)
func (Persistence) UpdateScan ¶
UpdateScan updates a scan in the database. The data of the current scan in the db it is not replaced, but merged using json merge as is defined in the concatenate operation here: https://www.postgresql.org/docs/9.5/functions-json.html
func (Persistence) UpsertCheck ¶
func (db Persistence) UpsertCheck(scanID, id uuid.UUID, check api.Check, updateStates []string) (int64, error)
UpsertCheck adds or updates a check of a given scan.
type ScansStore ¶
type ScansStore interface { CreateScan(id uuid.UUID, scan api.Scan) (int64, error) UpsertCheck(scanID, id uuid.UUID, check api.Check, updateStates []string) (int64, error) GetScans(offset, limit uint32) ([]api.Scan, error) GetScanChecks(scanID uuid.UUID) ([]api.Check, error) GetScanChecksByStatus(scanID uuid.UUID, status string) ([]api.Check, error) GetScanByID(id uuid.UUID) (api.Scan, error) GetScanStats(scanID uuid.UUID) (map[string]int, error) UpdateScan(id uuid.UUID, scan api.Scan, updateStates []string) (int64, error) GetScansByExternalID(ID string, offset, limit uint32) ([]api.Scan, error) GetCheckByID(id uuid.UUID) (api.Check, error) DeleteScanChecks(scanID uuid.UUID) error GetScanIDForCheck(ID uuid.UUID) (uuid.UUID, error) AddCheckAsFinished(checkID uuid.UUID) (int64, error) GetScanStatus(ID uuid.UUID) (api.Scan, error) }