github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/storage/enginepb/engine.go (about)

     1  // Copyright 2019 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  package enginepb
    12  
    13  import "fmt"
    14  
    15  // Type implements the pflag.Value interface.
    16  func (e *EngineType) Type() string { return "string" }
    17  
    18  // String implements the pflag.Value interface.
    19  func (e *EngineType) String() string {
    20  	switch *e {
    21  	case EngineTypeDefault:
    22  		return "default"
    23  	case EngineTypeRocksDB:
    24  		return "rocksdb"
    25  	case EngineTypePebble:
    26  		return "pebble"
    27  	case EngineTypeTeePebbleRocksDB:
    28  		return "pebble+rocksdb"
    29  	}
    30  	return ""
    31  }
    32  
    33  // Set implements the pflag.Value interface.
    34  func (e *EngineType) Set(s string) error {
    35  	switch s {
    36  	case "default":
    37  		*e = EngineTypeDefault
    38  	case "rocksdb":
    39  		*e = EngineTypeRocksDB
    40  	case "pebble":
    41  		*e = EngineTypePebble
    42  	case "pebble+rocksdb":
    43  		*e = EngineTypeTeePebbleRocksDB
    44  	default:
    45  		return fmt.Errorf("invalid storage engine: %s "+
    46  			"(possible values: rocksdb, pebble)", s)
    47  	}
    48  	return nil
    49  }