本文整理匯總了Golang中github.com/youtube/vitess/go/sync2.ServiceManager.Join方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceManager.Join方法的具體用法?Golang ServiceManager.Join怎麽用?Golang ServiceManager.Join使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/youtube/vitess/go/sync2.ServiceManager
的用法示例。
在下文中一共展示了ServiceManager.Join方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: BenchmarkConnStreamerParseEvents
func BenchmarkConnStreamerParseEvents(b *testing.B) {
filename := testfiles.Locate("binlog_test/vt-0000062347-bin.000001")
var svm sync2.ServiceManager
count := 0
bls := &binlogConnStreamer{dbname: "vt_test_database", sendTransaction: func(tx *proto.BinlogTransaction) error {
count++
return nil
}}
for i := 0; i < b.N; i++ {
events := readEvents(b, filename)
svm.Go(func(svc *sync2.ServiceContext) error {
_, err := bls.parseEvents(svc, events)
return err
})
if err := svm.Join(); err != ServerEOF {
b.Errorf("%v", err)
}
}
b.Logf("%d transactions processed", count)
}
示例2: BenchmarkFileStreamerParseEvents
func BenchmarkFileStreamerParseEvents(b *testing.B) {
filename := testfiles.Locate("binlog_test/vt-0000062347-bin.000001")
var svm sync2.ServiceManager
count := 0
bls := newTestBinlogFileStreamer("vt_test_database", "", myproto.ReplicationPosition{}, func(tx *proto.BinlogTransaction) error {
count++
return nil
})
for i := 0; i < b.N; i++ {
if err := bls.file.Init(filename, 0); err != nil {
b.Fatalf("%v", err)
}
svm.Go(bls.run)
if err := svm.Join(); err != nil {
b.Errorf("%v", err)
}
bls.file.Close()
}
b.Logf("%d transactions processed", count)
}