repositories

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricHistoriesDefaultLimit   = 10000000
	MetricHistoryBulkDefaultLimit = 25000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseRepository

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

BaseRepository represents base repository object.

func (BaseRepository) GetDB

func (r BaseRepository) GetDB() *gorm.DB

GetDB returns current DB instance.

type BaseRepositoryProvider

type BaseRepositoryProvider interface {
	// GetDB returns current DB instance.
	GetDB() *gorm.DB
}

BaseRepositoryProvider provides base repository interface.

type ExperimentRepository

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

ExperimentRepository repository to work with `experiment` entity.

func NewExperimentRepository

func NewExperimentRepository(db *gorm.DB) *ExperimentRepository

NewExperimentRepository creates repository to work with `experiment` entity.

func (ExperimentRepository) Create

func (r ExperimentRepository) Create(ctx context.Context, experiment *models.Experiment) error

Create creates new models.Experiment entity.

func (ExperimentRepository) Delete added in v0.3.0

func (r ExperimentRepository) Delete(ctx context.Context, experiment *models.Experiment) error

Delete removes the existing models.Experiment from the db.

func (ExperimentRepository) DeleteBatch added in v0.3.0

func (r ExperimentRepository) DeleteBatch(ctx context.Context, ids []*int32) error

DeleteBatch removes existing []models.Experiment in batch from the db.

func (ExperimentRepository) GetByID

func (r ExperimentRepository) GetByID(ctx context.Context, experimentID int32) (*models.Experiment, error)

GetByID returns experiment by its ID.

func (ExperimentRepository) GetByName

func (r ExperimentRepository) GetByName(ctx context.Context, name string) (*models.Experiment, error)

GetByName returns experiment by its name.

func (ExperimentRepository) Update

func (r ExperimentRepository) Update(ctx context.Context, experiment *models.Experiment) error

Update updates existing models.Experiment entity.

type ExperimentRepositoryProvider

type ExperimentRepositoryProvider interface {
	// Create creates new models.Experiment entity.
	Create(ctx context.Context, experiment *models.Experiment) error
	// GetByID returns experiment by its ID.
	GetByID(ctx context.Context, experimentID int32) (*models.Experiment, error)
	// GetByName returns experiment by its name.
	GetByName(ctx context.Context, name string) (*models.Experiment, error)
	// Update updates existing models.Experiment entity.
	Update(ctx context.Context, experiment *models.Experiment) error
	// Delete removes the existing models.Experiment from the db.
	Delete(ctx context.Context, experiment *models.Experiment) error
	// DeleteBatch removes existing []models.Experiment in batch from the db.
	DeleteBatch(ctx context.Context, ids []*int32) error
}

ExperimentRepositoryProvider provides an interface to work with `experiment` entity.

type MetricRepository

type MetricRepository struct {
	BaseRepository
}

MetricRepository repository to work with models.Metric entity.

func NewMetricRepository

func NewMetricRepository(db *gorm.DB) *MetricRepository

NewMetricRepository creates repository to work with models.Metric entity.

func (MetricRepository) CreateBatch

func (r MetricRepository) CreateBatch(
	ctx context.Context, run *models.Run, batchSize int, metrics []models.Metric,
) error

CreateBatch creates []models.Metric entities in batch.

func (MetricRepository) GetMetricHistories

func (r MetricRepository) GetMetricHistories(
	ctx context.Context,
	experimentIDs []string, runIDs []string, metricKeys []string, viewType request.ViewType, limit int32,
) (*sql.Rows, func(*sql.Rows, interface{}) error, error)

GetMetricHistories returns metric histories by request parameters. TODO think about to use interface instead of underlying type for -> func(*sql.Rows, interface{})

func (MetricRepository) GetMetricHistoryBulk

func (r MetricRepository) GetMetricHistoryBulk(
	ctx context.Context, runIDs []string, key string, limit int,
) ([]models.Metric, error)

GetMetricHistoryBulk returns metrics history bulk.

func (MetricRepository) GetMetricHistoryByRunIDAndKey

func (r MetricRepository) GetMetricHistoryByRunIDAndKey(
	ctx context.Context, runID, key string,
) ([]models.Metric, error)

GetMetricHistoryByRunIDAndKey returns metrics history by RunID and Key.

type MetricRepositoryProvider

