當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Stopper.AddCloser方法代碼示例

本文整理匯總了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
}
開發者ID:knz,項目名稱:cockroach,代碼行數:9,代碼來源:abort_cache_test.go

示例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
	}
}
開發者ID:knz,項目名稱:cockroach,代碼行數:29,代碼來源:testutil.go

示例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
}
開發者ID:veteranlu,項目名稱:cockroach,代碼行數:20,代碼來源:debug.go


注:本文中的github.com/cockroachdb/cockroach/pkg/util/stop.Stopper.AddCloser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。