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


Golang skynet.Query类代码示例

本文整理汇总了Golang中github.com/skynetservices/skynet.Query的典型用法代码示例。如果您正苦于以下问题:Golang Query类的具体用法?Golang Query怎么用?Golang Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ListServices

func ListServices(q *skynet.Query) {
	results := q.FindServices()

	for _, service := range results {
		fmt.Println(service)
	}
}
开发者ID:AlphaPerfect,项目名称:skynet-1,代码行数:7,代码来源:sky.go

示例2: ListRegions

func ListRegions(q *skynet.Query) {
	results := q.FindRegions()

	for _, region := range results {
		fmt.Println(region)
	}
}
开发者ID:AlphaPerfect,项目名称:skynet-1,代码行数:7,代码来源:sky.go

示例3: ListHosts

func ListHosts(q *skynet.Query) {
	results := q.FindHosts()

	for _, host := range results {
		fmt.Println(host)
	}
}
开发者ID:AlphaPerfect,项目名称:skynet-1,代码行数:7,代码来源:sky.go

示例4: ListInstances

func ListInstances(q *skynet.Query) {
	var regFlag *bool

	if *RegisteredFlag == "true" {
		b := true
		regFlag = &b
	} else if *RegisteredFlag == "false" {
		b := false
		regFlag = &b
	}

	q.Registered = regFlag

	results := q.FindInstances()

	for _, instance := range results {
		registered := ""

		if instance.Registered {
			registered = " [Registered]"
		}

		fmt.Println(instance.Config.ServiceAddr.IPAddress + ":" + strconv.Itoa(instance.Config.ServiceAddr.Port) + " - " + instance.Config.Name + " " + instance.Config.Version + registered)
	}
}
开发者ID:AlphaPerfect,项目名称:skynet-1,代码行数:25,代码来源:sky.go

示例5: getQueryListMux

func (im *InstanceMonitor) getQueryListMux(q *skynet.Query) (r []skynet.ServiceInfo) {
	for _, s := range im.instances {
		if q.ServiceMatches(s) {
			r = append(r, s)
		}
	}
	return
}
开发者ID:smarinskaya,项目名称:skynet,代码行数:8,代码来源:instancemonitor.go

示例6: PrintTopology

func PrintTopology(q *skynet.Query) {
	topology := make(map[string]map[string]map[string]map[string][]*skynet.ServiceInfo)

	results := q.FindInstances()

	// Build topology hash first
	for _, instance := range results {
		// Prevent runtime nil pointer dereference
		if instance.Config == nil {
			continue
		}
		if topology[instance.Config.Region] == nil {
			topology[instance.Config.Region] = make(map[string]map[string]map[string][]*skynet.ServiceInfo)
		}

		if topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress] == nil {
			topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress] = make(map[string]map[string][]*skynet.ServiceInfo)
		}

		if topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name] == nil {
			topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name] = make(map[string][]*skynet.ServiceInfo)
		}

		if topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name][instance.Config.Version] == nil {
			topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name][instance.Config.Version] = make([]*skynet.ServiceInfo, 0)
		}

		topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name][instance.Config.Version] = append(topology[instance.Config.Region][instance.Config.ServiceAddr.IPAddress][instance.Config.Name][instance.Config.Version], instance)
	}

	// Now we can print the correct heirarchy
	for regionName, region := range topology {
		fmt.Println("Region: " + regionName)

		for hostName, host := range region {
			fmt.Println("\tHost: " + hostName)

			for serviceName, service := range host {
				fmt.Println("\t\tService: " + serviceName)

				for versionName, version := range service {
					fmt.Println("\t\t\tVersion: " + versionName)

					for _, instance := range version {
						registered := ""

						if instance.Registered {
							registered = " [Registered]"
						}

						fmt.Println("\t\t\t\t" + instance.Config.ServiceAddr.IPAddress + ":" + strconv.Itoa(instance.Config.ServiceAddr.Port) + registered)
					}
				}
			}
		}
	}
}
开发者ID:jeffreybaird,项目名称:skynet,代码行数:57,代码来源:sky.go

示例7: removeFromDoozer

func (ss *SubService) removeFromDoozer() {
	q := skynet.Query{
		UUID:       ss.UUID,
		DoozerConn: ss.doozer,
	}

	instances := q.FindInstances()
	for _, instance := range instances {
		ss.doozer.Del(instance.GetConfigPath(), ss.doozer.GetCurrentRevision())
	}
}
开发者ID:smarinskaya,项目名称:skynet,代码行数:11,代码来源:subservice.go

示例8: Unregister

func Unregister(q *skynet.Query) {
	instances := filterDaemon(q.FindInstances())
	for _, instance := range instances {
		cladmin := client.Admin{
			Instance: instance,
		}
		_, err := cladmin.Unregister(skynet.UnregisterRequest{})
		if err != nil {
			config.Log.Error(err.Error())
		}
	}
}
开发者ID:smarinskaya,项目名称:skynet,代码行数:12,代码来源:admin.go

