本文整理匯總了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
}