💡极致性能的企业级Java服务器框架,RPC,游戏服务器框架,web应用服务器框架。(Extreme fast enterprise Java server framework, can be RPC, game server framework, web server framework.)

Overview

👉 为性能而生的万能服务器框架 👈



Ⅰ. zfoo简介 🚩

  • 性能炸裂,天生异步,Actor设计思想,无锁化设计,基于Spring的MVC式用法的万能RPC框架
  • 极致序列化,原生集成的目前二进制序列化和反序列化速度最快的 zfoo protocol 作为网络通讯协议
  • 高可拓展性,单台服务器部署,集群部署,注册中心加集群部署,网关加集群部署,随意搭配
  • 上能做游戏服务器框架,下能做应用网站服务器框架

完善的工作开发流程,完整的线上解决方案

  • 普通java项目,spring项目,spring boot项目,分布式项目, 无差别热更新代码 hotswap
  • Excel配置自动映射, 单服和分布式Excel热更新方案 storage
  • MongoDB的自动映射框架 orm
  • 事件总线 event
  • 时间任务调度 scheduler
  • 内置在程序里的轻量级cpu,内存,硬盘,网络监控, 无需代码和额外工具,解放运维生产力 monitor

Ⅱ. 背景和适用项目

  • 性能需求极高的项目,如游戏服务器框架,网站服务器框架,单服滚服,全球服,直播聊天,IM系统,实时推送
  • 节省研发成本的项目,如想节省,开发,部署,运维成本
  • 喜欢 KISS法则 的项目 ,简单的配置,优雅的代码

Ⅲ. 完整的工程案例和视频教程

  • zfoo 视频教程,持续更新中
  • tank-game-server 网络游戏《进击的坦克(The Fight of Tanks)》,新手友好,难度2星
  • zapp 图片分享聊天网站,标准的https企业级网站,难度5星

Ⅳ. 问题

Ⅴ. 安装和使用

1. 环境要求

JDK 11+,可以在 OpenJDKOracle JDK 无缝切换

如果你没有安装JDK 11+,快速的安装方法是在Idea的右上角Project Structure,Platform Settings,SDKs中直接下载

2. protocol 目前性能最好的Java序列化和反序列化库

// zfoo协议注册,只能初始化一次
ProtocolManager.initProtocol(Set.of(ComplexObject.class, ObjectA.class, ObjectB.class));

// 序列化
ProtocolManager.write(byteBuf, complexObject);

// 反序列化
var packet = ProtocolManager.read(byteBuf);

3. net 目前速度最快的RPC框架,支持 tcp udp websocket

// 服务提供者,只需要在方法上加个注解,则自动注册接口
@PacketReceiver
public void atUserInfoAsk(Session session, UserInfoAsk ask) {
}

// 消费者,同步请求远程用户信息,会阻塞当前的线程,慎重考虑使用同步请求
var userInfoAsk = UserInfoAsk.valueOf(userId);
var answer = NetContext.getCosumer().syncAsk(userInfoAsk, UserInfoAnswer.class, userId).packet();

