• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang v5.Gilmour类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: stopWordsReply

func stopWordsReply(g *G.Gilmour, stopList *[]string) func(req *G.Request, resp *G.Message) {
	return func(req *G.Request, resp *G.Message) {
		line := fmt.Sprintf("Filtering out stop words")
		g.Signal("example.log", G.NewMessage().SetData(line))

		words := []string{}
		if err := req.Data(&words); err != nil {
			panic(words)
		}

		stopMap := map[string]bool{}
		for _, w := range *stopList {
			stopMap[w] = true
		}

		filtered := []string{}
		for _, w := range words {
			if _, ok := stopMap[w]; !ok {
				filtered = append(filtered, w)
			}
		}

		resp.SetData(filtered)

	}
}
开发者ID:gilmour-libs,项目名称:gilmour-e-go,代码行数:26,代码来源:main.go


示例2: generator

func generator(first, second float64, tick <-chan time.Time, e *G.Gilmour) {
	//Wait for a tick
	<-tick

	packet := map[string]float64{"first": first, "second": second}
	data := G.NewMessage().SetData(packet)

	req := e.NewRequest(fibTopic)
	resp, err := req.Execute(data)
	if err != nil {
		fmt.Println("Error in Handler", err)
		return
	}

	if resp.Code() != 200 {
		fmt.Println("Error in Handler", resp.Code())
		return
	}

	var next float64
	msg := resp.Next()
	if err := msg.GetData(&next); err != nil {
		fmt.Println(err)
		return
	}

	generator(second, next, tick, e)
}
开发者ID:gilmour-libs,项目名称:gilmour-e-go,代码行数:28,代码来源:main.go


示例3: bindListeners

//Bind all service endpoints to their topics.
func bindListeners(g *G.Gilmour) {
	//Third argument is for Opts, which in this case is nil
	g.ReplyTo("weather.fetch", fetchReply(g), nil)
	g.ReplyTo("weather.group", groupReply(g), nil)
	g.ReplyTo("weather.min", minReply(g), nil)
	g.ReplyTo("weather.max", maxReply(g), nil)
}
开发者ID:gilmour-libs,项目名称:gilmour-e-go,代码行数:8,代码来源:main.go


示例4: saveReply

func saveReply(g *G.Gilmour) func(req *G.Request, resp *G.Message) {
	return func(req *G.Request, resp *G.Message) {
		line := fmt.Sprintf("Save")
		g.Signal("example.log", G.NewMessage().SetData(line))

		resp.SetData("Hello from Save")
	}
}
开发者ID:gilmour-libs,项目名称:gilmour-e-go,代码行数:8,代码来源:main.go


示例5: findReply

func findReply(g *G.Gilmour) func(req *G.Request, resp *G.Message) {
	return func(req *G.Request, resp *G.Message) {
		line := fmt.Sprintf("Find")
		g.Signal("example.log", G.NewMessage().SetData(line))

		input := getInput(req)

		resp.SetData(input)
	}
}
开发者ID:gilmour-libs,项目名称:gilmour-e-go,代码行数:10,代码来源:main.go


示例6: wordsReply

func wordsReply(g *G.Gilmour) func(req *G.Request, resp *G.Message) {
	return func(req *G.Request, resp *G.Message) {
		line := fmt.Sprintf("WordCount")
		g.Signal("example.log", G.NewMessage().SetData(line))

		input := getInput(req)
		wordRe := regexp.MustCompile("\\w+")
		words := wordRe.FindAllString(input, -1)
		resp.SetData(words)
	}
}
开发者ID:gilmour-libs,项目名称:gilmour-e-go,代码行数:11,代码来源:main.go


示例7: echoRequest

func echoRequest(wg *sync.WaitGroup, engine *G.Gilmour, msg string) {
	req := engine.NewRequest("echo")
	resp, err := req.Execute(G.NewMessage().SetData(msg))
	if err != nil {
		fmt.Println("Echoclient: error", err.Error())
	}

	defer wg.Done()

	var output string
	if err := resp.Next().GetData(&output); err != nil {
		fmt.Println("Echoclient: error", err.Error())
	} else {
		fmt.Println("Echoclient: received", output)
	}
}
开发者ID:gilmour-libs,项目名称:gilmour-e-go,代码行数:16,代码来源:main.go


示例8: countReply

func countReply(g *G.Gilmour) func(req *G.Request, resp *G.Message) {
	return func(req *G.Request, resp *G.Message) {
		line := fmt.Sprintf("WordCount")
		g.Signal("example.log", G.NewMessage().SetData(line))

		input := []string{}
		if err := req.Data(&input); err != nil {
			panic(err)
		}

		word_counts := make(map[string]int)
		for _, word := range input {
			word_counts[word]++
		}

		resp.SetData(word_counts)
	}
}
开发者ID:gilmour-libs,项目名称:gilmour-e-go,代码行数:18,代码来源:main.go


示例9: popularReply

func popularReply(g *G.Gilmour, wordLen int) func(req *G.Request, resp *G.Message) {
	return func(req *G.Request, resp *G.Message) {
		line := fmt.Sprintf("Popular %v", wordLen)
		g.Signal("example.log", G.NewMessage().SetData(line))

		input := map[string]int{}
		if err := req.Data(&input); err != nil {
			panic(err)
		}

		popular := map[int][]string{}
		score := []int{}

		for k, v := range input {
			if len(k) != wordLen {
				continue
			}
			popular[v] = append(popular[v], k)
		}

		for k := range popular {
			score = append(score, k)
		}

		sort.Sort(sort.Reverse(sort.IntSlice(score)))

		output := struct {
			WordLength int
			Score      int
			Words      []string
		}{WordLength: wordLen}

		if len(score) > 0 {
			output.Score = score[0]
			output.Words = popular[score[0]]
		}
		resp.SetData(output)
	}
}
开发者ID:gilmour-libs,项目名称:gilmour-e-go,代码行数:39,代码来源:main.go


示例10: fetchReply

//Fetch a remote file from the URL received in Request.
func fetchReply(g *G.Gilmour) func(req *G.Request, resp *G.Message) {
	return func(req *G.Request, resp *G.Message) {
		url := getInput(req)

		line := fmt.Sprintf("Fetch %v", url)
		g.Signal("example.log", G.NewMessage().SetData(line))

		response, err := http.Get(url)
		if err != nil {
			panic(err)
		}

		defer response.Body.Close()
		contents, err := ioutil.ReadAll(response.Body)

		if err != nil {
			panic(err)
		}

		//Send back the contents.
		resp.SetData(string(contents))
	}
}
开发者ID:gilmour-libs,项目名称:gilmour-e-go,代码行数:24,代码来源:main.go


示例11: glog

func glog(g *G.Gilmour, msg string) {
	g.Signal("example.log", G.NewMessage().SetData(msg))
}
开发者ID:gilmour-libs,项目名称:gilmour-e-go,代码行数:3,代码来源:main.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang v2.Project类代码示例发布时间:2022-05-28
下一篇:
Golang v1.Watcher类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap