本文整理汇总了Golang中github.com/bitly/nsq/util.HTTPServer函数的典型用法代码示例。如果您正苦于以下问题:Golang HTTPServer函数的具体用法?Golang HTTPServer怎么用?Golang HTTPServer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HTTPServer函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Main
func (n *NSQD) Main() {
var httpListener net.Listener
var httpsListener net.Listener
ctx := &context{n}
n.waitGroup.Wrap(func() { n.lookupLoop() })
tcpListener, err := net.Listen("tcp", n.tcpAddr.String())
if err != nil {
n.logf("FATAL: listen (%s) failed - %s", n.tcpAddr, err)
os.Exit(1)
}
n.tcpListener = tcpListener
tcpServer := &tcpServer{ctx: ctx}
n.waitGroup.Wrap(func() {
util.TCPServer(n.tcpListener, tcpServer, n.opts.Logger)
})
if n.tlsConfig != nil && n.httpsAddr != nil {
httpsListener, err = tls.Listen("tcp", n.httpsAddr.String(), n.tlsConfig)
if err != nil {
n.logf("FATAL: listen (%s) failed - %s", n.httpsAddr, err)
os.Exit(1)
}
n.httpsListener = httpsListener
httpsServer := &httpServer{
ctx: ctx,
tlsEnabled: true,
tlsRequired: true,
}
n.waitGroup.Wrap(func() {
util.HTTPServer(n.httpsListener, httpsServer, n.opts.Logger, "HTTPS")
})
}
httpListener, err = net.Listen("tcp", n.httpAddr.String())
if err != nil {
n.logf("FATAL: listen (%s) failed - %s", n.httpAddr, err)
os.Exit(1)
}
n.httpListener = httpListener
httpServer := &httpServer{
ctx: ctx,
tlsEnabled: false,
tlsRequired: n.opts.TLSRequired,
}
n.waitGroup.Wrap(func() {
util.HTTPServer(n.httpListener, httpServer, n.opts.Logger, "HTTP")
})
if n.opts.StatsdAddress != "" {
n.waitGroup.Wrap(func() { n.statsdLoop() })
}
}
开发者ID:RetVal,项目名称:nsq,代码行数:54,代码来源:nsqd.go
示例2: Main
func (n *NSQD) Main() {
var httpListener net.Listener
var httpsListener net.Listener
context := &context{n}
if n.options.TLSClientAuthPolicy != "" {
n.options.TLSRequired = true
}
if n.tlsConfig == nil && n.options.TLSRequired {
log.Fatalf("FATAL: cannot require TLS client connections without TLS key and cert")
}
n.waitGroup.Wrap(func() { n.lookupLoop() })
tcpListener, err := net.Listen("tcp", n.tcpAddr.String())
if err != nil {
log.Fatalf("FATAL: listen (%s) failed - %s", n.tcpAddr, err.Error())
}
n.tcpListener = tcpListener
tcpServer := &tcpServer{context: context}
n.waitGroup.Wrap(func() { util.TCPServer(n.tcpListener, tcpServer) })
if n.tlsConfig != nil && n.httpsAddr != nil {
httpsListener, err = tls.Listen("tcp", n.httpsAddr.String(), n.tlsConfig)
if err != nil {
log.Fatalf("FATAL: listen (%s) failed - %s", n.httpsAddr, err.Error())
}
n.httpsListener = httpsListener
httpsServer := &httpServer{
context: context,
tlsEnabled: true,
tlsRequired: true,
}
n.waitGroup.Wrap(func() { util.HTTPServer(n.httpsListener, httpsServer, "HTTPS") })
}
httpListener, err = net.Listen("tcp", n.httpAddr.String())
if err != nil {
log.Fatalf("FATAL: listen (%s) failed - %s", n.httpAddr, err.Error())
}
n.httpListener = httpListener
httpServer := &httpServer{
context: context,
tlsEnabled: false,
tlsRequired: n.options.TLSRequired,
}
n.waitGroup.Wrap(func() { util.HTTPServer(n.httpListener, httpServer, "HTTP") })
if n.options.StatsdAddress != "" {
n.waitGroup.Wrap(func() { n.statsdLoop() })
}
}
开发者ID:rogeriomarques,项目名称:nsq,代码行数:53,代码来源:nsqd.go
示例3: Main
func (n *NSQD) Main() {
context := &context{n}
n.waitGroup.Wrap(func() { n.lookupLoop() })
tcpListener, err := net.Listen("tcp", n.tcpAddr.String())
if err != nil {
log.Fatalf("FATAL: listen (%s) failed - %s", n.tcpAddr, err.Error())
}
n.tcpListener = tcpListener
tcpServer := &tcpServer{context: context}
n.waitGroup.Wrap(func() { util.TCPServer(n.tcpListener, tcpServer) })
httpListener, err := net.Listen("tcp", n.httpAddr.String())
if err != nil {
log.Fatalf("FATAL: listen (%s) failed - %s", n.httpAddr, err.Error())
}
n.httpListener = httpListener
httpServer := &httpServer{context: context}
n.waitGroup.Wrap(func() { util.HTTPServer(n.httpListener, httpServer) })
if n.options.StatsdAddress != "" {
n.waitGroup.Wrap(func() { n.statsdLoop() })
}
}
开发者ID:hzrandd,项目名称:nsq,代码行数:25,代码来源:nsqd.go
示例4: Main
func (l *NSQLookupd) Main() {
ctx := &Context{l}
tcpListener, err := net.Listen("tcp", l.tcpAddr.String())
if err != nil {
l.logf("FATAL: listen (%s) failed - %s", l.tcpAddr, err)
os.Exit(1)
}
l.tcpListener = tcpListener
tcpServer := &tcpServer{ctx: ctx}
l.waitGroup.Wrap(func() {
util.TCPServer(tcpListener, tcpServer, l.opts.Logger)
})
httpListener, err := net.Listen("tcp", l.httpAddr.String())
if err != nil {
l.logf("FATAL: listen (%s) failed - %s", l.httpAddr, err)
os.Exit(1)
}
l.httpListener = httpListener
httpServer := &httpServer{ctx: ctx}
l.waitGroup.Wrap(func() {
util.HTTPServer(httpListener, httpServer, l.opts.Logger, "HTTP")
})
}
开发者ID:RetVal,项目名称:nsq,代码行数:25,代码来源:nsqlookupd.go
示例5: Main
func (n *NSQAdmin) Main() {
httpListener, err := net.Listen("tcp", n.httpAddr.String())
if err != nil {
log.Fatalf("FATAL: listen (%s) failed - %s", n.httpAddr, err.Error())
}
n.httpListener = httpListener
httpServer := NewHTTPServer(&Context{n})
n.waitGroup.Wrap(func() { util.HTTPServer(n.httpListener, httpServer, "HTTP") })
n.waitGroup.Wrap(func() { n.handleAdminActions() })
}
开发者ID:KirillShaman,项目名称:nsq,代码行数:10,代码来源:nsqadmin.go
示例6: Main
func (s *ConsServer) Main() {
httpListener, err := net.Listen("tcp", s.opts.HttpAddr)
if err != nil {
log.Fatalf("ERR: listen (%s) failed - %s", s.opts.HttpAddr, err.Error())
}
s.httpListener = httpListener
httpServer := &httpServer{context: &Context{s}}
s.waitGroup.Wrap(func() { util.HTTPServer(s.httpListener, httpServer, "HTTP") })
cb := func() {
s.loadConf()
ticker := time.NewTicker(time.Minute * 15)
ticker2 := time.NewTicker(time.Minute)
for {
select {
case <-ticker.C:
s.reloadJson()
case <-ticker2.C:
s.updateReader(s.dbpool.InputChan)
case <-s.dbpool.FailChan:
s.Stop()
log.Fatal("Fatal: pool notwork, server exit")
case <-s.quit:
goto END
}
}
END:
log.Println("INF: server quit loop")
s.Stop()
if s.httpListener != nil {
s.httpListener.Close()
}
}
log.Println("INF: server run")
s.waitGroup.Wrap(cb)
}
开发者ID:samuelyao314,项目名称:mygo,代码行数:45,代码来源:server.go
示例7: Main
func (l *NSQLookupd) Main() {
context := &Context{l}
tcpListener, err := net.Listen("tcp", l.tcpAddr.String())
if err != nil {
log.Fatalf("FATAL: listen (%s) failed - %s", l.tcpAddr, err.Error())
}
l.tcpListener = tcpListener
tcpServer := &tcpServer{context: context}
l.waitGroup.Wrap(func() { util.TCPServer(tcpListener, tcpServer) })
httpListener, err := net.Listen("tcp", l.httpAddr.String())
if err != nil {
log.Fatalf("FATAL: listen (%s) failed - %s", l.httpAddr, err.Error())
}
l.httpListener = httpListener
httpServer := &httpServer{context: context}
l.waitGroup.Wrap(func() { util.HTTPServer(httpListener, httpServer, "HTTP") })
}
开发者ID:KirillShaman,项目名称:nsq,代码行数:19,代码来源:nsqlookupd.go
注:本文中的github.com/bitly/nsq/util.HTTPServer函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论