Giter VIP home page Giter VIP logo

zns's Introduction

ZNS

What's the ZNS is an implementation of distribution RPC.

1 Introduction

ZNS是一个分布式RPC框架。

  • 通过Zookeeper实现服务的注册与发现

  • 基于Netty实现底层网络通信

  • 采用Spring实现最小依赖注入

2 Feature LIST

  • 服务注册
  • 服务发现
  • 网络通信层
  • 服务异步调用
  • 灵活的水平扩容、缩容
  • 服务生产者与Zookeeper心跳机制
  • 更多的集群服务路由策略
  • 服务监控
  • 服务降级
  • 服务版本控制

3 Architecture

3.1 zns-server

ZNS 服务端:提供了服务注册,接受client端Connector连接,反射调用服务等

3.2 zns-client

ZNS 客户端:提供了服务发现,请求连接server端Acceptor,服务代理等

4 How to use

4.1 服务提供端

  • 添加 zns-server 依赖包
<dependency>
    <groupId>com.buildupchao</groupId>
    <artifactId>zns-service-api</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <exclusions>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </exclusion>
    </exclusions>
</dependency>    
  • 添加扫描包路径ZnsServerPackage.class以及启动调用方法znsServerRunner.run()
@ComponentScan(
        basePackages = "com.buildupchao.zns.service.provider",
        basePackageClasses = ZnsServerPackage.class
)
@SpringBootApplication
public class ZnsServiceProviderApplication implements ApplicationRunner {

    private static final Logger LOGGER = LoggerFactory.getLogger(ZnsServiceProviderApplication.class);

    @Autowired
    private ZnsServerRunner znsServerRunner;

    public static void main(String[] args) {
        SpringApplication.run(ZnsServiceProviderApplication.class, args);

        LOGGER.info("Zns service provider application startup successfully");

    }

    @Override
    public void run(ApplicationArguments applicationArguments) throws Exception {
        znsServerRunner.run();
    }
}
  • 在application.yml中配置属性
zns:
  server:
      zk:
        root: /zns
        addr: localhost:2181
        switch: true
  network:
      port: 8888

4.2 服务消费端

  • 添加 zns-client 依赖包
<dependency>
    <groupId>com.buildupchao</groupId>
    <artifactId>zns-client</artifactId>
    <version>1.0-SNAPSHOT</version>
    <exclusions>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </exclusion>
    </exclusions>
</dependency>
  • 添加扫描包路径ZnsClientPackage.class以及启动调用方法znsClientRunner.run()
@ComponentScan(
        basePackages = "com.buildupchao.zns.service.consumer",
        basePackageClasses = ZnsClientPackage.class
)
@SpringBootApplication
public class ZnsServiceConsumerApplication implements ApplicationRunner {

    @Autowired
    private ZnsClientRunner znsClientRunner;

    public static void main(String[] args) {
        SpringApplication.run(ZnsServiceConsumerApplication.class, args);
    }

    @Override
    public void run(ApplicationArguments applicationArguments) throws Exception {
        znsClientRunner.run();
    }
}
  • 在application.yml中配置属性
zns:
  client:
      zk:
        root: /zns
        addr: localhost:2181
        switch: true
      api:
        package: com.buildupchao.zns.service.api

4.3 公共APIzns-service-api需要引入zns-api包依赖

<dependency>
    <groupId>com.buildupchao</groupId>
    <artifactId>zns-api</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

Contact Me

zns's People

Contributors

buildupchao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.