Git Product home page Git Product logo

ray-gateway's Introduction

ray-gateway

在生产环境中,API网关部署的拓扑结构如下图所示。下游服务启动时向注册中心添加自身服务的元数据信息,API网关启动时与注册中心连接,拉取所属命名空间及环境的下游服务的元数据信息,从而完成一系列外部请求的处理与响应,并且在处理请求过程中,将监控数据上报到Kafka中,控制台直接与注册中心交互,完成对各类元数据信息的管理与维护,并且通过拉取Kafka中的数据实现对API网关整体的监控。

API网关部署拓扑图

本系统的开发语言为Java,核心开发框架使用Netty。注册中心采用ETCD,消息队列使用的是Kafka,最后基于Docker进行部署。各种软件的版本如下表所示。

软件 版本号
JDK 1.8
Netty 4.1.51.Final
ETCD 3.3.27
Kafka 3.3.1
Dubbo 2.7.4.1
Zookeeper 3.8
Docker 24.0.7

环境搭建

系统配置

网关核心模块配置

  • core/src/main/resources/gateway.properties 配置文件中注册中心地址 registryAddress 更改为当前部署的ETCD地址
registryAddress=http://#:20000,http://#:20002,http://#:20004
namespace=ray-gateway
env=dev
  • core/src/main/java/cn/ray/gateway/core/GatewayConfig.java 网关配置类中的 kafkaAddress 更改为当前部署的Kafka地址

网关下游服务配置

  • test-mvc/src/main/resources/application.ymltest-mvc/src/main/resources/gateway.properties 配置文件中注册中心地址 ray-gateway.registryAddress 更改为当前部署的ETCD地址
server:
  servlet:
    context-path: /
  port: 8084

ray-gateway:
  registryAddress: http://#:20000,http://#:20002,http://#:20004
  namespace: ray-gateway
  env: dev
  tags: 1

网关控制台配置

  • console/src/main/resources/application.properties 配置文件中注册中心地址 gateway.console.registryAddress 更改为当前部署的ETCD地址,以及 gateway.console.kafkaAddress 更改为当前部署的Kafka地址
server.port=9005

gateway.console.registryAddress=http://#:20000,http://#:20002,http://#:20004
gateway.console.namespace=ray-gateway
gateway.console.env=dev

gateway.console.kafkaAddress=#:9192
gateway.console.consumerNum=1
gateway.console.groupId=gateway-consumer
gateway.console.topicNamePrefix=gateway-metric-topic

系统运行

启动网关

运行 core/src/main/java/cn/ray/gateway/core/Bootstrap.java 网关核心模块中的启动类

启动下游服务

运行 test-mvc/src/main/java/cn/ray/test/mvc/Application.java 网关下游服务启动类

如需启动多个服务,可勾选应用配置 Operation SystemAllow multiple instances 允许多个实例

允许多个服务实例运行

启动一个服务实例后,之后更改其配置文件中的端口配置即可启动对应端口的服务实例

启动控制台

运行 console/src/main/java/cn/ray/gateway/console/Application.java 网关控制台模块启动类

ray-gateway's People

Watchers

xiarui 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.