本文整理汇总了Golang中github.com/cockroachdb/cockroach/pkg/util/stop.Stopper.AddCloser方法的典型用法代码示例。如果您正苦于以下问题:Golang Stopper.AddCloser方法的具体用法?Golang Stopper.AddCloser怎么用?Golang Stopper.AddCloser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cockroachdb/cockroach/pkg/util/stop.Stopper
的用法示例。
在下文中一共展示了Stopper.AddCloser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: createTestAbortCache
// createTestAbortCache creates an in-memory engine and
// returns a abort cache using the supplied Range ID.
func createTestAbortCache(
t *testing.T, rangeID roachpb.RangeID, stopper *stop.Stopper,
) (*AbortCache, engine.Engine) {
eng := engine.NewInMem(roachpb.Attributes{}, 1<<20)
stopper.AddCloser(eng)
return NewAbortCache(rangeID), eng
}
示例2: TestingSetupZoneConfigHook
// TestingSetupZoneConfigHook initializes the zone config hook
// to 'testingZoneConfigHook' which uses 'testingZoneConfig'.
// Settings go back to their previous values when the stopper runs our closer.
func TestingSetupZoneConfigHook(stopper *stop.Stopper) {
stopper.AddCloser(stop.CloserFn(testingResetZoneConfigHook))
testingLock.Lock()
defer testingLock.Unlock()
if testingHasHook {
panic("TestingSetupZoneConfigHook called without restoring state")
}
testingHasHook = true
testingZoneConfig = make(zoneConfigMap)
testingPreviousHook = ZoneConfigHook
ZoneConfigHook = testingZoneConfigHook
testingLargestIDHook = func(maxID uint32) (max uint32) {
testingLock.Lock()
defer testingLock.Unlock()
for id := range testingZoneConfig {
if maxID > 0 && id > maxID {
continue
}
if id > max {
max = id
}
}
return
}
}
示例3: openStore
func openStore(cmd *cobra.Command, dir string, stopper *stop.Stopper) (*engine.RocksDB, error) {
cache := engine.NewRocksDBCache(512 << 20)
defer cache.Release()
maxOpenFiles, err := server.SetOpenFileLimitForOneStore()
if err != nil {
return nil, err
}
db, err := engine.NewRocksDB(
roachpb.Attributes{},
dir,
cache,
0,
maxOpenFiles,
)
if err != nil {
return nil, err
}
stopper.AddCloser(db)
return db, nil
}