1 Star 0 Fork 37

... / jetty

forked from 郑大侠 / jetty 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

##Ketty

基于netty实现的服务端Nio MVC业务开发平台,提供性能监控,日志分析,动态扩展的功能。

###ketty-srv模块

基于netty实现支持自定义协议扩展的Nio MVC高性能业务框架

####协议

  • Http
  • Ketty(自定义私有协议)

####基于注解的 mvc

  • @Inject注入
  • @Path 路径支持
  • @Param参数自动注入value

####支持方法调用频率限制RateLimiter

@Action
public class SimpleAction {

    @Inject
    private UserService userService;

    // 每秒最多可调用100次,超过100次丢弃,
	@Rate(value=100)
	@Interceptor(id = "echoInterceptor")
    @Path
    public User getUserByUid(@Param String uid) {
        return userService.getUserByUid(uid);
    }
}

####拦截器 example

@Around
public class EchoInterceptor extends BaseInterceptor {

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

    @Override
    public boolean before() {
        LOGGER.info("==============EchoInterceptor before=========");
        return true;
    }

    @Override
    public boolean after() {
        LOGGER.info("==============EchoInterceptor after=========");
        return true;
    }
}

KettyServer example

// nio mvc 业务server启动类example
new KettyServer.Builder()
                .tcpNoDelay(true)
                .soKeepAlive(true)
                .setHttpProtocol()
                .host("localhost")
                .port(8888)
                .build()
                .start();

// 测试jetty客户端
public class JettClientTest {
	public static ClientSender clientSender = new ClientSender("localhost", 8888);
	public static void main(String[] args) throws Exception {
		KettyRequest request = new KettyRequest();
		request.setUri("/simpleAction/getUserByUid");
		JSONObject params = new JSONObject();
		params.put("uid", "12345677");
		request.setParameter(params);
		String result = clientSender.sendAndWait(request);
		System.out.println("result : " + result);
	}
}

HttpServer example

// nio mvc 业务server启动类example
public class SimpleServer {
    public static void main(String[] args) throws Exception {
         new KettyServer.Builder()
                        .setKettyProtocol()
                        .port(8888)
                        .build()
                        .start();
    }
}

####TODO

  • 支持自定义协议扩展
  • 安全验证
  • 性能优化
  • WebSocket协议的实现

###ketty-client模块

KettyServer高可用NIO客户端

####High availability 支持多个节点,节点不可用自动移除

Client pool

支持连接池

断链自动重连

自动维护心跳

###ketty-codec模块

编解码框架

####KettyRequest

header body
size len uri msgId paramsMap body
short(2byte) short(2byte) string int(4byte) map JSONString

####KettyResponse

header body
size len msgId(消息id) resCode(消息返回码) body
short(2byte) short(2byte) int(4byte) short(2byte) JSONString

###ketty-router模块

服务代理模块,提供路由分发功能

###ketty-monitor模块

性能监控 报警

###ketty-analysis模块

接口统计分析 智能推荐

READ MORE

Copyright 2015 by DEMPE Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

基于netty实现的服务端Nio MVC业务开发平台,提供性能监控,日志分析,动态扩展的功能。 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/tiangong.guo/jetty.git
git@gitee.com:tiangong.guo/jetty.git
tiangong.guo
jetty
jetty
master

搜索帮助