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

View File

@ -40,7 +40,7 @@ func (p *staticProvider) GetValue(ctx context.Context, key config.Key) config.Va
return config.StringValue{ return config.StringValue{
Val: val, Val: val,
} }
case float32: case float64:
return config.FloatValue{ return config.FloatValue{
Val: val, 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"
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files" "git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files"
// "git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files"
"github.com/google/uuid" "github.com/google/uuid"
) )
@ -26,7 +27,7 @@ func NewFilesEngine(
type File struct { type File struct {
Name string Name string
UserID uuid.UUID UserID int64
Ext string Ext string
Type string Type string
Size int64 Size int64
@ -38,7 +39,13 @@ func (e *FilesEngine) SaveFile(
ctx context.Context, ctx context.Context,
file File, file File,
) (uuid.UUID, error) { ) (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 { if err != nil {
return uuid.Nil, fmt.Errorf("failed to create new file metadata: %w", err) 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) GetFile(ctx context.Context, id uuid.UUID) (*os.File, error)
SaveBlob(ctx context.Context, id uuid.UUID, data []byte) error SaveBlob(ctx context.Context, id uuid.UUID, data []byte) error
DeleteFile(ctx context.Context, id uuid.UUID) error DeleteFile(ctx context.Context, id uuid.UUID) error
GetFSLink(ctx context.Context, fileID uuid.UUID) (string, error)
} }