func (front *Frontend) AddBackend(address string, protocol *link.StreamProtocol) (uint64, error) { session, err := link.ConnectTimeout(address, time.Second*3, protocol, link.SelfCodec()) if err != nil { return 0, err } front.linksMutex.Lock() defer front.linksMutex.Unlock() front.maxLinkId += 1 front.links[front.maxLinkId] = newFrontLink(session) return front.maxLinkId, nil }
func (backend *Backend) NewListener(listener net.Listener) (link.Listener, error) { lsn, _ := backend.StreamProtocol.NewListener(listener) srv := link.NewServer(lsn, link.SelfCodec()) return NewBackendListener(srv), nil }