type MetricRepositoryProvider interface {
	BaseRepositoryProvider
	// CreateBatch creates []models.Metric entities in batch.
	CreateBatch(ctx context.Context, run *models.Run, batchSize int, params []models.Metric) error
	// GetMetricHistories returns metric histories by request parameters.
	GetMetricHistories(
		ctx context.Context,
		experimentIDs []string, runIDs []string, metricKeys []string, viewType request.ViewType, limit int32,
	) (*sql.Rows, func(*sql.Rows, interface{}) error, error)
	// GetMetricHistoryBulk returns metrics history bulk.
	GetMetricHistoryBulk(ctx context.Context, runIDs []string, key string, limit int) ([]models.Metric, error)
	// GetMetricHistoryByRunIDAndKey returns metrics history by RunID and Key.
	GetMetricHistoryByRunIDAndKey(ctx context.Context, runID, key string) ([]models.Metric, error)
}

MetricRepositoryProvider provides an interface to work with models.Metric entity.

type MockBaseRepositoryProvider added in v0.3.2

type MockBaseRepositoryProvider struct {
	mock.Mock
}

MockBaseRepositoryProvider is an autogenerated mock type for the BaseRepositoryProvider type

func NewMockBaseRepositoryProvider added in v0.3.2

func NewMockBaseRepositoryProvider(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockBaseRepositoryProvider

NewMockBaseRepositoryProvider creates a new instance of MockBaseRepositoryProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockBaseRepositoryProvider) GetDB added in v0.3.2

func (_m *MockBaseRepositoryProvider) GetDB() *gorm.DB

GetDB provides a mock function with given fields:

type MockExperimentRepositoryProvider added in v0.3.2

type MockExperimentRepositoryProvider struct {
	mock.Mock
}

MockExperimentRepositoryProvider is an autogenerated mock type for the ExperimentRepositoryProvider type

func NewMockExperimentRepositoryProvider added in v0.3.2

func NewMockExperimentRepositoryProvider(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockExperimentRepositoryProvider

NewMockExperimentRepositoryProvider creates a new instance of MockExperimentRepositoryProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockExperimentRepositoryProvider) Create added in v0.3.2

Create provides a mock function with given fields: ctx, experiment

func (*MockExperimentRepositoryProvider) Delete added in v0.3.2

Delete provides a mock function with given fields: ctx, experiment

func (*MockExperimentRepositoryProvider) DeleteBatch added in v0.3.2

func (_m *MockExperimentRepositoryProvider) DeleteBatch(ctx context.Context, ids []*int32) error

DeleteBatch provides a mock function with given fields: ctx, ids

func (*MockExperimentRepositoryProvider) GetByID added in v0.3.2

func (_m *MockExperimentRepositoryProvider) GetByID(ctx context.Context, experimentID int32) (*models.Experiment, error)

GetByID provides a mock function with given fields: ctx, experimentID

func (*MockExperimentRepositoryProvider) GetByName added in v0.3.2

GetByName provides a mock function with given fields: ctx, name

func (*MockExperimentRepositoryProvider) Update added in v0.3.2

Update provides a mock function with given fields: ctx, experiment

type MockMetricRepositoryProvider added in v0.3.2

type MockMetricRepositoryProvider struct {
	mock.Mock
}

MockMetricRepositoryProvider is an autogenerated mock type for the MetricRepositoryProvider type

func NewMockMetricRepositoryProvider added in v0.3.2

func NewMockMetricRepositoryProvider(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockMetricRepositoryProvider

NewMockMetricRepositoryProvider creates a new instance of MockMetricRepositoryProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockMetricRepositoryProvider) CreateBatch added in v0.3.2

func (_m *MockMetricRepositoryProvider) CreateBatch(ctx context.Context, run *models.Run, batchSize int, params []models.Metric) error

CreateBatch provides a mock function with given fields: ctx, run, batchSize, params

func (*MockMetricRepositoryProvider) GetDB added in v0.3.2

func (_m *MockMetricRepositoryProvider) GetDB() *gorm.DB

GetDB provides a mock function with given fields:

func (*MockMetricRepositoryProvider) GetMetricHistories added in v0.3.2

func (_m *MockMetricRepositoryProvider) GetMetricHistories(ctx context.Context, experimentIDs []string, runIDs []string, metricKeys []string, viewType request.ViewType, limit int32) (*sql.Rows, func(*sql.Rows, interface{}) error, error)

GetMetricHistories provides a mock function with given fields: ctx, experimentIDs, runIDs, metricKeys, viewType, limit

func (*MockMetricRepositoryProvider) GetMetricHistoryBulk added in v0.3.2

func (_m *MockMetricRepositoryProvider) GetMetricHistoryBulk(ctx context.Context, runIDs []string, key string, limit int) ([]models.Metric, error)

