github.com/pachyderm/pachyderm@v1.13.4/src/server/pkg/serviceenv/option.go (about)

     1  package serviceenv
     2  
     3  import (
     4  	"path/filepath"
     5  
     6  	"github.com/pachyderm/pachyderm/src/server/pkg/obj"
     7  	"github.com/pachyderm/pachyderm/src/server/pkg/storage/chunk"
     8  	"github.com/pachyderm/pachyderm/src/server/pkg/storage/fileset"
     9  )
    10  
    11  // ChunkStorageOptions returns the chunk storage options for the service environment.
    12  func (env *ServiceEnv) ChunkStorageOptions() ([]chunk.StorageOption, error) {
    13  	var opts []chunk.StorageOption
    14  	if env.StorageUploadConcurrencyLimit > 0 {
    15  		opts = append(opts, chunk.WithMaxConcurrentObjects(0, env.StorageUploadConcurrencyLimit))
    16  	}
    17  	if env.StorageDiskCacheSize > 0 {
    18  		diskCache, err := obj.NewLocalClient(filepath.Join(env.CacheRoot, "pfs-cache"))
    19  		if err != nil {
    20  			return nil, err
    21  		}
    22  		opts = append(opts, chunk.WithObjectCache(diskCache, env.StorageDiskCacheSize))
    23  	}
    24  	return opts, nil
    25  }
    26  
    27  // FileSetStorageOptions returns the fileset storage options for the service environment.
    28  func (env *ServiceEnv) FileSetStorageOptions() []fileset.StorageOption {
    29  	var opts []fileset.StorageOption
    30  	if env.StorageMemoryThreshold > 0 {
    31  		opts = append(opts, fileset.WithMemoryThreshold(env.StorageMemoryThreshold))
    32  	}
    33  	if env.StorageShardThreshold > 0 {
    34  		opts = append(opts, fileset.WithShardThreshold(env.StorageShardThreshold))
    35  	}
    36  	if env.StorageLevelZeroSize > 0 {
    37  		opts = append(opts, fileset.WithLevelZeroSize(env.StorageLevelZeroSize))
    38  	}
    39  	if env.StorageLevelSizeBase > 0 {
    40  		opts = append(opts, fileset.WithLevelSizeBase(env.StorageLevelSizeBase))
    41  	}
    42  	return opts
    43  }