Documentation ¶
Index ¶
- func InitializeModel(db *gorm.DB) error
- type FifoRotationStrategy
- type NestedStreamMiddlewares
- type RotationStrategy
- type Service
- func (s *Service) CalculateAllocatedSpaceAboveSingleVersionLimit(collection *collections.Collection, existing []UploadedVersion, ...) (int64, error)
- func (s *Service) CalculateMaximumAllowedUploadFilesize(collection *collections.Collection, excluding []UploadedVersion) (int64, error)
- func (s *Service) CleanUpOlderVersions(versions []UploadedVersion) bool
- func (s *Service) CopyStream(ctx context.Context, inputStream io.ReadCloser, writeStream io.Writer, ...) (int64, error)
- func (s *Service) CreateNewVersionFromCollection(c *collections.Collection, uploader string, uploaderSessionId string, ...) (UploadedVersion, error)
- func (s *Service) CreateRotationStrategyCase(collection *collections.Collection) (RotationStrategy, error)
- func (s *Service) CreateStandardMiddleWares(context context.Context, versionsToDelete []UploadedVersion, ...) (NestedStreamMiddlewares, error)
- func (s *Service) Delete(version *UploadedVersion) []error
- func (s *Service) FindAllActiveVersionsFor(id string) ([]UploadedVersion, error)
- func (s *Service) FindLatestVersion(collectionId string) (UploadedVersion, error)
- func (s *Service) FindNextVersionForCollectionId(name string) (int, error)
- func (s *Service) GetVersionByNum(collectionId string, version string) (UploadedVersion, error)
- func (s *Service) ReadFile(ctx context.Context, path string) (io.ReadCloser, error)
- func (s *Service) RegisterVersion(version *UploadedVersion) error
- func (s *Service) TestReadWrite(parentCtx context.Context, timeout time.Duration) error
- func (s *Service) UploadFile(parentCtx context.Context, inputStream io.ReadCloser, version *UploadedVersion, ...) (int64, error)
- type UploadedVersion
- type VersionsRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitializeModel ¶
InitializeModel connects model to migrations
Types ¶
type FifoRotationStrategy ¶
type FifoRotationStrategy struct {
// contains filtered or unexported fields
}
FifoRotationStrategy implements a simple queue, first is appended, oldest will be deleted
func NewFifoRotationStrategy ¶
func NewFifoRotationStrategy(collection *collections.Collection, existingVersions []UploadedVersion) *FifoRotationStrategy
NewFifoRotationStrategy is a factorial method
func (*FifoRotationStrategy) CanUpload ¶
func (frs *FifoRotationStrategy) CanUpload(version UploadedVersion) error
CanUpload RotationStrategy can decide if we can still upload
func (*FifoRotationStrategy) GetVersionsThatShouldBeDeletedIfThisVersionUploaded ¶
func (frs *FifoRotationStrategy) GetVersionsThatShouldBeDeletedIfThisVersionUploaded(version UploadedVersion) []UploadedVersion
GetVersionsThatShouldBeDeletedIfThisVersionUploaded interface implementation that allows RotationStrategy to decide which versions should be deleted right now, when uploading a new version
type NestedStreamMiddlewares ¶
type NestedStreamMiddlewares []streamMiddleware
type RotationStrategy ¶
type RotationStrategy interface { // CanUpload returns nil if YES, error if NO CanUpload(version UploadedVersion) error // GetVersionsThatShouldBeDeletedIfThisVersionUploaded lists all the versions that should be deleted if a new version would be submitted GetVersionsThatShouldBeDeletedIfThisVersionUploaded(version UploadedVersion) []UploadedVersion }
RotationStrategy defines how old backups should be rotated
type Service ¶
type Service struct { HealthTimeout time.Duration IOTimeout time.Duration // contains filtered or unexported fields }
func NewService ¶
func NewService(db *gorm.DB, driverUrl string, isUsingGCS bool, healthTimeout time.Duration, ioTimeout time.Duration) (Service, error)
NewService is a factory method that knows how to construct a Storage provider, distincting multiple types of providers
func (*Service) CalculateAllocatedSpaceAboveSingleVersionLimit ¶
func (s *Service) CalculateAllocatedSpaceAboveSingleVersionLimit(collection *collections.Collection, existing []UploadedVersion, excluding []UploadedVersion) (int64, error)
func (*Service) CalculateMaximumAllowedUploadFilesize ¶
func (s *Service) CalculateMaximumAllowedUploadFilesize(collection *collections.Collection, excluding []UploadedVersion) (int64, error)
func (*Service) CleanUpOlderVersions ¶
func (s *Service) CleanUpOlderVersions(versions []UploadedVersion) bool
func (*Service) CopyStream ¶
func (s *Service) CopyStream(ctx context.Context, inputStream io.ReadCloser, writeStream io.Writer, bufferLen int, middlewares *NestedStreamMiddlewares) (int64, error)
CopyStream copies a readable stream to writable stream, while providing a possibility to use a validation callbacks on-the-fly
func (*Service) CreateNewVersionFromCollection ¶
func (s *Service) CreateNewVersionFromCollection(c *collections.Collection, uploader string, uploaderSessionId string, filesize int64) (UploadedVersion, error)
func (*Service) CreateRotationStrategyCase ¶
func (s *Service) CreateRotationStrategyCase(collection *collections.Collection) (RotationStrategy, error)
func (*Service) CreateStandardMiddleWares ¶
func (s *Service) CreateStandardMiddleWares(context context.Context, versionsToDelete []UploadedVersion, collection *collections.Collection) (NestedStreamMiddlewares, error)
func (*Service) Delete ¶
func (s *Service) Delete(version *UploadedVersion) []error
func (*Service) FindAllActiveVersionsFor ¶
func (s *Service) FindAllActiveVersionsFor(id string) ([]UploadedVersion, error)
func (*Service) FindLatestVersion ¶
func (s *Service) FindLatestVersion(collectionId string) (UploadedVersion, error)
func (*Service) FindNextVersionForCollectionId ¶
func (*Service) GetVersionByNum ¶
func (s *Service) GetVersionByNum(collectionId string, version string) (UploadedVersion, error)
func (*Service) RegisterVersion ¶
func (s *Service) RegisterVersion(version *UploadedVersion) error
func (*Service) TestReadWrite ¶
TestReadWrite is performing a simple write & read & delete operation to check if storage is healthy
func (*Service) UploadFile ¶
func (s *Service) UploadFile(parentCtx context.Context, inputStream io.ReadCloser, version *UploadedVersion, middlewares *NestedStreamMiddlewares) (int64, error)
type UploadedVersion ¶
type UploadedVersion struct { Id string `json:"id" structs:"id" sql:"type:string;primary_key;default:uuid_generate_v4()` CollectionId string `json:"collectionId"` VersionNumber int `json:"versionNumber"` Filename string `json:"filename"` // full filename e.g. iwa-ait-v1-db.tar.gz Filesize int64 `json:"filesize"` // in bytes // auditing UploadedBySessionId string `json:"uploadedBySessionId"` Uploader string `json:"user" structs:"user"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` }
func (*UploadedVersion) GetTargetPath ¶
func (u *UploadedVersion) GetTargetPath() string
type VersionsRepository ¶
type VersionsRepository struct {
// contains filtered or unexported fields
}
VersionsRepository persistence layer for Versions