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

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

示例1: StartDebugServer

func StartDebugServer(address string, sink *lager.ReconfigurableSink, metrics Metrics) (ifrit.Process, error) {
    expvar.Publish("numCPUS", expvar.Func(func() interface{} {
        return metrics.NumCPU()
    }))

    expvar.Publish("numGoRoutines", expvar.Func(func() interface{} {
        return metrics.NumGoroutine()
    }))

    expvar.Publish("loopDevices", expvar.Func(func() interface{} {
        return metrics.LoopDevices()
    }))

    expvar.Publish("backingStores", expvar.Func(func() interface{} {
        return metrics.BackingStores()
    }))

    expvar.Publish("depotDirs", expvar.Func(func() interface{} {
        return metrics.DepotDirs()
    }))

    server := http_server.New(address, handler(sink))
    p := ifrit.Invoke(server)
    select {
    case <-p.Ready():
    case err := <-p.Wait():
        return nil, err
    }
    return p, nil
}

开发者ID:nagyistoce,项目名称:garden-linux,代码行数:30,代码来源:debug.go

示例2: init

/*
 * Initializations
 */
func init() {
    flag.Parse()
    status.InputEventCount = expvar.NewInt("input_event_count")
    status.OutputEventCount = expvar.NewInt("output_event_count")
    status.ErrorCount = expvar.NewInt("error_count")

    expvar.Publish("connection_status",
        expvar.Func(func() interface{} {
            res := make(map[string]interface{}, 0)
            res["last_connect_time"] = status.LastConnectTime
            res["last_error_text"] = status.LastConnectError
            res["last_error_time"] = status.ErrorTime
            if status.IsConnected {
                res["connected"] = true
                res["uptime"] = time.Now().Sub(status.LastConnectTime).Seconds()
            } else {
                res["connected"] = false
                res["uptime"] = 0.0
            }

            return res
        }))
    expvar.Publish("uptime", expvar.Func(func() interface{} {
        return time.Now().Sub(status.StartTime).Seconds()
    }))
    expvar.Publish("subscribed_events", expvar.Func(func() interface{} {
        return config.EventTypes
    }))

    results = make(chan string, 100)
    output_errors = make(chan error)

    status.StartTime = time.Now()
}

开发者ID:carbonblack,项目名称:cb-event-forwarder,代码行数:37,代码来源:main.go

示例3: newOriginAllower

func newOriginAllower(blockedDomains []string, hostname string, gclog logClient, ns *expvar.Map) *originAllower {
    mu := &sync.RWMutex{}
    topKAllDomains := topk.New(100)
    topKOfflistDomains := topk.New(100)
    lifetime := new(expvar.Map).Init()
    ns.Set("lifetime", lifetime)
    lifetime.Set("top_all_domains", expvar.Func(func() interface{} {
        mu.RLock()
        defer mu.RUnlock()
        return topKAllDomains.Keys()
    }))
    lifetime.Set("top_offlist_domains", expvar.Func(func() interface{} {
        mu.RLock()
        defer mu.RUnlock()
        return topKOfflistDomains.Keys()
    }))

    oa := &originAllower{
        m:                  make(map[string]struct{}),
        ns:                 ns,
        hostname:           hostname,
        gclog:              gclog,
        mu:                 mu,
        topKAllDomains:     topKAllDomains,
        topKOfflistDomains: topKOfflistDomains,
    }
    for _, d := range blockedDomains {
        oa.m[d] = struct{}{}
    }
    return oa
}

开发者ID:jmhodges,项目名称:howsmyssl,代码行数:31,代码来源:allow.go

示例4: init

func init() {
    besticon.SetCacheMaxSize(128)

    expvar.Publish("cacheBytes", expvar.Func(func() interface{} { return besticon.GetCacheStats().Bytes }))
    expvar.Publish("cacheItems", expvar.Func(func() interface{} { return besticon.GetCacheStats().Items }))
    expvar.Publish("cacheGets", expvar.Func(func() interface{} { return besticon.GetCacheStats().Gets }))
    expvar.Publish("cacheHits", expvar.Func(func() interface{} { return besticon.GetCacheStats().Hits }))
    expvar.Publish("cacheEvictions", expvar.Func(func() interface{} { return besticon.GetCacheStats().Evictions }))
}

开发者ID:undernewmanagement,项目名称:besticon,代码行数:9,代码来源:server.go

示例5: initDebug

func initDebug(mux *http.ServeMux) {
    stats.prev = time.Now()

    expvar.Publish("dcp", expvar.Func(dcp))
    expvar.Publish("goroutines", expvar.Func(goroutines))

    mux.Handle("/debug/vars/", http.HandlerFunc(expvarHandler))
    mux.Handle("/debug/pprof/", http.HandlerFunc(pprof.Index))
    mux.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
    mux.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
    mux.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
    mux.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))
}

开发者ID:couchbaselabs,项目名称:dcpl,代码行数:13,代码来源:debug.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng