Giter Club home page Giter Club logo

jsongood's Introduction

#轻量级的微服务网关jsongood 简单地,上图说明这个轮子的作用:

img1

###jsongood是一个简单可扩展的API网关框架,支持客户端透明地调用服务端接口(基于JSON序列化),可以在此基础上方便地实现一套微服务网关架构。 ##网关目前已有功能:

  • 可反射调用本地spring bean;
  • 可泛化调用远程dubbo service bean;
  • RPC模块支持基于声明式validation
  • 支持自定义Filter,完成业务上的安全验证、协议转换、访问控制、会话管理等需求;
  • 目前API暴露方式支持Servlet,见ServletRpcServer,当然也可方便扩展至其他通讯架构比如websocket,如需扩展参考DefaultRpcServiceHandler

##未来计划增加的功能

  • 提供类似thrift和pb的IDL代码生成器,基于json scheme来生成不同端上的接口代码,方便更加透明地调用api;
  • 提供其他通讯模块集成,比如websocket,socketio等,保持客户端长连接能大幅优化调用开销;
  • 集成zipkin框架,追踪全链路调用数据
  • 提供ios或者其他语言的调用库

##服务端使用方式


  <!-- jsongood -->
      
        <dependency>
            <groupId>com.github.jessyZu</groupId>
            <artifactId>jsongood-servlet</artifactId>
            <version>1.0.1</version>
        </dependency>

  <!-- validation 可选 -->

  		<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.2.0.Final</version>
        </dependency>

  @Autowired
    private ServletRpcServer rpcServer;

    @RequestMapping("/gateway")
    void apiGateway(HttpServletRequest request, HttpServletResponse response) throws IOException {
        rpcServer.handle(request, response);
    }


##客户端调用方式

###JSON以及JSONP请求 参考https://github.com/jessyZu/jsongood/blob/master/jsongood-demo/src/main/resources/static/test.htm

###android客户端请求 参考https://github.com/jessyZu/jsongood-android-client/blob/master/jsongood-android/src/androidTest/java/com/github/jessyzu/jsongood/RpcManagerTests.java

<dependency>
    <groupId>com.github.jessyZu</groupId>
    <artifactId>jsongood-android</artifactId>
    <version>1.0.1</version>
</dependency>

  manager.invoke("com.github.jessyZu.jsongood.demo.api.DemoService:sayHello1:1.0.0", new Object[]{p1, p2, new Param[]{p1, null}}, new RpcCallback() {
            @Override
            public void success(RpcResult result) {
                if (result.isSuccess()) {
                    Param data = result.dataToObject(Param.class);
                    boolean isMainThread = Looper.myLooper() == Looper.getMainLooper();
                    Log.i(RPCConstants.JSONGOOD_LOG_FLAG, data.toString());

                }
                signal.countDown();
            }

            @Override
            public void failure(Request request, Response response, IOException e) {
                signal.countDown();
                fail();
            }


###IOS客户端请求 后续有时间会提供pod出来,目前不想维护oc版本,直接上swift吧

jsongood's People

Contributors

laizhou avatar

Watchers

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