pkg/mock/mockserver/mockserver.go
func (ms *MockServers) StartAt(idx int) (err error) {
	ms.mu.Lock()
	defer ms.mu.Unlock()

	if ms.Servers[idx].ln == nil {
		ms.Servers[idx].ln, err = net.Listen(ms.Servers[idx].Network, ms.Servers[idx].Address)
		if err != nil {
			return fmt.Errorf("failed to listen %v", err)
		}
	}

	svr := grpc.NewServer()
	pb.RegisterKVServer(svr, &mockKVServer{})
	ms.Servers[idx].GrpcServer = svr

	ms.wg.Add(1)
	go func(svr *grpc.Server, l net.Listener) {
		svr.Serve(l)
	}(ms.Servers[idx].GrpcServer, ms.Servers[idx].ln)
	return nil
}
func (ms *MockServers) StartAt(idx int) (err error) {
	ms.mu.Lock()
	defer ms.mu.Unlock()

	if ms.Servers[idx].ln == nil {
		ms.Servers[idx].ln, err = net.Listen(ms.Servers[idx].Network, ms.Servers[idx].Address)
		if err != nil {
			return fmt.Errorf("failed to listen %v", err)
		}
	}

	svr := grpc.NewServer()
	pb.RegisterKVServer(svr, &mockKVServer{})
	ms.Servers[idx].GrpcServer = svr

	ms.wg.Add(1)
	go func(svr *grpc.Server, l net.Listener) {
		svr.Serve(l)
	}(ms.Servers[idx].GrpcServer, ms.Servers[idx].ln)
	return nil
}
func ( ms * MockServers ) StartAt ( idx int ) ( err error ) { ms . mu . Lock ( ) defer ms . mu . Unlock ( ) if ms . Servers [ idx ] . ln == nil { ms . Servers [ idx ] . ln , err = net . Listen ( ms . Servers [ idx ] . Network , ms . Servers [ idx ] . Address ) if err != nil { return fmt . Errorf ( " " , err ) } } svr := grpc . NewServer ( ) pb . RegisterKVServer ( svr , & mockKVServer { } ) ms . Servers [ idx ] . GrpcServer = svr ms . wg . Add ( 1 ) go func ( svr * grpc . Server , l net . Listener ) { svr . Serve ( l ) } ( ms . Servers [ idx ] . GrpcServer , ms . Servers [ idx ] . ln ) return nil }
// StartAt restarts mock server at given index.
StartAt restarts mock server at given index .