当前位置: 首页>>代码示例>>Golang>>正文


Golang URLs.StringSlice方法代码示例

本文整理汇总了Golang中github.com/coreos/etcd/pkg/types.URLs.StringSlice方法的典型用法代码示例。如果您正苦于以下问题:Golang URLs.StringSlice方法的具体用法?Golang URLs.StringSlice怎么用?Golang URLs.StringSlice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/coreos/etcd/pkg/types.URLs的用法示例。


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

示例1: NewMember

func NewMember(name string, peerURLs types.URLs, clusterName string) *member {
	m := &member{
		raftAttributes: raftAttributes{PeerURLs: peerURLs.StringSlice()},
		attributes:     attributes{Name: name},
	}

	var b []byte
	sort.Strings(m.PeerURLs)
	for _, p := range m.PeerURLs {
		b = append(b, []byte(p)...)
	}

	b = append(b, []byte(clusterName)...)

	hash := sha1.Sum(b)
	m.ID = types.ID(binary.BigEndian.Uint64(hash[:8]))
	return m
}
开发者ID:diffoperator,项目名称:etcd,代码行数:18,代码来源:member.go

示例2: newMember

// newMember creates a Member without an ID and generates one based on the
// name, peer URLs. This is used for bootstrapping.
func newMember(name string, peerURLs types.URLs, now *time.Time) *Member {
	m := &Member{Name: name, PeerURLs: peerURLs.StringSlice()}

	b := []byte(m.Name)
	for _, p := range m.PeerURLs {
		b = append(b, []byte(p)...)
	}

	if now != nil {
		b = append(b, []byte(fmt.Sprintf("%d", now.Unix()))...)
	}

	hash := sha1.Sum(b)
	m.ID = int64(binary.BigEndian.Uint64(hash[:8]))
	if m.ID < 0 {
		m.ID = m.ID * -1
	}

	return m
}
开发者ID:digideskio,项目名称:etcd,代码行数:22,代码来源:member.go

示例3: NewMember

// newMember creates a Member without an ID and generates one based on the
// name, peer URLs. This is used for bootstrapping/adding new member.
func NewMember(name string, peerURLs types.URLs, clusterName string, now *time.Time) *Member {
	m := &Member{
		RaftAttributes: RaftAttributes{PeerURLs: peerURLs.StringSlice()},
		Attributes:     Attributes{Name: name},
	}

	var b []byte
	sort.Strings(m.PeerURLs)
	for _, p := range m.PeerURLs {
		b = append(b, []byte(p)...)
	}

	b = append(b, []byte(clusterName)...)
	if now != nil {
		b = append(b, []byte(fmt.Sprintf("%d", now.Unix()))...)
	}

	hash := sha1.Sum(b)
	m.ID = binary.BigEndian.Uint64(hash[:8])
	return m
}
开发者ID:ericcapricorn,项目名称:etcd,代码行数:23,代码来源:member.go


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