Exemplo n.º 1
0
func (p *Pumper) init(rw MsgReadWriter, h Handler,
	ud interface{}, maxIn, maxBackup int) {

	p.stopD = chanutil.NewDoneChan()
	p.rw = rw
	p.rsD = chanutil.NewDoneChan()
	p.imax = maxIn
	p.wsD = chanutil.NewDoneChan()
	p.h = h
	p.ud = ud

	p.rQ.Init()
	p.wQ.Init()

	p.bI.N = 0
	if maxBackup > 0 {
		p.bI.N = maxBackup
		p.bI.Init()
		p.bB.N = 1024
		p.bB.GrowthUnit = 1024
		p.bB.Init()
	}
}
Exemplo n.º 2
0
// NewServerF allocates and returns a new Server.
//
// Note: hsto is "handshake timeout".
func NewServerF(l net.Listener, h Handler, hsto time.Duration,
	pumperMaxIn, pumperMaxBackup int, ioc Converter) *Server {

	s := &Server{}

	s.quitCtx, s.quitF = context.WithCancel(context.Background())
	s.stopD = chanutil.NewDoneChan()
	s.l = l
	s.h = h
	s.hsto = hsto
	s.pumperMaxIn = pumperMaxIn
	s.pumperMaxBackup = pumperMaxBackup
	s.ioc = ioc

	return s
}
Exemplo n.º 3
0
func NewHttpServiceEx(l *net.TCPListener, h ContextHandler) *HttpService {
	s := &HttpService{}

	s.quitCtx, s.quitF = context.WithCancel(context.Background())
	s.stopD = chanutil.NewDoneChan()
	s.l = l
	s.h = h
	s.srv = &http.Server{
		Addr:           s.l.Addr().String(),
		Handler:        s,
		ReadTimeout:    10 * time.Second,
		WriteTimeout:   10 * time.Second,
		MaxHeaderBytes: 1 << 20,
	}

	return s
}