當前位置: 首頁>>代碼示例>>Golang>>正文


Golang EtcdConfig.Codec方法代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/storage/etcd.EtcdConfig.Codec方法的典型用法代碼示例。如果您正苦於以下問題:Golang EtcdConfig.Codec方法的具體用法?Golang EtcdConfig.Codec怎麽用?Golang EtcdConfig.Codec使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在k8s/io/kubernetes/pkg/storage/etcd.EtcdConfig的用法示例。


在下文中一共展示了EtcdConfig.Codec方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: newStorageDestinations

func newStorageDestinations(groupName string, groupMeta *apimachinery.GroupMeta) (*genericapiserver.StorageDestinations, error) {
	storageDestinations := genericapiserver.NewStorageDestinations()
	var storageConfig etcdstorage.EtcdConfig
	storageConfig.ServerList = []string{"http://127.0.0.1:4001"}
	storageConfig.Prefix = genericapiserver.DefaultEtcdPathPrefix
	storageConfig.Codec = groupMeta.Codec
	storageInterface, err := storageConfig.NewStorage()
	if err != nil {
		return nil, err
	}
	storageDestinations.AddAPIGroup(groupName, storageInterface)
	return &storageDestinations, nil
}
開發者ID:ethernetdan,項目名稱:kubernetes,代碼行數:13,代碼來源:apiserver.go

示例2: newEtcd

func newEtcd(etcdServerList []string, interfacesFunc meta.VersionInterfacesFunc, storageVersion, pathPrefix string) (etcdStorage storage.Interface, err error) {
	if storageVersion == "" {
		return etcdStorage, fmt.Errorf("storageVersion is required to create a etcd storage")
	}
	var storageConfig etcdstorage.EtcdConfig
	storageConfig.ServerList = etcdServerList
	storageConfig.Prefix = pathPrefix
	versionedInterface, err := interfacesFunc(storageVersion)
	if err != nil {
		return nil, err
	}
	storageConfig.Codec = versionedInterface.Codec
	return storageConfig.NewStorage()
}
開發者ID:jsravn,項目名稱:kubernetes,代碼行數:14,代碼來源:server.go

示例3: newEtcd

func newEtcd(etcdServerList []string, ns runtime.NegotiatedSerializer, storageGroupVersionString, pathPrefix string) (etcdStorage storage.Interface, err error) {
	if storageGroupVersionString == "" {
		return etcdStorage, fmt.Errorf("storageVersion is required to create a etcd storage")
	}
	storageVersion, err := unversioned.ParseGroupVersion(storageGroupVersionString)
	if err != nil {
		return nil, err
	}

	var storageConfig etcdstorage.EtcdConfig
	storageConfig.ServerList = etcdServerList
	storageConfig.Prefix = pathPrefix
	s, ok := ns.SerializerForMediaType("application/json", nil)
	if !ok {
		return nil, fmt.Errorf("unable to find serializer for JSON")
	}
	storageConfig.Codec = runtime.NewCodec(ns.EncoderForVersion(s, storageVersion), ns.DecoderToVersion(s, unversioned.GroupVersion{Group: storageVersion.Group, Version: runtime.APIVersionInternal}))
	return storageConfig.NewStorage()
}
開發者ID:mjg59,項目名稱:kubernetes,代碼行數:19,代碼來源:server.go

示例4: newEtcd

func newEtcd(etcdServerList []string, ns runtime.NegotiatedSerializer, storageGroupVersionString, memoryGroupVersionString, pathPrefix string, quorum bool) (etcdStorage storage.Interface, err error) {
	if storageGroupVersionString == "" {
		return etcdStorage, fmt.Errorf("storageVersion is required to create a etcd storage")
	}
	storageVersion, err := unversioned.ParseGroupVersion(storageGroupVersionString)
	if err != nil {
		return nil, fmt.Errorf("couldn't understand storage version %v: %v", storageGroupVersionString, err)
	}
	memoryVersion, err := unversioned.ParseGroupVersion(memoryGroupVersionString)
	if err != nil {
		return nil, fmt.Errorf("couldn't understand memory version %v: %v", memoryGroupVersionString, err)
	}

	var storageConfig etcdstorage.EtcdConfig
	storageConfig.ServerList = etcdServerList
	storageConfig.Prefix = pathPrefix
	storageConfig.Quorum = quorum
	s, ok := ns.SerializerForMediaType("application/json", nil)
	if !ok {
		return nil, fmt.Errorf("unable to find serializer for JSON")
	}
	glog.Infof("constructing etcd storage interface.\n  sv: %v\n  mv: %v\n", storageVersion, memoryVersion)
	encoder := ns.EncoderForVersion(s, storageVersion)
	decoder := ns.DecoderToVersion(s, memoryVersion)
	if memoryVersion.Group != storageVersion.Group {
		// Allow this codec to translate between groups.
		if err = versioning.EnableCrossGroupEncoding(encoder, memoryVersion.Group, storageVersion.Group); err != nil {
			return nil, fmt.Errorf("error setting up encoder for %v: %v", storageGroupVersionString, err)
		}
		if err = versioning.EnableCrossGroupDecoding(decoder, storageVersion.Group, memoryVersion.Group); err != nil {
			return nil, fmt.Errorf("error setting up decoder for %v: %v", storageGroupVersionString, err)
		}
	}
	storageConfig.Codec = runtime.NewCodec(encoder, decoder)
	return storageConfig.NewStorage()
}
開發者ID:ethernetdan,項目名稱:kubernetes,代碼行數:36,代碼來源:server.go


注:本文中的k8s/io/kubernetes/pkg/storage/etcd.EtcdConfig.Codec方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。