GetMetricHistoryBulk provides a mock function with given fields: ctx, runIDs, key, limit

func (*MockMetricRepositoryProvider) GetMetricHistoryByRunIDAndKey added in v0.3.2

func (_m *MockMetricRepositoryProvider) GetMetricHistoryByRunIDAndKey(ctx context.Context, runID string, key string) ([]models.Metric, error)

GetMetricHistoryByRunIDAndKey provides a mock function with given fields: ctx, runID, key

type MockParamRepositoryProvider added in v0.3.2

type MockParamRepositoryProvider struct {
	mock.Mock
}

MockParamRepositoryProvider is an autogenerated mock type for the ParamRepositoryProvider type

func NewMockParamRepositoryProvider added in v0.3.2

func NewMockParamRepositoryProvider(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockParamRepositoryProvider

NewMockParamRepositoryProvider creates a new instance of MockParamRepositoryProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockParamRepositoryProvider) CreateBatch added in v0.3.2

func (_m *MockParamRepositoryProvider) CreateBatch(ctx context.Context, batchSize int, params []models.Param) error

CreateBatch provides a mock function with given fields: ctx, batchSize, params

type MockRunRepositoryProvider added in v0.3.2

type MockRunRepositoryProvider struct {
	mock.Mock
}

MockRunRepositoryProvider is an autogenerated mock type for the RunRepositoryProvider type

func NewMockRunRepositoryProvider added in v0.3.2

func NewMockRunRepositoryProvider(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRunRepositoryProvider

NewMockRunRepositoryProvider creates a new instance of MockRunRepositoryProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockRunRepositoryProvider) Archive added in v0.3.2

func (_m *MockRunRepositoryProvider) Archive(ctx context.Context, run *models.Run) error

Archive provides a mock function with given fields: ctx, run

func (*MockRunRepositoryProvider) ArchiveBatch added in v0.3.2

func (_m *MockRunRepositoryProvider) ArchiveBatch(ctx context.Context, ids []string) error

ArchiveBatch provides a mock function with given fields: ctx, ids

func (*MockRunRepositoryProvider) Create added in v0.3.2

func (_m *MockRunRepositoryProvider) Create(ctx context.Context, run *models.Run) error

Create provides a mock function with given fields: ctx, run

func (*MockRunRepositoryProvider) Delete added in v0.3.2

func (_m *MockRunRepositoryProvider) Delete(ctx context.Context, run *models.Run) error

Delete provides a mock function with given fields: ctx, run

func (*MockRunRepositoryProvider) DeleteBatch added in v0.3.2

func (_m *MockRunRepositoryProvider) DeleteBatch(ctx context.Context, ids []string) error

DeleteBatch provides a mock function with given fields: ctx, ids

func (*MockRunRepositoryProvider) GetByID added in v0.3.2

func (_m *MockRunRepositoryProvider) GetByID(ctx context.Context, id string) (*models.Run, error)

GetByID provides a mock function with given fields: ctx, id

func (*MockRunRepositoryProvider) GetByIDAndLifecycleStage added in v0.3.2

func (_m *MockRunRepositoryProvider) GetByIDAndLifecycleStage(ctx context.Context, id string, lifecycleStage models.LifecycleStage) (*models.Run, error)

GetByIDAndLifecycleStage provides a mock function with given fields: ctx, id, lifecycleStage

func (*MockRunRepositoryProvider) GetDB added in v0.3.2

func (_m *MockRunRepositoryProvider) GetDB() *gorm.DB

GetDB provides a mock function with given fields:

func (*MockRunRepositoryProvider) Restore added in v0.3.2

func (_m *MockRunRepositoryProvider) Restore(ctx context.Context, run *models.Run) error

Restore provides a mock function with given fields: ctx, run

func (*MockRunRepositoryProvider) RestoreBatch added in v0.3.2

func (_m *MockRunRepositoryProvider) RestoreBatch(ctx context.Context, ids []string) error

RestoreBatch provides a mock function with given fields: ctx, ids

func (*MockRunRepositoryProvider) SetRunTagsBatch added in v0.3.2

func (_m *MockRunRepositoryProvider) SetRunTagsBatch(ctx context.Context, run *models.Run, batchSize int, tags []models.Tag) error

SetRunTagsBatch provides a mock function with given fields: ctx, run, batchSize, tags

func (*MockRunRepositoryProvider) Update added in v0.3.2

func (_m *MockRunRepositoryProvider) Update(ctx context.Context, run *models.Run) error

Update provides a mock function with given fields: ctx, run

