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


Golang platform.Platform類代碼示例

本文整理匯總了Golang中bosh/platform.Platform的典型用法代碼示例。如果您正苦於以下問題:Golang Platform類的具體用法?Golang Platform怎麽用?Golang Platform使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Platform類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: NewProvider

func NewProvider(
	platform boshplatform.Platform,
	client boshmonit.Client,
	logger boshlog.Logger,
	dirProvider boshdir.DirectoriesProvider,
	handler boshhandler.Handler,
) (p provider) {
	monitJobSupervisor := NewMonitJobSupervisor(
		platform.GetFs(),
		platform.GetRunner(),
		client,
		logger,
		dirProvider,
		2825,
		MonitReloadOptions{
			MaxTries:               3,
			MaxCheckTries:          6,
			DelayBetweenCheckTries: 5 * time.Second,
		},
	)

	p.supervisors = map[string]JobSupervisor{
		"monit":      monitJobSupervisor,
		"dummy":      newDummyJobSupervisor(),
		"dummy-nats": NewDummyNatsJobSupervisor(handler),
	}

	return
}
開發者ID:Jane4PKU,項目名稱:bosh,代碼行數:29,代碼來源:provider.go

示例2: NewFactory

func NewFactory(
	settings boshsettings.Service,
	platform boshplatform.Platform,
	blobstore boshblob.Blobstore,
	taskService boshtask.Service,
	applier boshappl.Applier,
) (factory Factory) {

	fs := platform.GetFs()
	compressor := platform.GetCompressor()

	factory = concreteFactory{
		availableActions: map[string]Action{
			"apply":        newApply(applier, fs, platform),
			"drain":        newDrain(),
			"fetch_logs":   newLogs(compressor, blobstore),
			"get_task":     newGetTask(taskService),
			"get_state":    newGetState(settings, fs),
			"list_disk":    newListDisk(settings, platform),
			"migrate_disk": newMigrateDisk(settings, platform),
			"mount_disk":   newMountDisk(settings, platform),
			"ping":         newPing(),
			"ssh":          newSsh(settings, platform),
			"start":        newStart(),
			"stop":         newStop(),
			"unmount_disk": newUnmountDisk(settings, platform),
		},
	}
	return
}
開發者ID:ian-plosker,項目名稱:bosh,代碼行數:30,代碼來源:concrete_factory.go

示例3: createAwsInfrastructure

func (p Provider) createAwsInfrastructure(metadataHost string, resolver dnsResolver,
	platform boshplatform.Platform) (inf Infrastructure) {

	devicePathResolver := boshdpresolv.NewAwsDevicePathResolver(500*time.Millisecond, platform.GetFs())
	inf = NewAwsInfrastructure(metadataHost, resolver, platform, devicePathResolver)
	return
}
開發者ID:punalpatel,項目名稱:bosh,代碼行數:7,代碼來源:provider.go

示例4: New

func New(inf boshinf.Infrastructure, platform boshplatform.Platform, dirProvider boshdir.DirectoriesProvider) (b bootstrap) {
	b.infrastructure = inf
	b.platform = platform
	b.dirProvider = dirProvider
	b.fs = platform.GetFs()
	return
}
開發者ID:reneedv,項目名稱:bosh,代碼行數:7,代碼來源:bootstrap.go

示例5: Get

func (p MbusHandlerProvider) Get(
	platform boshplatform.Platform,
	dirProvider boshdir.DirectoriesProvider,
) (handler boshhandler.Handler, err error) {
	if p.handler != nil {
		handler = p.handler
		return
	}

	mbusURL, err := url.Parse(p.settings.GetMbusURL())
	if err != nil {
		err = bosherr.WrapError(err, "Parsing handler URL")
		return
	}

	switch mbusURL.Scheme {
	case "nats":
		handler = NewNatsHandler(p.settings, p.logger, yagnats.NewClient())
	case "https":
		handler = micro.NewHTTPSHandler(mbusURL, p.logger, platform.GetFs(), dirProvider)
	default:
		err = bosherr.New("Message Bus Handler with scheme %s could not be found", mbusURL.Scheme)
	}

	p.handler = handler

	return
}
開發者ID:Jane4PKU,項目名稱:bosh,代碼行數:28,代碼來源:handler_provider.go

示例6: NewProvider

func NewProvider(logger boshlog.Logger, platform boshplatform.Platform) (p Provider) {
	digDnsResolver := NewDigDnsResolver(logger)

	p.infrastructures = map[string]Infrastructure{
		"aws":     p.createAwsInfrastructure("http://169.254.169.254", digDnsResolver, platform),
		"dummy":   p.createDummyInfrastructure(platform.GetFs(), platform.GetDirProvider(), platform),
		"vsphere": p.createVsphereInfrastructure(platform, logger),
	}
	return
}
開發者ID:velankanisys,項目名稱:bosh,代碼行數:10,代碼來源:provider.go

示例7: NewProvider

func NewProvider(platform boshplatform.Platform) (p provider) {
	fs := platform.GetFs()
	runner := platform.GetRunner()
	uuidGen := boshuuid.NewGenerator()

	p.blobstores = map[boshsettings.BlobstoreType]Blobstore{
		boshsettings.BlobstoreTypeS3:    newS3Blobstore(fs, runner, uuidGen),
		boshsettings.BlobstoreTypeDummy: newDummyBlobstore(),
	}
	return
}
開發者ID:nicregez,項目名稱:bosh,代碼行數:11,代碼來源:provider.go

示例8: NewProvider

