// Listen starts the ksync server locally.
Listen starts the ksync server locally.
// Listen starts the ksync server locally .
func Listen(list *ksync.SpecList, bind string, port int) error {
	lis, err := net.Listen("tcp", fmt.Sprintf("%s:%d", bind, port))
	if err != nil {
		return err
	}
	log.WithFields(log.Fields{
		"bind": bind,
		"port": port,
	}).Info("listening")
	server := &ksyncServer{SpecList: list}
	logrusEntry := log.NewEntry(log.StandardLogger())
	logOpts := []grpc_logrus.Option{
		grpc_logrus.WithDurationField(withDuration),
	}
	opts := []grpc.ServerOption{}
	opts = append(
		opts,
		grpc_middleware.WithUnaryServerChain(
			grpc_ctxtags.UnaryServerInterceptor(),
			grpc_logrus.UnaryServerInterceptor(logrusEntry, logOpts...)),
		grpc_middleware.WithStreamServerChain(
			grpc_ctxtags.StreamServerInterceptor(),
			grpc_logrus.StreamServerInterceptor(logrusEntry, logOpts...)),
	)
	rpcServer := grpc.NewServer(opts...)
	pb.RegisterKsyncServer(rpcServer, server)
	return rpcServer.Serve(lis)
}
func Listen ( list * ksync . SpecList , bind string , port int ) error { lis , err := net . Listen ( " " , fmt . Sprintf ( " " , bind , port ) ) if err != nil { return err } log . WithFields ( log . Fields { " " : bind , " " : port , } ) . Info ( " " ) server := & ksyncServer { SpecList : list } logrusEntry := log . NewEntry ( log . StandardLogger ( ) ) logOpts := [ ] grpc_logrus . Option { grpc_logrus . WithDurationField ( withDuration ) , } opts := [ ] grpc . ServerOption { } opts = append ( opts , grpc_middleware . WithUnaryServerChain ( grpc_ctxtags . UnaryServerInterceptor ( ) , grpc_logrus . UnaryServerInterceptor ( logrusEntry , logOpts ... ) ) , grpc_middleware . WithStreamServerChain ( grpc_ctxtags . StreamServerInterceptor ( ) , grpc_logrus . StreamServerInterceptor ( logrusEntry , logOpts ... ) ) , ) rpcServer := grpc . NewServer ( opts ... ) pb . RegisterKsyncServer ( rpcServer , server ) return rpcServer . Serve ( lis ) }
Listen starts the ksync server locally.
Listen starts the ksync server locally .