MCPcopy
hub / github.com/grpc/grpc-go / NewServer

Function NewServer

server.go:704–736  ·  server.go::NewServer

NewServer creates a gRPC server which has no service registered and has not started to accept requests yet.

(opt ...ServerOption)

Source from the content-addressed store, hash-verified

702// NewServer creates a gRPC server which has no service registered and has not
703// started to accept requests yet.
704func NewServer(opt ...ServerOption) *Server {
705 opts := defaultServerOptions
706 for _, o := range globalServerOptions {
707 o.apply(&opts)
708 }
709 for _, o := range opt {
710 o.apply(&opts)
711 }
712 s := &Server{
713 lis: make(map[net.Listener]bool),
714 opts: opts,
715 statsHandler: istats.NewCombinedHandler(opts.statsHandlers...),
716 conns: make(map[string]map[transport.ServerTransport]bool),
717 services: make(map[string]*serviceInfo),
718 quit: grpcsync.NewEvent(),
719 done: grpcsync.NewEvent(),
720 channelz: channelz.RegisterServer(""),
721 }
722 chainUnaryServerInterceptors(s)
723 chainStreamServerInterceptors(s)
724 s.cv = sync.NewCond(&s.mu)
725 if EnableTracing {
726 _, file, line, _ := runtime.Caller(1)
727 s.events = newTraceEventLog("grpc.Server", fmt.Sprintf("%s:%d", file, line))
728 }
729
730 if s.opts.numServerWorkers > 0 {
731 s.initServerWorkers()
732 }
733
734 channelz.Info(logger, s.channelz, "Server created")
735 return s
736}
737
738// printf records an event in s's event log, unless s has been stopped.
739// REQUIRES s.mu is held.

Callers 15

startServerFunction · 0.92
TestEnd2EndMethod · 0.92
TestTLSVersionsMethod · 0.92
mainFunction · 0.92
TestProducerMethod · 0.92
TestProducerBackoffMethod · 0.92
TestReflectionEnd2endMethod · 0.92

Calls 8

initServerWorkersMethod · 0.95
NewEventFunction · 0.92
RegisterServerFunction · 0.92
InfoFunction · 0.92
newTraceEventLogFunction · 0.70
applyMethod · 0.65