ing
This commit is contained in:
		
							parent
							
								
									44bc4f51d8
								
							
						
					
					
						commit
						97acdddce5
					
				@ -14,6 +14,7 @@ func New(addr string) server.Server {
 | 
			
		||||
	registry.RegisterService(new(dRPC.DiscoveryService), "")
 | 
			
		||||
 | 
			
		||||
	sh := NewServerHandler(addr, registry)
 | 
			
		||||
	sh.workersChan = make(chan struct{}, 10)
 | 
			
		||||
 | 
			
		||||
	s := server.NewServer(sh)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -4,11 +4,10 @@ import (
 | 
			
		||||
	"io"
 | 
			
		||||
 | 
			
		||||
	"git.loafle.net/commons_go/rpc"
 | 
			
		||||
	"git.loafle.net/commons_go/server"
 | 
			
		||||
	"git.loafle.net/commons_go/server/ipc"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func NewServerHandler(addr string, registry rpc.Registry) ServerHandler {
 | 
			
		||||
func NewServerHandler(addr string, registry rpc.Registry) *ServerHandlers {
 | 
			
		||||
	sh := &ServerHandlers{
 | 
			
		||||
		registry: registry,
 | 
			
		||||
	}
 | 
			
		||||
@ -17,16 +16,23 @@ func NewServerHandler(addr string, registry rpc.Registry) ServerHandler {
 | 
			
		||||
	return sh
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ServerHandler interface {
 | 
			
		||||
	server.ServerHandler
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ServerHandlers struct {
 | 
			
		||||
	ipc.ServerHandlers
 | 
			
		||||
 | 
			
		||||
	registry rpc.Registry
 | 
			
		||||
	registry    rpc.Registry
 | 
			
		||||
	workersChan chan struct{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (sh *ServerHandlers) Handle(remoteAddr string, rwc io.ReadWriteCloser, stopChan chan struct{}) {
 | 
			
		||||
	contentType := "json"
 | 
			
		||||
 | 
			
		||||
	for {
 | 
			
		||||
		sh.registry.Invoke(contentType, rwc, rwc, nil, nil)
 | 
			
		||||
 | 
			
		||||
		select {
 | 
			
		||||
		case <-stopChan:
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user