func (*MockRunRepositoryProvider) UpdateWithTransaction added in v0.3.2

func (_m *MockRunRepositoryProvider) UpdateWithTransaction(ctx context.Context, tx *gorm.DB, run *models.Run) error

UpdateWithTransaction provides a mock function with given fields: ctx, tx, run

type MockTagRepositoryProvider added in v0.3.2

type MockTagRepositoryProvider struct {
	mock.Mock
}

MockTagRepositoryProvider is an autogenerated mock type for the TagRepositoryProvider type

func NewMockTagRepositoryProvider added in v0.3.2

func NewMockTagRepositoryProvider(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockTagRepositoryProvider

NewMockTagRepositoryProvider creates a new instance of MockTagRepositoryProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockTagRepositoryProvider) CreateExperimentTag added in v0.3.2

func (_m *MockTagRepositoryProvider) CreateExperimentTag(ctx context.Context, experimentTag *models.ExperimentTag) error

CreateExperimentTag provides a mock function with given fields: ctx, experimentTag

func (*MockTagRepositoryProvider) CreateRunTagWithTransaction added in v0.3.2

func (_m *MockTagRepositoryProvider) CreateRunTagWithTransaction(ctx context.Context, tx *gorm.DB, runID string, key string, value string) error

CreateRunTagWithTransaction provides a mock function with given fields: ctx, tx, runID, key, value

func (*MockTagRepositoryProvider) Delete added in v0.3.2

func (_m *MockTagRepositoryProvider) Delete(ctx context.Context, tag *models.Tag) error

Delete provides a mock function with given fields: ctx, tag

func (*MockTagRepositoryProvider) GetByRunIDAndKey added in v0.3.2

func (_m *MockTagRepositoryProvider) GetByRunIDAndKey(ctx context.Context, runID string, key string) (*models.Tag, error)

GetByRunIDAndKey provides a mock function with given fields: ctx, runID, key

func (*MockTagRepositoryProvider) GetDB added in v0.3.2

func (_m *MockTagRepositoryProvider) GetDB() *gorm.DB

GetDB provides a mock function with given fields:

type ParamRepository

type ParamRepository struct {
	BaseRepository
}

ParamRepository repository to work with models.Param entity.

func NewParamRepository

func NewParamRepository(db *gorm.DB) *ParamRepository

NewParamRepository creates repository to work with models.Param entity.

func (ParamRepository) CreateBatch

func (r ParamRepository) CreateBatch(ctx context.Context, batchSize int, params []models.Param) error

CreateBatch creates []models.Param entities in batch.

type ParamRepositoryProvider

type ParamRepositoryProvider interface {
	// CreateBatch creates []models.Param entities in batch.
	CreateBatch(ctx context.Context, batchSize int, params []models.Param) error
}

ParamRepositoryProvider provides an interface to work with models.Param entity.

type RunRepository

type RunRepository struct {
	BaseRepository
}

RunRepository repository to work with models.Run entity.

func NewRunRepository

func NewRunRepository(db *gorm.DB) *RunRepository

NewRunRepository creates repository to work with models.Run entity.

func (RunRepository) Archive

func (r RunRepository) Archive(ctx context.Context, run *models.Run) error

Archive marks existing models.Run entity as archived.

func (RunRepository) ArchiveBatch

func (r RunRepository) ArchiveBatch(ctx context.Context, ids []string) error

ArchiveBatch marks existing models.Run entities as archived.

func (RunRepository) Create

func (r RunRepository) Create(ctx context.Context, run *models.Run) error

Create creates new models.Run entity.

func (RunRepository) Delete

func (r RunRepository) Delete(ctx context.Context, run *models.Run) error

Delete removes the existing models.Run from the db.

func (RunRepository) DeleteBatch

func (r RunRepository) DeleteBatch(ctx context.Context, ids []string) error

DeleteBatch removes existing models.Run from the db.

func (RunRepository) GetByID

func (r RunRepository) GetByID(ctx context.Context, id string) (*models.Run, error)

GetByID returns models.Run entity by its ID.

func (RunRepository) GetByIDAndLifecycleStage

func (r RunRepository) GetByIDAndLifecycleStage(
	ctx context.Context, id string, lifecycleStage models.LifecycleStage,
) (*models.Run, error)

GetByIDAndLifecycleStage returns models.Run entity by its ID and Lifecycle Stage

func (RunRepository) Restore

func (r RunRepository) Restore(ctx context.Context, run *models.Run) error

Restore marks existing models.Run entity as active.

func (RunRepository) RestoreBatch

