• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang types.NodeName类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/square/p2/pkg/types.NodeName的典型用法代码示例。如果您正苦于以下问题:Golang NodeName类的具体用法?Golang NodeName怎么用?Golang NodeName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了NodeName类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: ListPods

func (f *FakePodStore) ListPods(podPrefix kp.PodPrefix, hostname types.NodeName) ([]kp.ManifestResult, time.Duration, error) {
	f.podLock.Lock()
	defer f.podLock.Unlock()
	res := make([]kp.ManifestResult, 0)
	for key, manifest := range f.podResults {
		if key.podPrefix == podPrefix && key.hostname == hostname {
			// TODO(mpuncel) make ManifestResult not contain the path, it's silly to have to do things like this
			path := path.Join(string(podPrefix), hostname.String(), string(manifest.ID()))
			uniqueKey, err := kp.PodUniqueKeyFromConsulPath(path)
			if err != nil {
				return nil, 0, err
			}

			res = append(res, kp.ManifestResult{
				Manifest: manifest,
				PodLocation: types.PodLocation{
					Node:  hostname,
					PodID: manifest.ID(),
				},
				PodUniqueKey: uniqueKey,
			})
		}
	}
	return res, 0, nil
}
开发者ID:petertseng,项目名称:p2,代码行数:25,代码来源:fake_store.go


示例2: Pod

func (s *fakeKpStore) Pod(podPrefix kp.PodPrefix, nodeName types.NodeName, podID types.PodID) (
	manifest.Manifest, time.Duration, error) {
	key := path.Join(string(podPrefix), nodeName.String(), podID.String())
	if manifest, ok := s.manifests[key]; ok {
		return manifest, 0, nil
	}
	return nil, 0, pods.NoCurrentManifest
}
开发者ID:drcapulet,项目名称:p2,代码行数:8,代码来源:replication_controller_test.go


示例3: NewLegacyP2RM

// NewLegacyP2RM is a constructor for the P2RM type which configures it to
// remove a "legacy" pod. It will generate the storage types based on its
// api.Client argument
func NewLegacyP2RM(client consulutil.ConsulClient, podName types.PodID, nodeName types.NodeName, labeler labels.ApplicatorWithoutWatches) *P2RM {
	rm := &P2RM{}
	rm.LabelID = path.Join(nodeName.String(), podName.String())
	rm.PodID = podName
	rm.NodeName = nodeName
	rm.PodUniqueKey = ""
	rm.configureStorage(client, labeler)
	return rm
}
开发者ID:petertseng,项目名称:p2,代码行数:12,代码来源:rm.go


示例4: NewP2RM

// NewP2RM is a constructor for the P2RM type. It will generate the necessary
// storage types based on its api.Client argument
func NewP2RM(client consulutil.ConsulClient, podName string, nodeName types.NodeName) *P2RM {
	rm := &P2RM{}
	rm.Client = client
	rm.Store = kp.NewConsulStore(client)
	rm.RCStore = rcstore.NewConsul(client, 5)
	rm.Labeler = labels.NewConsulApplicator(client, 3)
	rm.LabelID = path.Join(nodeName.String(), podName)
	rm.PodName = podName
	rm.NodeName = nodeName

	return rm
}
开发者ID:rudle,项目名称:p2,代码行数:14,代码来源:main.go


示例5: nodePath

func nodePath(podPrefix PodPrefix, nodeName types.NodeName) (string, error) {
	// hook tree is an exception to the rule because they are not scheduled
	// by host, and it is valid to want to watch for them agnostic to pod
	// id. There are plans to deploy hooks by host at which time this
	// exception can be removed
	if podPrefix == HOOK_TREE {
		nodeName = ""
	} else {
		if nodeName == "" {
			return "", util.Errorf("nodeName not specified when computing host path")
		}
	}

	return path.Join(string(podPrefix), nodeName.String()), nil
}
开发者ID:petertseng,项目名称:p2,代码行数:15,代码来源:constants.go


