本文整理汇总了Golang中github.com/briandorsey/partisci/version.Version.ExactUpdate方法的典型用法代码示例。如果您正苦于以下问题:Golang Version.ExactUpdate方法的具体用法?Golang Version.ExactUpdate怎么用?Golang Version.ExactUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/briandorsey/partisci/version.Version
的用法示例。
在下文中一共展示了Version.ExactUpdate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: 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))
}
}