当前位置: 首页>>代码示例>>Golang>>正文


Golang Gossip.RegisterSystemConfigCallback方法代码示例

本文整理汇总了Golang中github.com/cockroachdb/cockroach/gossip.Gossip.RegisterSystemConfigCallback方法的典型用法代码示例。如果您正苦于以下问题:Golang Gossip.RegisterSystemConfigCallback方法的具体用法?Golang Gossip.RegisterSystemConfigCallback怎么用?Golang Gossip.RegisterSystemConfigCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cockroachdb/cockroach/gossip.Gossip的用法示例。


在下文中一共展示了Gossip.RegisterSystemConfigCallback方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: newExecutor

// newExecutor creates an Executor and registers a callback on the
// system config.
func newExecutor(db client.DB, gossip *gossip.Gossip, clock *hlc.Clock) *Executor {
	exec := &Executor{
		db:      db,
		reCache: parser.NewRegexpCache(512),
	}
	gossip.RegisterSystemConfigCallback(exec.updateSystemConfig)
	return exec
}
开发者ID:JonathanHub,项目名称:cockroach,代码行数:10,代码来源:executor.go

示例2: newExecutor

// newExecutor creates an Executor and registers a callback on the
// system config.
func newExecutor(db client.DB, gossip *gossip.Gossip, leaseMgr *LeaseManager) *Executor {
	exec := &Executor{
		db:       db,
		reCache:  parser.NewRegexpCache(512),
		leaseMgr: leaseMgr,
	}
	exec.systemConfigCond = sync.NewCond(&exec.systemConfigMu)
	gossip.RegisterSystemConfigCallback(exec.updateSystemConfig)
	return exec
}
开发者ID:gechong,项目名称:cockroach,代码行数:12,代码来源:executor.go

示例3: RefreshLeases

// RefreshLeases starts a goroutine that refreshes the lease manager
// leases for tables received in the latest system configuration via gossip.
func (m *LeaseManager) RefreshLeases(s *stop.Stopper, db *client.DB, gossip *gossip.Gossip) {
	s.RunWorker(func() {
		descKeyPrefix := keys.MakeTablePrefix(uint32(DescriptorTable.ID))
		gossip.RegisterSystemConfigCallback(m.updateSystemConfig)
		for {
			select {
			case <-m.newConfig:
				// Read all tables and their versions
				cfg := m.getSystemConfig()
				if log.V(2) {
					log.Info("received a new config %v", cfg)
				}

				// Loop through the configuration to find all the tables.
				for _, kv := range cfg.Values {
					if kv.Value.Tag != roachpb.ValueType_BYTES {
						continue
					}

					if !bytes.HasPrefix(kv.Key, descKeyPrefix) {
						continue
					}
					// Attempt to unmarshal config into a table/database descriptor.
					var descriptor Descriptor
					if err := kv.Value.GetProto(&descriptor); err != nil {
						log.Warningf("unable to unmarshal descriptor %v", kv.Value)
						continue
					}
					switch union := descriptor.Union.(type) {
					case *Descriptor_Table:
						table := union.Table
						if err := table.Validate(); err != nil {
							log.Errorf("received invalid table descriptor: %v", table)
							continue
						}
						if log.V(2) {
							log.Infof("refreshing lease table: %d, version: %d", table.ID, table.Version)
						}
						// Try to refresh the table lease to one >= this version.
						if err := m.refreshLease(db, table.ID, table.Version); err != nil {
							log.Warning(err)
						}

					case *Descriptor_Database:
						// Ignore.
					}
				}

			case <-s.ShouldStop():
				return
			}
		}
	})
}
开发者ID:Ralkage,项目名称:cockroach,代码行数:56,代码来源:lease.go

示例4: NewExecutor

// NewExecutor creates an Executor and registers a callback on the
// system config.
func NewExecutor(db client.DB, gossip *gossip.Gossip) *Executor {
	exec := &Executor{db: db}
	gossip.RegisterSystemConfigCallback(exec.updateSystemConfig)
	return exec
}
开发者ID:GokulSrinivas,项目名称:cockroach,代码行数:7,代码来源:executor.go


注:本文中的github.com/cockroachdb/cockroach/gossip.Gossip.RegisterSystemConfigCallback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。