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


Golang Reporter.Report方法代碼示例

本文整理匯總了Golang中github.com/weaveworks/scope/xfer.Reporter.Report方法的典型用法代碼示例。如果您正苦於以下問題:Golang Reporter.Report方法的具體用法?Golang Reporter.Report怎麽用?Golang Reporter.Report使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/weaveworks/scope/xfer.Reporter的用法示例。


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

示例1: makeTopologyList

// makeTopologyList returns a handler that yields an APITopologyList.
func makeTopologyList(rep xfer.Reporter) func(w http.ResponseWriter, r *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		var (
			rpt        = rep.Report()
			topologies = []APITopologyDesc{}
		)
		for name, def := range topologyRegistry {
			if def.parent != "" {
				continue // subtopology, don't show at top level
			}
			subTopologies := []APITopologyDesc{}
			for subName, subDef := range topologyRegistry {
				if subDef.parent == name {
					subTopologies = append(subTopologies, APITopologyDesc{
						Name:  subDef.human,
						URL:   "/api/topology/" + subName,
						Stats: stats(subDef.renderer.Render(rpt)),
					})
				}
			}
			topologies = append(topologies, APITopologyDesc{
				Name:          def.human,
				URL:           "/api/topology/" + name,
				SubTopologies: subTopologies,
				Stats:         stats(def.renderer.Render(rpt)),
			})
		}
		respondWith(w, http.StatusOK, topologies)
	}
}
開發者ID:philipz,項目名稱:scope,代碼行數:31,代碼來源:api_topologies.go

示例2: handleEdge

// Individual edges.
func handleEdge(rep xfer.Reporter, t topologyView, w http.ResponseWriter, r *http.Request) {
	var (
		vars     = mux.Vars(r)
		localID  = vars["local"]
		remoteID = vars["remote"]
		rpt      = rep.Report()
		metadata = t.renderer.EdgeMetadata(rpt, localID, remoteID)
	)

	respondWith(w, http.StatusOK, APIEdge{Metadata: metadata})
}
開發者ID:philipz,項目名稱:scope,代碼行數:12,代碼來源:api_topology.go

示例3: handleNode

// Individual nodes.
func handleNode(rep xfer.Reporter, t topologyView, w http.ResponseWriter, r *http.Request) {
	var (
		vars     = mux.Vars(r)
		nodeID   = vars["id"]
		rpt      = rep.Report()
		node, ok = t.renderer.Render(rep.Report())[nodeID]
	)
	if !ok {
		http.NotFound(w, r)
		return
	}
	respondWith(w, http.StatusOK, APINode{Node: render.MakeDetailedNode(rpt, node)})
}
開發者ID:philipz,項目名稱:scope,代碼行數:14,代碼來源:api_topology.go

示例4: makeOriginHostHandler

// makeOriginHostHandler makes the /api/origin/* handler.
func makeOriginHostHandler(rep xfer.Reporter) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var (
			vars   = mux.Vars(r)
			nodeID = vars["id"]
		)
		origin, ok := getOriginHost(rep.Report().Host, nodeID)
		if !ok {
			http.NotFound(w, r)
			return
		}
		respondWith(w, http.StatusOK, origin)
	}
}
開發者ID:barravi,項目名稱:scope,代碼行數:15,代碼來源:origin_host.go

示例5: handleWebsocket

func handleWebsocket(
	w http.ResponseWriter,
	r *http.Request,
	rep xfer.Reporter,
	t topologyView,
	loop time.Duration,
) {
	conn, err := upgrader.Upgrade(w, r, nil)
	if err != nil {
		// log.Println("Upgrade:", err)
		return
	}
	defer conn.Close()

	quit := make(chan struct{})
	go func(c *websocket.Conn) {
		for { // just discard everything the browser sends
			if _, _, err := c.NextReader(); err != nil {
				close(quit)
				break
			}
		}
	}(conn)

	var (
		previousTopo render.RenderableNodes
		tick         = time.Tick(loop)
	)
	for {
		newTopo := t.renderer.Render(rep.Report())
		diff := render.TopoDiff(previousTopo, newTopo)
		previousTopo = newTopo

		if err := conn.SetWriteDeadline(time.Now().Add(websocketTimeout)); err != nil {
			return
		}
		if err := conn.WriteJSON(diff); err != nil {
			return
		}

		select {
		case <-quit:
			return
		case <-tick:
		}
	}
}
開發者ID:philipz,項目名稱:scope,代碼行數:47,代碼來源:api_topology.go

示例6: makeTopologyList

// makeTopologyList returns a handler that yields an APITopologyList.
func makeTopologyList(rep xfer.Reporter) func(w http.ResponseWriter, r *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		var (
			rpt        = rep.Report()
			topologies = []APITopologyDesc{}
		)
		for name, def := range topologyRegistry {
			// Don't show sub-topologies at the top level.
			if def.parent != "" {
				continue
			}
			decorateTopologyForRequest(r, &def)

			// Collect all sub-topologies of this one, depth=1 only.
			subTopologies := []APITopologyDesc{}
			for subName, subDef := range topologyRegistry {
				if subDef.parent == name {
					decorateTopologyForRequest(r, &subDef)
					subTopologies = append(subTopologies, APITopologyDesc{
						Name:    subDef.human,
						URL:     "/api/topology/" + subName,
						Options: makeTopologyOptions(subDef),
						Stats:   stats(subDef.renderer, rpt),
					})
				}
			}

			// Append.
			topologies = append(topologies, APITopologyDesc{
				Name:          def.human,
				URL:           "/api/topology/" + name,
				SubTopologies: subTopologies,
				Options:       makeTopologyOptions(def),
				Stats:         stats(def.renderer, rpt),
			})
		}
		respondWith(w, http.StatusOK, topologies)
	}
}
開發者ID:webwurst,項目名稱:scope,代碼行數:40,代碼來源:api_topologies.go

示例7: handleTopology

// Full topology.
func handleTopology(rep xfer.Reporter, t topologyView, w http.ResponseWriter, r *http.Request) {
	respondWith(w, http.StatusOK, APITopology{
		Nodes: t.renderer.Render(rep.Report()),
	})
}
開發者ID:philipz,項目名稱:scope,代碼行數:6,代碼來源:api_topology.go

示例8: makeRawReportHandler

// Raw report handler
func makeRawReportHandler(rep xfer.Reporter) func(http.ResponseWriter, *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		// r.ParseForm()
		respondWith(w, http.StatusOK, rep.Report())
	}
}
開發者ID:philipz,項目名稱:scope,代碼行數:7,代碼來源:api_report.go


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