Package database is a database interface to export.



    This section is empty.


    This section is empty.


    This section is empty.


    type ExportDB

    type ExportDB struct {
    	// contains filtered or unexported fields

    func New

    func New(db *database.DB) *ExportDB

    func (*ExportDB) AddExportBatches

    func (db *ExportDB) AddExportBatches(ctx context.Context, batches []*model.ExportBatch) error

      AddExportBatches inserts new export batches.

      func (*ExportDB) AddExportConfig

      func (db *ExportDB) AddExportConfig(ctx context.Context, ec *model.ExportConfig) error

        AddExportConfig creates a new ExportConfig record from which batch jobs are created.

        func (*ExportDB) AddSignatureInfo

        func (db *ExportDB) AddSignatureInfo(ctx context.Context, si *model.SignatureInfo) error

        func (*ExportDB) DeleteFilesBefore

        func (db *ExportDB) DeleteFilesBefore(ctx context.Context, before time.Time, blobstore storage.Blobstore) (int, error)

          DeleteFilesBefore deletes the export batch files for batches ending before the time passed in.

          func (*ExportDB) FinalizeBatch

          func (db *ExportDB) FinalizeBatch(ctx context.Context, eb *model.ExportBatch, files []string, batchSize int) error

            FinalizeBatch writes the ExportFile records and marks the ExportBatch as complete.

            func (*ExportDB) GetAllExportConfigs

            func (db *ExportDB) GetAllExportConfigs(ctx context.Context) ([]*model.ExportConfig, error)

            func (*ExportDB) GetExportConfig

            func (db *ExportDB) GetExportConfig(ctx context.Context, id int64) (*model.ExportConfig, error)

            func (*ExportDB) GetSignatureInfo

            func (db *ExportDB) GetSignatureInfo(ctx context.Context, id int64) (*model.SignatureInfo, error)

              GetSignatureInfo looks up a single signature info by ID.

              func (*ExportDB) IterateExportConfigs

              func (db *ExportDB) IterateExportConfigs(ctx context.Context, t time.Time, f func(*model.ExportConfig) error) (err error)

                IterateExportConfigs applies f to each ExportConfig whose FromTimestamp is before the given time. If f returns a non-nil error, the iteration stops, and the returned error will match f's error with errors.Is.

                func (*ExportDB) LatestExportBatchEnd

                func (db *ExportDB) LatestExportBatchEnd(ctx context.Context, ec *model.ExportConfig) (time.Time, error)

                  LatestExportBatchEnd returns the end time of the most recent ExportBatch for a given ExportConfig. It returns the zero time if no previous ExportBatch exists.

                  func (*ExportDB) LeaseBatch

                  func (db *ExportDB) LeaseBatch(ctx context.Context, ttl time.Duration, batchMaxCloseTime time.Time) (*model.ExportBatch, error)

                    LeaseBatch returns a leased ExportBatch for the worker to process. If no work to do, nil will be returned.

                    func (*ExportDB) ListAllSignatureInfos

                    func (db *ExportDB) ListAllSignatureInfos(ctx context.Context) ([]*model.SignatureInfo, error)

                    func (*ExportDB) ListLatestExportBatchEnds

                    func (db *ExportDB) ListLatestExportBatchEnds(ctx context.Context) (map[int64]*time.Time, error)

                      ListLatestExportBatchEnds returns a map of export config IDs to their latest batch end times.

                      func (*ExportDB) LookupExportBatch

                      func (db *ExportDB) LookupExportBatch(ctx context.Context, batchID int64) (*model.ExportBatch, error)

                        LookupExportBatch returns an ExportBatch for the given batchID.

                        func (*ExportDB) LookupExportFile

                        func (db *ExportDB) LookupExportFile(ctx context.Context, filename string) (*model.ExportFile, error)

                        func (*ExportDB) LookupExportFiles

                        func (db *ExportDB) LookupExportFiles(ctx context.Context, configID int64, ttl time.Duration) ([]string, error)

                          LookupExportFiles returns a list of completed and unexpired export files for a specific config.

                          func (*ExportDB) LookupSignatureInfos

                          func (db *ExportDB) LookupSignatureInfos(ctx context.Context, ids []int64, validUntil time.Time) ([]*model.SignatureInfo, error)

                          func (*ExportDB) MarkExpiredFiles

                          func (db *ExportDB) MarkExpiredFiles(ctx context.Context, configID int64, ttl time.Duration) (int, error)

                            MarkExpiredFiles marks files for deletion.

                            func (*ExportDB) UpdateExportConfig

                            func (db *ExportDB) UpdateExportConfig(ctx context.Context, ec *model.ExportConfig) error

                              UpdateExportConfig updates an existing ExportConfig record from which batch jobs are created.

                              func (*ExportDB) UpdateSignatureInfo

                              func (db *ExportDB) UpdateSignatureInfo(ctx context.Context, si *model.SignatureInfo) error

                              Source Files