优化结构

This commit is contained in:
Yvan
2026-08-22 12:13:16 +08:00
parent d987244d0e
commit b27a66e9d3
200 changed files with 1794 additions and 1715 deletions
+6 -6
View File
@@ -3,15 +3,15 @@ package storage
import (
"context"
"io"
"kra/internal/biz/system"
"sync"
"kra/internal/biz"
"kra/internal/conf"
)
type Reloadable struct {
mu sync.RWMutex
current biz.FileStorage
current system.FileStorage
}
func NewFileStorage(runtime *conf.Runtime) (*Reloadable, error) {
@@ -30,13 +30,13 @@ func NewReloadable(config *conf.AdminBackend) (*Reloadable, error) {
return &Reloadable{current: current}, nil
}
func (s *Reloadable) Replace(current biz.FileStorage) {
func (s *Reloadable) Replace(current system.FileStorage) {
s.mu.Lock()
s.current = current
s.mu.Unlock()
}
func (s *Reloadable) Put(ctx context.Context, name string, reader io.Reader) (*biz.StoredFile, error) {
func (s *Reloadable) Put(ctx context.Context, name string, reader io.Reader) (*system.StoredFile, error) {
s.mu.RLock()
defer s.mu.RUnlock()
return s.current.Put(ctx, name, reader)
@@ -51,7 +51,7 @@ func (s *Reloadable) Delete(ctx context.Context, name string) error {
defer s.mu.RUnlock()
return s.current.Delete(ctx, name)
}
func (s *Reloadable) Compose(ctx context.Context, names []string, destination string) (*biz.StoredFile, string, error) {
func (s *Reloadable) Compose(ctx context.Context, names []string, destination string) (*system.StoredFile, string, error) {
s.mu.RLock()
defer s.mu.RUnlock()
return s.current.Compose(ctx, names, destination)
@@ -61,7 +61,7 @@ func (s *Reloadable) DeletePrefix(ctx context.Context, prefix string) error {
defer s.mu.RUnlock()
return s.current.DeletePrefix(ctx, prefix)
}
func (s *Reloadable) List(ctx context.Context, prefix, cursor string, limit int) ([]*biz.StoredFile, string, bool, error) {
func (s *Reloadable) List(ctx context.Context, prefix, cursor string, limit int) ([]*system.StoredFile, string, bool, error) {
s.mu.RLock()
defer s.mu.RUnlock()
return s.current.List(ctx, prefix, cursor, limit)