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


Golang Wrapper.Subscribe方法代码示例

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


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

示例1: NewProgressEmitter

// Creates a new progress emitter which emits DownloadProgress events every
// interval.
func NewProgressEmitter(cfg *config.Wrapper) *ProgressEmitter {
	t := &ProgressEmitter{
		stop:     make(chan struct{}),
		registry: make(map[string]*sharedPullerState),
		last:     make(map[string]map[string]*pullerProgress),
		timer:    time.NewTimer(time.Millisecond),
	}
	t.Changed(cfg.Raw())
	cfg.Subscribe(t)
	return t
}
开发者ID:qbit,项目名称:syncthing,代码行数:13,代码来源:progressemitter.go

示例2: NewBlockFinder

func NewBlockFinder(db *leveldb.DB, cfg *config.Wrapper) *BlockFinder {
	if blockFinder != nil {
		return blockFinder
	}

	f := &BlockFinder{
		db: db,
	}
	f.Changed(cfg.Raw())
	cfg.Subscribe(f)
	return f
}
开发者ID:qbit,项目名称:syncthing,代码行数:12,代码来源:blockmap.go

示例3: NewProgressEmitter

// NewProgressEmitter creates a new progress emitter which emits
// DownloadProgress events every interval.
func NewProgressEmitter(cfg *config.Wrapper) *ProgressEmitter {
	t := &ProgressEmitter{
		stop:     make(chan struct{}),
		registry: make(map[string]*sharedPullerState),
		last:     make(map[string]map[string]*pullerProgress),
		timer:    time.NewTimer(time.Millisecond),
		mut:      sync.NewMutex(),
	}

	t.CommitConfiguration(config.Configuration{}, cfg.Raw())
	cfg.Subscribe(t)

	return t
}
开发者ID:kattunga,项目名称:syncthing,代码行数:16,代码来源:progressemitter.go

示例4: newUsageReportingManager

func newUsageReportingManager(m *model.Model, cfg *config.Wrapper) *usageReportingManager {
	mgr := &usageReportingManager{
		model: m,
	}

	// Start UR if it's enabled.
	mgr.CommitConfiguration(config.Configuration{}, cfg.Raw())

	// Listen to future config changes so that we can start and stop as
	// appropriate.
	cfg.Subscribe(mgr)

	return mgr
}
开发者ID:kattunga,项目名称:syncthing,代码行数:14,代码来源:usage_report.go

示例5: NewBlockFinder

func NewBlockFinder(db *leveldb.DB, cfg *config.Wrapper) *BlockFinder {
	if blockFinder != nil {
		return blockFinder
	}

	f := &BlockFinder{
		db:  db,
		mut: sync.NewRWMutex(),
	}

	f.CommitConfiguration(config.Configuration{}, cfg.Raw())
	cfg.Subscribe(f)

	return f
}
开发者ID:kattunga,项目名称:syncthing,代码行数:15,代码来源:blockmap.go

示例6: setupGUI

func setupGUI(mainSvc *suture.Supervisor, cfg *config.Wrapper, m *model.Model, apiSub *events.BufferedSubscription) {
	opts := cfg.Options()
	guiCfg := overrideGUIConfig(cfg.GUI(), guiAddress, guiAuthentication, guiAPIKey)

	if guiCfg.Enabled && guiCfg.Address != "" {
		addr, err := net.ResolveTCPAddr("tcp", guiCfg.Address)
		if err != nil {
			l.Fatalf("Cannot start GUI on %q: %v", guiCfg.Address, err)
		} else {
			var hostOpen, hostShow string
			switch {
			case addr.IP == nil:
				hostOpen = "localhost"
				hostShow = "0.0.0.0"
			case addr.IP.IsUnspecified():
				hostOpen = "localhost"
				hostShow = addr.IP.String()
			default:
				hostOpen = addr.IP.String()
				hostShow = hostOpen
			}

			var proto = "http"
			if guiCfg.UseTLS {
				proto = "https"
			}

			urlShow := fmt.Sprintf("%s://%s/", proto, net.JoinHostPort(hostShow, strconv.Itoa(addr.Port)))
			l.Infoln("Starting web GUI on", urlShow)
			api, err := newAPISvc(myID, guiCfg, guiAssets, m, apiSub)
			if err != nil {
				l.Fatalln("Cannot start GUI:", err)
			}
			cfg.Subscribe(api)
			mainSvc.Add(api)

			if opts.StartBrowser && !noBrowser && !stRestarting {
				urlOpen := fmt.Sprintf("%s://%s/", proto, net.JoinHostPort(hostOpen, strconv.Itoa(addr.Port)))
				// Can potentially block if the utility we are invoking doesn't
				// fork, and just execs, hence keep it in it's own routine.
				go openURL(urlOpen)
			}
		}
	}
}
开发者ID:beride,项目名称:syncthing,代码行数:45,代码来源:main.go


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