示例9: ListServiceVersions

func ListServiceVersions(q *skynet.Query) {
	if q.Service == "" {
		fmt.Println("Service name is required")
		return
	}

	results := q.FindServiceVersions()

	for _, version := range results {
		fmt.Println(version)
	}
}
开发者ID:AlphaPerfect,项目名称:skynet-1,代码行数:12,代码来源:sky.go

示例10: AdminStop

func AdminStop(q *skynet.Query) {
	instances := q.FindInstances()
	for _, instance := range instances {
		cladmin := client.Admin{
			Instance: instance,
		}
		_, err := cladmin.Stop(skynet.StopRequest{
			WaitForClients: true,
		})
		if err != nil {
			config.Log.Error(err.Error())
		}
	}
}
开发者ID:smarinskaya,项目名称:skynet,代码行数:14,代码来源:admin.go

示例11: sendRPCStop

func (ss *SubService) sendRPCStop() {
	q := skynet.Query{
		UUID:       ss.UUID,
		DoozerConn: ss.doozer,
	}
	instances := q.FindInstances()
	for _, instance := range instances {
		cladmin := client.Admin{
			Instance: instance,
		}

		cladmin.Stop(skynet.StopRequest{
			WaitForClients: true,
		})
	}

}
开发者ID:smarinskaya,项目名称:skynet,代码行数:17,代码来源:subservice.go

示例12: cleanupDoozerEntriesForAddr

func (s *Service) cleanupDoozerEntriesForAddr(addr *skynet.BindAddr) {
	if addr == nil {
		return
	}
	q := skynet.Query{
		Host:       addr.IPAddress,
		Port:       strconv.Itoa(addr.Port),
		DoozerConn: s.doozer(),
	}

	instances := q.FindInstances()

	for _, i := range instances {
		s.Log.Trace("Cleaning up old doozer entry with conflicting addr " +
			addr.String() + "(" + i.GetConfigPath() + ")")
		s.doozer().Del(i.GetConfigPath(), s.doozer().GetCurrentRevision())
		s.doozer().Del(i.GetStatsPath(), s.doozer().GetCurrentRevision())
	}
}
开发者ID:smarinskaya,项目名称:skynet,代码行数:19,代码来源:service.go

示例13: Stop

func Stop(q *skynet.Query) {
	cl := client.NewClient(config)

	for _, instance := range filterDaemon(q.FindInstances()) {
		cdaemon := daemon.GetDaemonForService(cl, instance)

		in := daemon.StopSubServiceRequest{UUID: instance.Config.UUID}
		out, err := cdaemon.StopSubService(in)

		if err != nil {
			if strings.HasPrefix(err.Error(), "No such service UUID") {
				// no daemon on the service's machine, shut it down directly
				AdminStop(q)
			} else {
				fmt.Println(err)
			}
		} else {
			stopTemplate.Execute(os.Stdout, out)
		}
	}
}
开发者ID:smarinskaya,项目名称:skynet,代码行数:21,代码来源:admin.go

示例14: Deploy

// TODO: this should be smarter about which hosts it deploys to
func Deploy(q *skynet.Query, path string, args ...string) {
	cl := client.NewClient(config)

	fmt.Println("deploying " + path + " " + strings.Join(args, ""))

	for _, host := range q.FindHosts() {
		cdaemon := daemon.GetDaemonForHost(cl, host)

		in := daemon.DeployRequest{
			ServicePath: path,
			Args:        shellquote.Join(args...),
		}
		out, err := cdaemon.Deploy(in)

		if err != nil {
			fmt.Println(err)
			return
		}

		deployTemplate.Execute(os.Stdout, out)
	}
}
开发者ID:smarinskaya,项目名称:skynet,代码行数:23,代码来源:admin.go

示例15: Restart

func Restart(q *skynet.Query) {
	cl := client.NewClient(config)

	for _, instance := range filterDaemon(q.FindInstances()) {
		cdaemon := daemon.GetDaemonForService(cl, instance)

		in := daemon.RestartSubServiceRequest{UUID: instance.Config.UUID}
		out, err := cdaemon.RestartSubService(in)

		if err != nil {
			if strings.HasPrefix(err.Error(), "No such service UUID") {
				// Commented out for now, we need to determine if we want to try to restart an unmanaged instance, and support it
				// no daemon on the service's machine, shut it down directly
				//AdminStop(q)
			} else {
				fmt.Println(err)
			}
		} else {
			restartTemplate.Execute(os.Stdout, out)
		}
	}

}
开发者ID:smarinskaya,项目名称:skynet,代码行数:23,代码来源:admin.go


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