// 消费者,异步请求远程用户信息,不会柱塞当前的线程,异步请求成功过后依然会在userId指定的线程执行逻辑
NetContext.getCosumer()
                    .asyncAsk(userInfoAsk, UserInfoAnswer.class, userId)
                    .whenComplete(sm -> {
                        // do something
                    );

4. hotswap 热更新代码,不需要停止服务器,不需要额外的任何配置,一行代码开启热更新

// 传入需要更新的class文件
HotSwapUtils.hotswapClass(bytes);

5. orm 基于mongodb的自动映射框架,使用 caffeine 设计了二级缓存,充分释放数据库压力

// 无需自己写sql和任何配置,直接通过注解定义在数据库中定义一张表
@EntityCache(cacheStrategy = "tenThousand", persister = @Persister("time30s"))
public class UserEntity implements IEntity<Long> {
    @Id
    private long id;
    private String name;
}

// 更新数据库的数据
entityCaches.update(userEntity);

6. event 事件总线解耦不同模块,提高代码的质量

// 接收一个事件,只需要在需要接收事件的方法上加一个注解就会自动监听这个事件
@EventReceiver
public void onNoticeEvent(NoticeEvent event) {
    // do something
}

// 抛出一个事件
EventBus.syncSubmit(MyNoticeEvent.valueOf("同步事件"));
EventBus.asyncSubmit(MyNoticeEvent.valueOf("异步事件"));

7. scheduler 基于cron表达式的定时任务调度框架

@Scheduler(cron = "0/1 * * * * ?")
public void cronSchedulerPerSecond() {
    // do something
}

8. storage excel和Java类自动映射框架,无需代码和任何工具只需要定义一个和excel对应的类,直接解析excel

@Resource
public class StudentResource {
    @Id
    private int id;
    @Index
    private String name;
    private int age;
}

Ⅵ. 提交规范 👏

  • 欢迎喜欢这个项目的人来一起维护这个项目,提交代码的时候注意下面规范
  • Java项目格式化代码的方式采用IntelliJ Idea默认的格式化
  • 所有的接口的参数和方法返回的参数都默认是非空的,如果参数可空,需要加上org.springframework.lang.Nullable注解
  • 代码提交的时候需要固定格式,如给net增加了一个功能,feat[net]: 功能描述,下面给出了一些常用的格式
feat[module]: 新增某一项功能
perf[module]: 优化了模块代码或者优化了什么功能
fix[module]: 修改了什么bug
test[module]: 测试了什么东西
doc[module]: 增加了什么文档
del[module]: 删除了某些功能或者无用代码

Ⅶ. License

zfoo使用 Apache License Version 2.0

Copyright (C) 2020 The zfoo Authors

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.
You might also like...

✈A high-performance RPC based on Java & Netty.

bRPC README 中文版本 一个基于netty的RPC框架 基于netty NIO、IO多路复用。 client与server端建立心跳包保活机制。发生未知断连时,重连保证可靠长连接。 使用kryo序列化,自定义传输包,及传输格式,避免TCP沾包问题。 支持zookeeper或nacos做服务

Dec 16, 2022

Lightweight service-based PubSub, RPC and public APIs in Java

kite - service-based RPC, public APIs and PubSub in Java kite is a collection of reactive application messaging libraries that aim at providing high l

Feb 17, 2022

A base repo for creating RPC microservices in Java with gRPC, jOOQ, and Maven.

Wenower Core OSX local installation Install Protocol Buffer $ brew install protobuf Install Postgresql and joopc database and user $ brew install pos

Jan 9, 2022

A fault tolerant, protocol-agnostic RPC system

A fault tolerant, protocol-agnostic RPC system

Finagle Status This project is used in production at Twitter (and many other organizations), and is being actively developed and maintained. Releases

Jan 4, 2023

Lattice is a powerful, lightweight business extension invoke framework. By using the Lattice framework, complex business customization can be efficiently organized and managed.

Lattice Framework Introduction Lattice is a powerful, lightweight business extension invoke framework. By using the Lattice framework, complex busines

Dec 30, 2022

Text to Speech Project for Spring Boot and Kotlin, Auth Server, Python with Fast API (gTTS)

Text to Speech Project for Spring Boot and Kotlin, Auth Server, Python with Fast API (gTTS)

TTS-App Text to Speech Project for Spring Boot Module (etc Resource, Auth Server, Python with Fast API (gTTS)) Python의 gTTS lib를 활용하여 텍스트를 음성으로 변환하는 서

Dec 21, 2021

A simple Plugin to allow server admins and user with Permissions to change fast and easy thier own Gamemode

A simple Plugin to allow server admins and user with Permissions to change fast and easy thier own Gamemode

A simple Plugin to allow server admins and user with Permissions to change fast and easy thier own Gamemode

Jan 17, 2022

A fast, lightweight and more productive microservices framework

A fast, lightweight and cloud-native microservices framework. Stack Overflow | Google Group | Gitter Chat | Subreddit | Youtube Channel | Documentatio

Jan 5, 2023

"Some" Utilities you can use for your Java projects "freely"! Files are compiled with Java-8 and above, but mostly Java-11.

✨ Java-SomeUtils 🚀 "Some" Utilities you can use for your Java projects "freely"! *"Freely"* forcing you to include the license into your program. Fil

Jan 6, 2023
Comments
  • 服务启动后,有些方法标志为EventReceiver可以注册,有些注册不了

    服务启动后,有些方法标志为EventReceiver可以注册,有些注册不了

    https://github.com/zfoo-project/zfoo/blob/f5c8f3b9ea57b58a15e3b5125b2fea39c94ffb10/event/src/main/java/com/zfoo/event/schema/EventRegisterProcessor.java#L45

    在网上也有人提出这个问题, method的Annotation一直都为空, method.isAnnotationPresent(annotation)返回false

    https://stackoverflow.com/questions/53794925/isannotationpresent-returning-false-always

    opened by dillonnet 5
  • feat[storage]

    feat[storage]

    [1]@Resource注解增加指定固定文件路径功能(将@Resource拆分成两个注解@FilePathResource和@ClassPathResource,分别对应文件路径和类路径);没有指定路径则默认为原功能。 [2]增加@ExcelColumn注解,支持在对应字段中指定excel或者csv文件中的列名(可以解决列名为中文或者其他不符合格式的字符) [3]删除excel,csv以及json文件中需要指定字段类型的多余操作,这可以使得用户不需要事先对excel文件进行预处理 [4]配置文件中scan标签package属性以及resource标签location属性可以指定多个路径 [5]调整了一些相应的注释,文档和细节

    opened by Yuao-github 1
  • fix(sec): upgrade org.springframework:spring-expression to 5.3.17

    fix(sec): upgrade org.springframework:spring-expression to 5.3.17

    What happened?

    There are 1 security vulnerabilities found in org.springframework:spring-expression 5.3.4

    What did I do?

    Upgrade org.springframework:spring-expression from 5.3.4 to 5.3.17 for vulnerability fix

    What did you expect to happen?

    Ideally, no insecure libs should be used.

    The specification of the pull request

    PR Specification from OSCS

    opened by chncaption 0
  • fix(sec): upgrade org.springframework:spring-context to 5.3.19

    fix(sec): upgrade org.springframework:spring-context to 5.3.19

    What happened?

    There are 1 security vulnerabilities found in org.springframework:spring-context 5.3.4

    What did I do?

    Upgrade org.springframework:spring-context from 5.3.4 to 5.3.19 for vulnerability fix

    What did you expect to happen?

    Ideally, no insecure libs should be used.

    The specification of the pull request

    PR Specification from OSCS

    opened by ren-jq101 0
Owner
null
Rivr is a lightweight open-source dialogue engine enabling Java developers to easily create enterprise-grade VoiceXML applications.

Overview Rivr is a lightweight open-source dialogue engine enabling Java developers to easily create enterprise-grade VoiceXML applications. Read our

Nu Echo Inc. 57 Jun 27, 2022
Write enterprise Bitcoin applications with Spring Boot.

Write enterprise Bitcoin applications with Spring Boot. Starter projects with multiple Bitcoin related modules that you can include in your application Google Colab

DE MINING 3 Dec 11, 2022
Discourse-java is a platform where users can freely discuss on topics they want to, and like-minded people can join in and contribute

Discourse is the 100% open source discussion platform built for the next decade of the Internet. Use it as a: mailing list discussion forum long-form

Infosys Ltd 16 Oct 19, 2022
By this package we can get sim info, call logs and sms logs.Also we can find for specific sim info and call logs as well.

sim_sms_call_info A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized package

 Hasib Akon 3 Sep 17, 2022
A manager tool to categorize game assets such as images and sounds/music. The tool enables you to tag these files, so that finding them by tags allows fast searches.

BtAssetManager This application allows you to easily categorize large amounts of image and sound files. You can apply tags to each individual file to

null 21 Sep 15, 2022
This repository is related to the Java Web Developer (ND035), Course - Web Services and APIs

About this Repository This repository is related to the Java Web Developer (ND035), Course - Web Services and APIs It contains the following folders:

Rasha Omran 1 Jan 28, 2022
JSON Web Token implementation for Java according to RFC 7519. Easily create, parse and validate JSON Web Tokens using a fluent API.

JWT-Java JSON Web Token library for Java according to RFC 7519. Table of Contents What are JSON Web Tokens? Header Payload Signature Features Supporte

Bastiaan Jansen 6 Jul 10, 2022
High performance RPC framework based on netty

RPC(Remote Procedure Call)实战 @desc: 仅用于个人学习、了解RPC @date: 2021/01/16 技术组成: 版本一 版本二 版本三 传输层 Netty4 * * 编码层 Kryo * * 应用层 JDK动态代理 * * 服务注册与发现 手动注册+guava缓存

XDD 10 Nov 22, 2022
The application consists of a web page with a list of some movies. The page allows user interaction through ratings of movies listed in the web app.

DSMovie About the project https://matheus-maia-alvarez-dsmovie.netlify.app/ DSMovie is a full stack web and mobile application built during the Spring

Matheus Maia Alvarez 6 Jul 21, 2022
Spring boot backend for marble guessing game inspired by Squid Game TV series.

Back-end for marble guessing game inspired by Squid Game TV series. Built with Spring-boot and WebSocket.

Zaid 4 Sep 3, 2022