Documentation ¶
Index ¶
- Variables
- type DealsForFileRange
- type DefaultHandler
- func (DefaultHandler) GetFileDealsHandler(ctx context.Context, db *gorm.DB, id uint64) ([]DealsForFileRange, error)
- func (DefaultHandler) GetFileHandler(ctx context.Context, db *gorm.DB, id uint64) (*model.File, error)
- func (DefaultHandler) PrepareToPackFileHandler(ctx context.Context, db *gorm.DB, fileID uint64) (int64, error)
- func (DefaultHandler) PushFileHandler(ctx context.Context, db *gorm.DB, preparation string, source string, ...) (*model.File, error)
- func (DefaultHandler) RetrieveFileHandler(ctx context.Context, db *gorm.DB, filecoinRetriever FilecoinRetriever, ...) (data io.ReadSeekCloser, name string, modTime time.Time, err error)
- type FilecoinRetriever
- type Handler
- type Info
- type MockFile
- func (m *MockFile) GetFileDealsHandler(ctx context.Context, db *gorm.DB, id uint64) ([]DealsForFileRange, error)
- func (m *MockFile) GetFileHandler(ctx context.Context, db *gorm.DB, id uint64) (*model.File, error)
- func (m *MockFile) PrepareToPackFileHandler(ctx context.Context, db *gorm.DB, fileID uint64) (int64, error)
- func (m *MockFile) PushFileHandler(ctx context.Context, db *gorm.DB, preparation string, source string, ...) (*model.File, error)
- func (m *MockFile) RetrieveFileHandler(ctx context.Context, db *gorm.DB, retriever FilecoinRetriever, id uint64) (data io.ReadSeekCloser, name string, modTime time.Time, err error)
- type UnableToServeRangeError
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type DealsForFileRange ¶ added in v0.5.10
type DefaultHandler ¶
type DefaultHandler struct{}
func (DefaultHandler) GetFileDealsHandler ¶
func (DefaultHandler) GetFileDealsHandler( ctx context.Context, db *gorm.DB, id uint64, ) ([]DealsForFileRange, error)
GetFileDealsHandler retrieves the deals associated with a given file ID.
The method operates by querying the database using the provided file ID. It starts by selecting the relevant file range, joining it with the cars table on the job_id field, and then joining with the deals table using the piece_cid field.
Parameters:
- ctx: The context for managing timeouts and cancellation.
- db: The gorm.DB instance for database operations.
- id: The ID of the file for which deals need to be retrieved.
Returns:
- A slice of DealsForFileRange containing the deals associated with the provided file ID for each FileRange.
- An error if any issues occur during the database operation.
func (DefaultHandler) GetFileHandler ¶
func (DefaultHandler) GetFileHandler( ctx context.Context, db *gorm.DB, id uint64, ) (*model.File, error)
GetFileHandler retrieves a file with its associated file ranges from the database using a given file ID.
This function preloads the associated FileRanges for the queried file. If no record is found matching the provided ID, it returns an ErrNotFound error.
Parameters:
- ctx: The context for managing timeouts and cancellation.
- db: The gorm.DB instance for database operations.
- id: The ID of the file to be retrieved.
Returns:
- A pointer to the retrieved model.File, if found.
- An error if any issues occur during the database operation, including when the file is not found.
func (DefaultHandler) PrepareToPackFileHandler ¶
func (DefaultHandler) PushFileHandler ¶
func (DefaultHandler) PushFileHandler( ctx context.Context, db *gorm.DB, preparation string, source string, fileInfo Info, ) (*model.File, error)
PushFileHandler pushes a file to the database using specified preparation and source details.
This function retrieves the source attachment by its preparation and source. If the source isn't attached to the given preparation, an ErrNotFound error is returned. The function then validates the file's existence in the storage system using the RClone handler. If the file is validated successfully, it is then pushed to the database.
Parameters:
- ctx: The context for managing timeouts and cancellation.
- db: The gorm.DB instance for database operations.
- preparation: The preparation ID or name.
- source: The source ID or name.
- fileInfo: Information regarding the file to be pushed.
Returns:
- A pointer to the pushed model.File, if successful.
- An error if any issues occur during the operation, including when the source isn't attached to the preparation, if the file doesn't exist in the storage system, or if the file already exists
func (DefaultHandler) RetrieveFileHandler ¶ added in v0.5.0
func (DefaultHandler) RetrieveFileHandler( ctx context.Context, db *gorm.DB, filecoinRetriever FilecoinRetriever, id uint64, ) (data io.ReadSeekCloser, name string, modTime time.Time, err error)
RetrieveFileHandler retrieves the actual bytes for a file on disk using a given file ID.
For now, this function only works if the file remains available in its original source storage ¶
Parameters: - ctx: The context for managing timeouts and cancellation. - db: The gorm.DB instance for database operations. - id: The ID of the file to be retrieved.
Returns: - A ReadSeekCloser for the given file - the name of the file - An error if any issues occur during the database operation, including when the file is not found.
type FilecoinRetriever ¶ added in v0.5.1
type Handler ¶
type Handler interface { PrepareToPackFileHandler( ctx context.Context, db *gorm.DB, fileID uint64) (int64, error) GetFileDealsHandler( ctx context.Context, db *gorm.DB, id uint64, ) ([]DealsForFileRange, error) GetFileHandler( ctx context.Context, db *gorm.DB, id uint64, ) (*model.File, error) PushFileHandler( ctx context.Context, db *gorm.DB, preparation string, source string, fileInfo Info, ) (*model.File, error) RetrieveFileHandler( ctx context.Context, db *gorm.DB, retriever FilecoinRetriever, id uint64, ) (data io.ReadSeekCloser, name string, modTime time.Time, err error) }
var Default Handler = &DefaultHandler{}
type Info ¶
type Info struct {
Path string `json:"path"` // Path to the new file, relative to the source
}
type MockFile ¶ added in v0.5.0
func (*MockFile) GetFileDealsHandler ¶ added in v0.5.0
func (*MockFile) GetFileHandler ¶ added in v0.5.0
func (*MockFile) PrepareToPackFileHandler ¶ added in v0.5.0
func (*MockFile) PushFileHandler ¶ added in v0.5.0
func (*MockFile) RetrieveFileHandler ¶ added in v0.5.0
type UnableToServeRangeError ¶ added in v0.5.1
func (UnableToServeRangeError) Error ¶ added in v0.5.1
func (e UnableToServeRangeError) Error() string
func (UnableToServeRangeError) Unwrap ¶ added in v0.5.1
func (e UnableToServeRangeError) Unwrap() error