示例6: queryReality

func (r *replication) queryReality(node types.NodeName) (manifest.Manifest, error) {
	for {
		select {
		case r.concurrentRealityRequests <- struct{}{}:
			man, _, err := r.store.Pod(kp.REALITY_TREE, node, r.manifest.ID())
			<-r.concurrentRealityRequests
			return man, err
		case <-time.After(5 * time.Second):
			r.logger.Infof("Waiting on concurrentRealityRequests for pod: %s/%s", node.String(), r.manifest.ID())
		case <-time.After(1 * time.Minute):
			err := util.Errorf("Timed out while waiting for reality query rate limit")
			r.logger.Error(err)
			return nil, err
		}
	}
}
开发者ID:petertseng,项目名称:p2,代码行数:16,代码来源:replication.go


示例7: Schedule

// matches podstore.consulStore signature
func (c Client) Schedule(manifest manifest.Manifest, node types.NodeName) (types.PodUniqueKey, error) {
	manifestBytes, err := manifest.Marshal()
	if err != nil {
		return "", util.Errorf("Could not marshal manifest: %s", err)
	}

	req := &podstore_protos.SchedulePodRequest{
		NodeName: node.String(),
		Manifest: string(manifestBytes),
	}

	resp, err := c.client.SchedulePod(context.Background(), req)
	if err != nil {
		return "", util.Errorf("Could not schedule pod: %s", err)
	}

	return types.PodUniqueKey(resp.PodUniqueKey), nil
}
开发者ID:petertseng,项目名称:p2,代码行数:19,代码来源:client.go


示例8: DeletePod

func (s *fakeKpStore) DeletePod(podPrefix kp.PodPrefix, nodeName types.NodeName, podID types.PodID) (time.Duration, error) {
	key := path.Join(string(podPrefix), nodeName.String(), podID.String())
	delete(s.manifests, key)
	return 0, nil
}
开发者ID:drcapulet,项目名称:p2,代码行数:5,代码来源:replication_controller_test.go


示例9: SetPod

func (s *fakeKpStore) SetPod(podPrefix kp.PodPrefix, nodeName types.NodeName, manifest manifest.Manifest) (time.Duration, error) {
	key := path.Join(string(podPrefix), nodeName.String(), string(manifest.ID()))
	s.manifests[key] = manifest
	return 0, nil
}
开发者ID:drcapulet,项目名称:p2,代码行数:5,代码来源:replication_controller_test.go


示例10: GetHealth

func (f fakeConsulStore) GetHealth(service string, node types.NodeName) (kp.WatchResult, error) {
	return f.results[node.String()], nil
}
开发者ID:drcapulet,项目名称:p2,代码行数:3,代码来源:checker_test.go


示例11: MakePodLabelKey

// these utility functions are used primarily while we exist in a mutable
// deployment world. We will need to figure out how to replace these with
// different datasources to allow RCs and DSs to continue to function correctly
// in the future.
func MakePodLabelKey(node types.NodeName, podID types.PodID) string {
	return node.String() + "/" + podID.String()
}
开发者ID:drcapulet,项目名称:p2,代码行数:7,代码来源:consul_applicator.go


示例12: computeRealityIndexPath

func computeRealityIndexPath(key types.PodUniqueKey, node types.NodeName) string {
	return path.Join("reality", node.String(), key.String())
}
开发者ID:petertseng,项目名称:p2,代码行数:3,代码来源:consul_store.go


示例13: computeIntentIndexPath

func computeIntentIndexPath(key types.PodUniqueKey, node types.NodeName) string {
	return path.Join("intent", node.String(), key.String())
}
开发者ID:petertseng,项目名称:p2,代码行数:3,代码来源:consul_store.go



注:本文中的github.com/square/p2/pkg/types.NodeName类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang types.PodID类代码示例发布时间:2022-05-28
下一篇:
Golang types.PodID函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap