store

package
v0.0.0-...-5bd05a1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRecordNotFound error = errors.New("record not found")
)

Functions

func Commit

func Commit(ctx context.Context) (context.Context, error)

func FromContext

func FromContext(ctx context.Context) *gorm.DB

func InitDB

func InitDB(cfg *config.Config) (*gorm.DB, error)

func Rollback

func Rollback(ctx context.Context) (context.Context, error)

Types

type Agent

type Agent interface {
	List(ctx context.Context, filter *AgentQueryFilter, opts *AgentQueryOptions) (api.AgentList, error)
	Get(ctx context.Context, id string) (*api.Agent, error)
	Update(ctx context.Context, agentUpdate apiAgent.AgentStatusUpdate) (*api.Agent, error)
	UpdateSourceID(ctx context.Context, agentID string, sourceID string, associated bool) (*api.Agent, error)
	Create(ctx context.Context, agentUpdate apiAgent.AgentStatusUpdate) (*api.Agent, error)
	Delete(ctx context.Context, id string, softDeletion bool) error
	InitialMigration(context.Context) error
}

func NewAgentSource

func NewAgentSource(db *gorm.DB) Agent

type AgentQueryFilter

type AgentQueryFilter = BaseAgentQuerier

func NewAgentQueryFilter

func NewAgentQueryFilter() *AgentQueryFilter

func (*AgentQueryFilter) ByID

func (qf *AgentQueryFilter) ByID(ids []string) *AgentQueryFilter

func (*AgentQueryFilter) BySoftDeleted

func (qf *AgentQueryFilter) BySoftDeleted(isSoftDeleted bool) *AgentQueryFilter

func (*AgentQueryFilter) BySourceID

func (qf *AgentQueryFilter) BySourceID(sourceID string) *AgentQueryFilter

type AgentQueryOptions

type AgentQueryOptions = BaseAgentQuerier

func NewAgentQueryOptions

func NewAgentQueryOptions() *AgentQueryOptions

func (*AgentQueryOptions) WithIncludeSoftDeleted

func (o *AgentQueryOptions) WithIncludeSoftDeleted(includeSoftDeleted bool) *AgentQueryOptions

func (*AgentQueryOptions) WithSortOrder

func (o *AgentQueryOptions) WithSortOrder(sort SortOrder) *AgentQueryOptions

type AgentStore

type AgentStore struct {
	// contains filtered or unexported fields
}

func (*AgentStore) Create

func (a *AgentStore) Create(ctx context.Context, agentUpdate apiAgent.AgentStatusUpdate) (*api.Agent, error)

Create creates an agent from api model.

func (*AgentStore) Delete

func (a *AgentStore) Delete(ctx context.Context, id string, softDeletion bool) error

Delete removes an agent. If softDeletion is true, the agent is soft-deleted.

func (*AgentStore) Get

func (a *AgentStore) Get(ctx context.Context, id string) (*api.Agent, error)

Get returns an agent based on its id.

func (*AgentStore) InitialMigration

func (a *AgentStore) InitialMigration(ctx context.Context) error

func (*AgentStore) List

List lists all the agents.

If includeSoftDeleted is true, it lists the agents soft-deleted.

func (*AgentStore) Update

func (a *AgentStore) Update(ctx context.Context, agentUpdate apiAgent.AgentStatusUpdate) (*api.Agent, error)

Update updates an agent from api model.

func (*AgentStore) UpdateSourceID

func (a *AgentStore) UpdateSourceID(ctx context.Context, agentID string, sourceID string, associated bool) (*api.Agent, error)

UpdateSourceID updates the sources id field of an agent. The source must exists.

type BaseAgentQuerier

type BaseAgentQuerier struct {
	QueryFn []func(tx *gorm.DB) *gorm.DB
}

type DataStore

type DataStore struct {
	// contains filtered or unexported fields
}

func (*DataStore) Agent

func (s *DataStore) Agent() Agent

func (*DataStore) Close

func (s *DataStore) Close() error

func (*DataStore) InitialMigration

func (s *DataStore) InitialMigration() error

func (*DataStore) NewTransactionContext

func (s *DataStore) NewTransactionContext(ctx context.Context) (context.Context, error)

func (*DataStore) Source

func (s *DataStore) Source() Source

type SortOrder

type SortOrder int
const (
	Unsorted SortOrder = iota
	SortByID
	SortByUpdatedTime
	SortByCreatedTime
)

type Source

type Source interface {
	List(ctx context.Context) (api.SourceList, error)
	Create(ctx context.Context, id uuid.UUID) (*api.Source, error)
	DeleteAll(ctx context.Context) error
	Get(ctx context.Context, id uuid.UUID) (*api.Source, error)
	Delete(ctx context.Context, id uuid.UUID) error
	Update(ctx context.Context, id uuid.UUID, inventory *api.Inventory) (*api.Source, error)
	InitialMigration(context.Context) error
}

func NewSource

func NewSource(db *gorm.DB) Source

type SourceStore

type SourceStore struct {
	// contains filtered or unexported fields
}

func (*SourceStore) Create

func (s *SourceStore) Create(ctx context.Context, id uuid.UUID) (*api.Source, error)

func (*SourceStore) Delete

func (s *SourceStore) Delete(ctx context.Context, id uuid.UUID) error

func (*SourceStore) DeleteAll

func (s *SourceStore) DeleteAll(ctx context.Context) error

func (*SourceStore) Get

func (s *SourceStore) Get(ctx context.Context, id uuid.UUID) (*api.Source, error)

func (*SourceStore) InitialMigration

func (s *SourceStore) InitialMigration(ctx context.Context) error

func (*SourceStore) List

func (s *SourceStore) List(ctx context.Context) (api.SourceList, error)

func (*SourceStore) Update

func (s *SourceStore) Update(ctx context.Context, id uuid.UUID, inventory *api.Inventory) (*api.Source, error)

type Store

type Store interface {
	NewTransactionContext(ctx context.Context) (context.Context, error)
	Agent() Agent
	Source() Source
	InitialMigration() error
	Close() error
}

func NewStore

func NewStore(db *gorm.DB) Store

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

func (*Tx) Commit

func (t *Tx) Commit() error

func (*Tx) Db

func (t *Tx) Db() (*gorm.DB, error)

func (*Tx) Rollback

func (t *Tx) Rollback() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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