This commit is contained in:
r8zavetr8v 2025-02-25 14:47:57 -08:00
parent bfec6255bc
commit 2f0b38a3fb
60 changed files with 3260 additions and 3228 deletions

BIN
bin/task Normal file

Binary file not shown.

View File

@ -14,7 +14,7 @@ type Key string
type Value interface {
Int() int
String() string
Float() float32
Float() float64
Duration() time.Duration
}
@ -22,10 +22,10 @@ type DurationValue time.Duration
type FloatValue struct {
EmptyValue
Val float32
Val float64
}
func (v FloatValue) Float() float32 {
func (v FloatValue) Float() float64 {
return v.Val
}
@ -47,8 +47,8 @@ func (v IntValue) Int() int {
return v.Val
}
func (v IntValue) Float() float32 {
return float32(v.Val)
func (v IntValue) Float() float64 {
return float64(v.Val)
}
type EmptyValue struct{}
@ -61,7 +61,7 @@ func (v EmptyValue) String() string {
return ""
}
func (v EmptyValue) Float() float32 {
func (v EmptyValue) Float() float64 {
return 0
}

View File

@ -40,7 +40,7 @@ func (p *staticProvider) GetValue(ctx context.Context, key config.Key) config.Va
return config.StringValue{
Val: val,
}
case float32:
case float64:
return config.FloatValue{
Val: val,
}

View File

@ -0,0 +1,24 @@
package domain
import "fmt"
type StorageType int
const (
StorageTypeFS StorageType = iota
StorageTypeS3
)
const (
fslinkTemplate = "fs:///%s"
)
func GetFSConverter(storageType StorageType) func(fslink string) string {
switch storageType {
default:
// TODO s3 converter
return func(fslink string) string {
return fmt.Sprintf(fslinkTemplate, fslink)
}
}
}

View File

@ -6,6 +6,7 @@ import (
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage"
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files"
// "git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files"
"github.com/google/uuid"
)
@ -26,7 +27,7 @@ func NewFilesEngine(
type File struct {
Name string
UserID uuid.UUID
UserID int64
Ext string
Type string
Size int64
@ -38,7 +39,13 @@ func (e *FilesEngine) SaveFile(
ctx context.Context,
file File,
) (uuid.UUID, error) {
fileID, err := e.metaStorage.SaveMetadata(ctx, files.FileMetadata{})
fileID, err := e.metaStorage.SaveMetadata(ctx, files.FileMetadata{
Name: file.Name,
UserID: file.UserID,
Ext: file.Ext,
Type: file.Type,
// FSLink: f,
})
if err != nil {
return uuid.Nil, fmt.Errorf("failed to create new file metadata: %w", err)
}

View File

@ -36,4 +36,5 @@ type BlobStorage interface {
GetFile(ctx context.Context, id uuid.UUID) (*os.File, error)
SaveBlob(ctx context.Context, id uuid.UUID, data []byte) error
DeleteFile(ctx context.Context, id uuid.UUID) error
GetFSLink(ctx context.Context, fileID uuid.UUID) (string, error)
}