func (r RunRepository) RestoreBatch(ctx context.Context, ids []string) error

RestoreBatch marks existing models.Run entities as active.

func (RunRepository) SetRunTagsBatch

func (r RunRepository) SetRunTagsBatch(ctx context.Context, run *models.Run, batchSize int, tags []models.Tag) error

SetRunTagsBatch sets Run tags in batch.

func (RunRepository) Update

func (r RunRepository) Update(ctx context.Context, run *models.Run) error

Update updates existing models.Run entity.

func (RunRepository) UpdateWithTransaction

func (r RunRepository) UpdateWithTransaction(ctx context.Context, tx *gorm.DB, run *models.Run) error

UpdateWithTransaction updates existing models.Run entity in scope of transaction.

type RunRepositoryProvider

type RunRepositoryProvider interface {
	BaseRepositoryProvider
	// GetByID returns models.Run entity by its ID.
	GetByID(ctx context.Context, id string) (*models.Run, error)
	// GetByIDAndLifecycleStage returns models.Run entity by its ID and Lifecycle Stage
	GetByIDAndLifecycleStage(
		ctx context.Context, id string, lifecycleStage models.LifecycleStage,
	) (*models.Run, error)
	// Create creates new models.Run entity.
	Create(ctx context.Context, run *models.Run) error
	// Update updates existing models.Experiment entity.
	Update(ctx context.Context, run *models.Run) error
	// Archive marks existing models.Run entity as archived.
	Archive(ctx context.Context, run *models.Run) error
	// Delete removes the existing models.Run
	Delete(ctx context.Context, run *models.Run) error
	// Restore marks existing models.Run entity as active.
	Restore(ctx context.Context, run *models.Run) error
	// ArchiveBatch marks existing models.Run entities as archived.
	ArchiveBatch(ctx context.Context, ids []string) error
	// DeleteBatch removes the existing models.Run from the db.
	DeleteBatch(ctx context.Context, ids []string) error
	// RestoreBatch marks existing models.Run entities as active.
	RestoreBatch(ctx context.Context, ids []string) error
	// SetRunTagsBatch sets Run tags in batch.
	SetRunTagsBatch(ctx context.Context, run *models.Run, batchSize int, tags []models.Tag) error
	// UpdateWithTransaction updates existing models.Run entity in scope of transaction.
	UpdateWithTransaction(ctx context.Context, tx *gorm.DB, run *models.Run) error
}

RunRepositoryProvider provides an interface to work with models.Run entity.

type TagRepository

type TagRepository struct {
	BaseRepository
}

TagRepository repository to work with models.Tag entity.

func NewTagRepository

func NewTagRepository(db *gorm.DB) *TagRepository

NewTagRepository creates repository to work with models.Tag entity.

func (TagRepository) CreateExperimentTag

func (r TagRepository) CreateExperimentTag(ctx context.Context, experimentTag *models.ExperimentTag) error

CreateExperimentTag creates new models.ExperimentTag entity connected to models.Experiment.

func (TagRepository) CreateRunTagWithTransaction

func (r TagRepository) CreateRunTagWithTransaction(
	ctx context.Context, tx *gorm.DB, runID, key, value string,
) error

CreateRunTagWithTransaction creates new models.Tag entity connected to models.Run.

func (TagRepository) Delete

func (r TagRepository) Delete(ctx context.Context, tag *models.Tag) error

Delete deletes existing models.Tag entity.

func (TagRepository) GetByRunIDAndKey

func (r TagRepository) GetByRunIDAndKey(ctx context.Context, runID, key string) (*models.Tag, error)

GetByRunIDAndKey returns models.Tag by provided RunID and Tag Key.

type TagRepositoryProvider

type TagRepositoryProvider interface {
	BaseRepositoryProvider
	// CreateExperimentTag creates new models.ExperimentTag entity connected to models.Experiment.
	CreateExperimentTag(ctx context.Context, experimentTag *models.ExperimentTag) error
	// CreateRunTagWithTransaction creates new models.Tag entity connected to models.Run.
	CreateRunTagWithTransaction(ctx context.Context, tx *gorm.DB, runID, key, value string) error
	// GetByRunIDAndKey returns models.Tag by provided RunID and Tag Key.
	GetByRunIDAndKey(ctx context.Context, runID, key string) (*models.Tag, error)
	// Delete deletes existing models.Tag entity.
	Delete(ctx context.Context, tag *models.Tag) error
}

TagRepositoryProvider provides an interface to work with models.Tag entity.

Jump to

Keyboard shortcuts

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