func NewProvider(platform boshplatform.Platform) (p provider) {
	fs := platform.GetFs()
	runner := platform.GetRunner()
	uuidGen := boshuuid.NewGenerator()
	s3cliConfigPath := filepath.Join(boshsettings.VCAP_ETC_DIR, "s3cli")

	p.blobstores = map[boshsettings.BlobstoreType]Blobstore{
		boshsettings.BlobstoreTypeDav:   newDummyBlobstore(),
		boshsettings.BlobstoreTypeDummy: newDummyBlobstore(),
		boshsettings.BlobstoreTypeS3:    newS3Blobstore(fs, runner, uuidGen, s3cliConfigPath),
	}
	return
}
開發者ID:viglesiasce,項目名稱:bosh,代碼行數:13,代碼來源:provider.go

示例9: New

func New(
	inf boshinf.Infrastructure,
	platform boshplatform.Platform,
	dirProvider boshdir.DirectoriesProvider,
	settingsServiceProvider boshsettings.ServiceProvider,
) (b bootstrap) {
	b.fs = platform.GetFs()
	b.infrastructure = inf
	b.platform = platform
	b.dirProvider = dirProvider
	b.settingsServiceProvider = settingsServiceProvider
	return
}
開發者ID:punalpatel,項目名稱:bosh,代碼行數:13,代碼來源:bootstrap.go

示例10: getDiskStats

func getDiskStats(platform boshplatform.Platform, devicePath string) (stats boshmbus.DiskStats) {
	diskStats, err := platform.GetDiskStats(devicePath)
	if err != nil {
		return
	}

	percent := float64(diskStats.Used) / float64(diskStats.Total) * 100
	inodePercent := float64(diskStats.InodeUsed) / float64(diskStats.InodeTotal) * 100

	stats.Percent = fmt.Sprintf("%.0f", percent)
	stats.InodePercent = fmt.Sprintf("%.0f", inodePercent)

	return
}
開發者ID:simonleung8,項目名稱:bosh,代碼行數:14,代碼來源:heartbeat.go

示例11: NewProvider

func NewProvider(
	platform boshplatform.Platform,
	client boshmonit.Client,
	logger boshlog.Logger,
	dirProvider boshdir.DirectoriesProvider,
) (p provider) {

	p.supervisors = map[string]JobSupervisor{
		"monit": NewMonitJobSupervisor(platform.GetFs(), platform.GetRunner(), client, logger, dirProvider),
		"dummy": newDummyJobSupervisor(),
	}

	return
}
開發者ID:UhuruSoftware,項目名稱:bosh_old,代碼行數:14,代碼來源:provider.go

示例12: NewProvider

func NewProvider(
	platform boshplatform.Platform,
	client boshmonit.Client,
	logger boshlog.Logger,
	dirProvider boshdir.DirectoriesProvider,
	handler boshhandler.Handler,
) (p provider) {
	p.supervisors = map[string]JobSupervisor{
		"monit":      NewMonitJobSupervisor(platform.GetFs(), platform.GetRunner(), client, logger, dirProvider, 2825, 5*time.Second),
		"dummy":      newDummyJobSupervisor(),
		"dummy-nats": NewDummyNatsJobSupervisor(handler),
	}

	return
}
開發者ID:punalpatel,項目名稱:bosh,代碼行數:15,代碼來源:provider.go

示例13: updateWithSwapStats

func updateWithSwapStats(platform boshplatform.Platform, hb boshmbus.Heartbeat) (updatedHb boshmbus.Heartbeat) {
	updatedHb = hb
	swapStats, err := platform.GetSwapStats()
	if err != nil {
		return
	}

	percent := float64(swapStats.Used) / float64(swapStats.Total) * 100
	kb := swapStats.Used / 1024

	updatedHb.Vitals.UsedSwap = boshmbus.MemStats{
		Percent: fmt.Sprintf("%.0f", percent),
		Kb:      fmt.Sprintf("%d", kb),
	}
	return
}
開發者ID:simonleung8,項目名稱:bosh,代碼行數:16,代碼來源:heartbeat.go

示例14: updateWithCpuLoad

func updateWithCpuLoad(platform boshplatform.Platform, hb boshmbus.Heartbeat) (updatedHb boshmbus.Heartbeat) {
	updatedHb = hb

	load, err := platform.GetCpuLoad()
	if err != nil {
		return
	}

	one := fmt.Sprintf("%.2f", load.One)
	five := fmt.Sprintf("%.2f", load.Five)
	fifteen := fmt.Sprintf("%.2f", load.Fifteen)

	updatedHb.Vitals.CpuLoad = []string{one, five, fifteen}

	return
}
開發者ID:simonleung8,項目名稱:bosh,代碼行數:16,代碼來源:heartbeat.go

示例15: updateWithCpuStats

func updateWithCpuStats(platform boshplatform.Platform, hb boshmbus.Heartbeat) (updatedHb boshmbus.Heartbeat) {
	updatedHb = hb
	cpuStats, err := platform.GetCpuStats()
	if err != nil {
		return
	}

	user := float64(cpuStats.User) / float64(cpuStats.Total) * 100
	sys := float64(cpuStats.Sys) / float64(cpuStats.Total) * 100
	wait := float64(cpuStats.Wait) / float64(cpuStats.Total) * 100

	updatedHb.Vitals.Cpu = boshmbus.CpuStats{
		User: fmt.Sprintf("%.1f", user),
		Sys:  fmt.Sprintf("%.1f", sys),
		Wait: fmt.Sprintf("%.1f", wait),
	}
	return
}
開發者ID:simonleung8,項目名稱:bosh,代碼行數:18,代碼來源:heartbeat.go


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