func NewServer(optFns ...Option) Server {
	opts := getOptions(optFns)
	if opts.external {
		return newExternalServer(opts)
	}

	ch, err := tchannel.NewChannel(opts.svcName, &tchannel.ChannelOptions{
		Logger: tchannel.NewLevelLogger(tchannel.NewLogger(os.Stderr), tchannel.LogLevelWarn),
	})
	if err != nil {
		panic("failed to create channel: " + err.Error())
	}
	if err := ch.ListenAndServe("127.0.0.1:0"); err != nil {
		panic("failed to listen on port 0: " + err.Error())
	}

	s := &internalServer{
		ch:   ch,
		opts: opts,
	}

	tServer := thrift.NewServer(ch)
	tServer.Register(gen.NewTChanSecondServiceServer(handler{calls: &s.thriftCalls}))
	ch.Register(raw.Wrap(rawHandler{calls: &s.rawCalls}), "echo")

	if len(opts.advertiseHosts) > 0 {
		if err := s.Advertise(opts.advertiseHosts); err != nil {
			panic("failed to advertise: " + err.Error())
		}
	}

	return s
}
func NewServer(optFns ...Option) Server {
	opts := getOptions(optFns)
	if opts.external {
		return newExternalServer(opts)
	}

	ch, err := tchannel.NewChannel(opts.svcName, &tchannel.ChannelOptions{
		Logger: tchannel.NewLevelLogger(tchannel.NewLogger(os.Stderr), tchannel.LogLevelWarn),
	})
	if err != nil {
		panic("failed to create channel: " + err.Error())
	}
	if err := ch.ListenAndServe("127.0.0.1:0"); err != nil {
		panic("failed to listen on port 0: " + err.Error())
	}

	s := &internalServer{
		ch:   ch,
		opts: opts,
	}

	tServer := thrift.NewServer(ch)
	tServer.Register(gen.NewTChanSecondServiceServer(handler{calls: &s.thriftCalls}))
	ch.Register(raw.Wrap(rawHandler{calls: &s.rawCalls}), "echo")

	if len(opts.advertiseHosts) > 0 {
		if err := s.Advertise(opts.advertiseHosts); err != nil {
			panic("failed to advertise: " + err.Error())
		}
	}

	return s
}
func NewServer ( optFns ... Option ) Server { opts := getOptions ( optFns ) if opts . external { return newExternalServer ( opts ) } ch , err := tchannel . NewChannel ( opts . svcName , & tchannel . ChannelOptions { Logger : tchannel . NewLevelLogger ( tchannel . NewLogger ( os . Stderr ) , tchannel . LogLevelWarn ) , } ) if err != nil { panic ( " " + err . Error ( ) ) } if err := ch . ListenAndServe ( " " ) ; err != nil { panic ( " " + err . Error ( ) ) } s := & internalServer { ch : ch , opts : opts , } tServer := thrift . NewServer ( ch ) tServer . Register ( gen . NewTChanSecondServiceServer ( handler { calls : & s . thriftCalls } ) ) ch . Register ( raw . Wrap ( rawHandler { calls : & s . rawCalls } ) , " " ) if len ( opts . advertiseHosts ) > 0 { if err := s . Advertise ( opts . advertiseHosts ) ; err != nil { panic ( " " + err . Error ( ) ) } } return s }
// NewServer returns a new Server that can recieve Thrift calls or raw calls.
NewServer returns a new Server that can recieve Thrift calls or raw calls .