state

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package state interacts with core database schema and stores cloudquery metadata such as fetch summaries

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Logger hclog.Logger
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, dsn string) (*Client, error)

NewClient creates a client from the given DSN and migrates the metadata schema. client.Close should be called to disconnect afterwards.

func (*Client) Close added in v0.24.0

func (c *Client) Close()

Close closes the underlying database connection.

func (*Client) GetFetchSummaryForProvider

func (c *Client) GetFetchSummaryForProvider(ctx context.Context, provider string) (*FetchSummary, error)

GetFetchSummaryForProvider gets latest fetch summary for specific provider

func (*Client) GetProvider added in v0.24.0

func (c *Client) GetProvider(ctx context.Context, p registry.Provider) (*Provider, error)

GetProvider gets state about given provider, or returns nil, nil.

func (*Client) ProviderSync added in v0.24.0

func (c *Client) ProviderSync(ctx context.Context) (*Tx, error)

func (*Client) SaveFetchSummary

func (c *Client) SaveFetchSummary(ctx context.Context, fs *FetchSummary) error

SaveFetchSummary saves fetch summary into fetches database

type FetchSummary

type FetchSummary struct {
	CqId uuid.UUID `db:"id"`
	//  Unique Id of fetch session
	FetchId            uuid.UUID              `db:"fetch_id"`
	CreatedAt          time.Time              `db:"created_at"`
	Start              time.Time              `db:"start"`
	Finish             time.Time              `db:"finish"`
	IsSuccess          bool                   `db:"is_success"`
	TotalResourceCount uint64                 `db:"total_resource_count"`
	TotalErrorsCount   uint64                 `db:"total_errors_count"`
	ProviderName       string                 `db:"provider_name"`
	ProviderAlias      string                 `db:"provider_alias"`
	ProviderVersion    string                 `db:"provider_version"`
	CoreVersion        string                 `db:"core_version"`
	Resources          ResourceFetchSummaries `db:"results"`
}

FetchSummary includes a summarized report of fetch, such as fetch id, fetch start and finish, resources fetch results

type Provider added in v0.24.0

type Provider struct {
	Source  string `db:"source"`
	Name    string `db:"name"`
	Version string `db:"version"`

	VMajor int    `db:"v_major"`
	VMinor int    `db:"v_minor"`
	VPatch int    `db:"v_patch"`
	VPre   string `db:"v_pre"`
	VMeta  string `db:"v_meta"`

	Tables     tableList `db:"tables"`
	Signatures stringMap `db:"signatures"`

	ParsedVersion *version.Version `db:"-"`
}

Provider keeps track of installed providers

func ProviderFromRegistry added in v0.24.0

func ProviderFromRegistry(r registry.Provider) *Provider

ProviderFromRegistry returns a Provider struct with info filled from a registry.Provider

func (*Provider) Registry added in v0.24.0

func (p *Provider) Registry() registry.Provider

type ResourceFetchSummaries

type ResourceFetchSummaries []ResourceFetchSummary

func (ResourceFetchSummaries) Value

Value implements Valuer interface required by goqu

type ResourceFetchSummary

type ResourceFetchSummary struct {
	ResourceName string `json:"resource_name"`
	// map of resources that have finished fetching
	FinishedResources map[string]bool `json:"finished_resources"`
	// Error value if any, if returned the stream will be canceled
	Error string `json:"error"`
	// Execution status of resource
	Status string `json:"status"`
	// Total Amount of resources collected by this resource
	ResourceCount uint64 `json:"resource_count"`
}

ResourceFetchSummary includes a data about fetching specific resource

type Tx added in v0.24.0

type Tx struct {
	execution.TXQueryExecer
	// contains filtered or unexported fields
}

func (*Tx) InstallProvider added in v0.24.0

func (t *Tx) InstallProvider(ctx context.Context, p *Provider) error

InstallProvider saves state about given provider

func (*Tx) UninstallProvider added in v0.24.0

func (t *Tx) UninstallProvider(ctx context.Context, p registry.Provider) error

UninstallProvider removes state about given provider

Jump to

Keyboard shortcuts

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