Commit 33332a05 authored by Maxim Ivanov's avatar Maxim Ivanov
Browse files

fixup! Extract console storage into own struct to make it more testable

parent 05e7657a
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ type consoleStorageCursor struct {
	Read       int32
}

var collectionSetCache = &atomic.Value{}

func (s *ConsoleStorage) DeleteStorage(ctx context.Context, in *emptypb.Empty) (*emptypb.Empty, error) {
	_, err := s.db.ExecContext(ctx, "TRUNCATE TABLE storage")
	if err != nil {
@@ -397,3 +399,29 @@ func countDatabase(ctx context.Context, logger *zap.Logger, db *sql.DB, tableNam
	}
	return int32(count.Int64)
}

// Because of embedding of  console.UnimplementedConsoleServer method promotion
// doesn't work, so we have to forward methods to satisfy console.ConsoleServer interface
func (s *ConsoleServer) DeleteStorage(ctx context.Context, in *emptypb.Empty) (*emptypb.Empty, error) {
	return s.ConsoleStorage.DeleteStorage(ctx, in)
}

func (s *ConsoleServer) DeleteStorageObject(ctx context.Context, in *console.DeleteStorageObjectRequest) (*emptypb.Empty, error) {
	return s.ConsoleStorage.DeleteStorageObject(ctx, in)
}

func (s *ConsoleServer) GetStorage(ctx context.Context, in *api.ReadStorageObjectId) (*api.StorageObject, error) {
	return s.ConsoleStorage.GetStorage(ctx, in)
}

func (s *ConsoleServer) ListStorageCollections(ctx context.Context, in *emptypb.Empty) (*console.StorageCollectionsList, error) {
	return s.ConsoleStorage.ListStorageCollections(ctx, in)
}

func (s *ConsoleServer) ListStorage(ctx context.Context, in *console.ListStorageRequest) (*console.StorageList, error) {
	return s.ConsoleStorage.ListStorage(ctx, in)
}

func (s *ConsoleServer) WriteStorageObject(ctx context.Context, in *console.WriteStorageObjectRequest) (*api.StorageObjectAck, error) {
	return s.ConsoleStorage.WriteStorageObject(ctx, in)
}