mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Add unified-next-grpc (#89891)
This commit is contained in:
parent
afe0848d16
commit
e96b1c0b42
@ -14,12 +14,13 @@ import (
|
||||
type StorageType string
|
||||
|
||||
const (
|
||||
StorageTypeFile StorageType = "file"
|
||||
StorageTypeEtcd StorageType = "etcd"
|
||||
StorageTypeLegacy StorageType = "legacy"
|
||||
StorageTypeUnified StorageType = "unified"
|
||||
StorageTypeUnifiedGrpc StorageType = "unified-grpc"
|
||||
StorageTypeUnifiedNext StorageType = "unified-next"
|
||||
StorageTypeFile StorageType = "file"
|
||||
StorageTypeEtcd StorageType = "etcd"
|
||||
StorageTypeLegacy StorageType = "legacy"
|
||||
StorageTypeUnified StorageType = "unified"
|
||||
StorageTypeUnifiedGrpc StorageType = "unified-grpc"
|
||||
StorageTypeUnifiedNext StorageType = "unified-next"
|
||||
StorageTypeUnifiedNextGrpc StorageType = "unified-next-grpc"
|
||||
)
|
||||
|
||||
type StorageOptions struct {
|
||||
@ -45,10 +46,10 @@ func (o *StorageOptions) AddFlags(fs *pflag.FlagSet) {
|
||||
func (o *StorageOptions) Validate() []error {
|
||||
errs := []error{}
|
||||
switch o.StorageType {
|
||||
case StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedNext:
|
||||
case StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedNext, StorageTypeUnifiedNextGrpc:
|
||||
// no-op
|
||||
default:
|
||||
errs = append(errs, fmt.Errorf("--grafana-apiserver-storage-type must be one of %s, %s, %s, %s, %s, %s", StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedNext))
|
||||
errs = append(errs, fmt.Errorf("--grafana-apiserver-storage-type must be one of %s, %s, %s, %s, %s, %s", StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedNext, StorageTypeUnifiedNextGrpc))
|
||||
}
|
||||
|
||||
if _, _, err := net.SplitHostPort(o.Address); err != nil {
|
||||
|
@ -275,6 +275,23 @@ func (s *service) start(ctx context.Context) error {
|
||||
store := resource.NewLocalResourceStoreClient(resourceServer)
|
||||
serverConfig.Config.RESTOptionsGetter = apistore.NewRESTOptionsGetter(store,
|
||||
o.RecommendedOptions.Etcd.StorageConfig.Codec)
|
||||
case grafanaapiserveroptions.StorageTypeUnifiedNextGrpc:
|
||||
if !s.features.IsEnabledGlobally(featuremgmt.FlagUnifiedStorage) {
|
||||
return fmt.Errorf("unified storage requires the unifiedStorage feature flag")
|
||||
}
|
||||
// Create a connection to the gRPC server
|
||||
conn, err := grpc.NewClient(o.StorageOptions.Address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: determine when to close the connection, we cannot defer it here
|
||||
// defer conn.Close()
|
||||
|
||||
// Create a client instance
|
||||
store := resource.NewResourceStoreClientGRPC(conn)
|
||||
|
||||
serverConfig.Config.RESTOptionsGetter = apistore.NewRESTOptionsGetter(store, o.RecommendedOptions.Etcd.StorageConfig.Codec)
|
||||
|
||||
case grafanaapiserveroptions.StorageTypeUnified:
|
||||
if !s.features.IsEnabledGlobally(featuremgmt.FlagUnifiedStorage) {
|
||||
|
Loading…
Reference in New Issue
Block a user