本文整理汇总了Golang中github.com/briandorsey/partisci/version.Version类的典型用法代码示例。如果您正苦于以下问题:Golang Version类的具体用法?Golang Version怎么用?Golang Version使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Version类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: cmdUpdate
func cmdUpdate(args []string) int {
v := new(version.Version)
if len(args) < 2 {
flag.Usage()
fmt.Fprintf(os.Stderr, "UPDATE requires APP and VERSION\n")
return 1
}
v.App = args[0]
v.Ver = args[1]
if len(args) > 2 {
v.Host = args[2]
}
if len(args) > 3 {
i, err := strconv.ParseUint(args[3], 10, 16)
if err != nil {
fmt.Println("Error parsing Intstance value:", args[3])
return 1
}
v.Instance = uint16(i)
}
err := client.SendUDP(*server, *port, *v)
if err != nil {
fmt.Println(err)
return 1
}
return 0
}
开发者ID:briandorsey,项目名称:partisci,代码行数:27,代码来源:partisci.go
示例2: Update
func (s *SQLiteStore) Update(v version.Version) (err error) {
if v.ExactUpdate.Before(s.threshold) {
return
}
_, err = s.db.Exec(
`insert into version(key, app_id, app, ver, host,
instance, host_ip, last_update, exact_update)
values(?, ?, ?, ?, ?, ?, ?, ?, ?);`,
v.Key(), v.AppId, v.App, v.Ver, v.Host,
v.Instance, v.HostIP, v.LastUpdate, v.ExactUpdate.UnixNano())
return err
}
开发者ID:briandorsey,项目名称:partisci,代码行数:12,代码来源:sqlitestore.go
示例3: Update
func (s *MemoryStore) Update(v version.Version) (err error) {
key := v.Key()
_, vpresent := s.version[key]
if v.ExactUpdate.After(s.threshold) {
s.version[key] = v
}
// app map
if as, present := s.app[v.AppId]; present {
as.LastUpdate = v.LastUpdate
if !vpresent {
as.HostCount++
s.app[v.AppId] = as
}
} else {
appv := version.AppSummary{
App: v.App,
AppId: v.AppId,
LastUpdate: v.LastUpdate,
HostCount: 1,
}
s.app[v.AppId] = appv
}
// host map
if hs, present := s.host[v.Host]; present {
hs.LastUpdate = v.LastUpdate
if !vpresent {
hs.AppCount++
s.host[v.Host] = hs
}
} else {
hostv := version.HostSummary{
Host: v.Host,
LastUpdate: v.LastUpdate,
AppCount: 1,
}
s.host[v.Host] = hostv
}
return
}
开发者ID:briandorsey,项目名称:partisci,代码行数:41,代码来源:memstore.go
示例4: USTestHostSummary
func USTestHostSummary(s store.UpdateStore, t *testing.T) {
v := version.Version{App: "app1", Ver: "ver", Host: "a"}
v.Prepare()
s.Update(v)
if _, ok := s.Host("non-existant"); ok {
t.Error("got ok for non-existant Host")
}
if as, ok := s.Host("a"); ok {
if as.AppCount != 1 {
t.Error("expected AppCount: 1, actual: ", as.AppCount)
}
} else {
t.Error("missing expected Host")
}
v2 := version.Version{App: "app2", Ver: "ver", Host: "a"}
v2.Prepare()
s.Update(v2)
if as, ok := s.Host("a"); ok {
if as.AppCount != 2 {
t.Error("expected AppCount: 2, actual: ", as.AppCount)
}
}
}
开发者ID:briandorsey,项目名称:partisci,代码行数:25,代码来源:sharedtest.go
示例5: Versions
func (s *SQLiteStore) Versions(AppId string, Host string, Ver string) (
vs []version.Version, err error) {
vs = make([]version.Version, 0)
if AppId == "" {
AppId = "%"
}
if Host == "" {
Host = "%"
}
if Ver == "" {
Ver = "%"
}
rows, err := s.db.Query(`
select app_id, app, ver, host,
instance, host_ip, last_update, exact_update
from version
where app_id like ?
and host like ?
and ver like ?;`,
AppId, Host, Ver)
if err != nil {
return nil, err
}
defer rows.Close()
for rows.Next() {
v := version.Version{}
var d int64
err = rows.Scan(&v.AppId, &v.App, &v.Ver, &v.Host,
&v.Instance, &v.HostIP, &v.LastUpdate, &d)
if err != nil {
return nil, err
}
v.ExactUpdate = time.Unix(0, d)
vs = append(vs, v)
}
return vs, nil
}
开发者ID:briandorsey,项目名称:partisci,代码行数:38,代码来源:sqlitestore.go
示例6: USTestTrim
func USTestTrim(s store.UpdateStore, t *testing.T) {
// setup one version in the future and a few more
v1a := version.Version{App: "app1", Ver: "ver", Host: "a"}
v1a.Prepare()
v1a.ExactUpdate = v1a.ExactUpdate.Add(time.Duration(10 * time.Second))
s.Update(v1a)
v1b := version.Version{App: "app1", Ver: "ver", Host: "b"}
v1b.Prepare()
s.Update(v1b)
v2 := version.Version{App: "app2", Ver: "ver", Host: "a"}
v2.Prepare()
s.Update(v2)
// sanity check
if vs, err := s.Versions("", "", ""); len(vs) != 3 {
if err != nil {
t.Fatal(err)
}
t.Fatal("before: version count - expected: 2, actual: ", len(vs))
}
if l, err := s.Hosts(); len(l) != 2 {
if err != nil {
t.Fatal(err)
}
t.Fatal("before: host count - expected: 2, actual: ", len(l))
}
if l, err := s.Apps(); len(l) != 2 {
if err != nil {
t.Fatal(err)
}
t.Fatal("before: app count - expected: 2, actual: ", len(l))
}
// trim every version before 1 second in the future of one version
count, err := s.Trim(v2.ExactUpdate.Add(time.Duration(1 * time.Second)))
if err != nil {
t.Fatal(err)
}
if count != 2 {
t.Fatal("after: trim should have removed 2 versions")
}
if vs, err := s.Versions("", "", ""); len(vs) != 1 {
if err != nil {
t.Fatal(err)
}
t.Fatal("after: version count - expected: 1, actual: ", len(vs))
}
if l, err := s.Hosts(); len(l) != 1 {
if err != nil {
t.Fatal(err)
}
t.Fatal("after: host count - expected: 1, actual: ", len(l))
}
if l, err := s.Apps(); len(l) != 1 {
if err != nil {
t.Fatal(err)
}
t.Fatal("after: app count - expected: 1, actual: ", len(l))
}
// trim every version
count, err = s.Trim(v2.ExactUpdate.Add(time.Duration(20 * time.Second)))
if err != nil {
t.Fatal(err)
}
if count != 1 {
t.Fatal("after all: trim should have removed the last one version")
}
if vs, err := s.Versions("", "", ""); len(vs) != 0 {
if err != nil {
t.Fatal(err)
}
t.Fatal("after all: version count - expected: 0, actual: ", len(vs))
}
if l, err := s.Hosts(); len(l) != 0 {
if err != nil {
t.Fatal(err)
}
t.Fatal(l)
t.Fatal("after all: host count - expected: 0, actual: ", len(l))
}
if l, err := s.Apps(); len(l) != 0 {
if err != nil {
t.Fatal(err)
}
t.Fatal(l)
t.Fatal("after all: app count - expected: 0, actual: ", len(l))
}
}
开发者ID:briandorsey,项目名称:partisci,代码行数:91,代码来源:sharedtest.go
注:本文中的github.com/briandorsey/partisci/version.Version类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论