Giter VIP home page Giter VIP logo

zfoo-project / zfoo Goto Github PK

View Code? Open in Web Editor NEW
1.8K 50.0 395.0 15.16 MB

💡Extremely fast enterprise server framework, can be used in RPC, game server, web server.

License: Apache License 2.0

Shell 0.14% Java 36.65% C# 7.26% Go 0.65% JavaScript 13.89% Lua 1.18% GDScript 5.76% C++ 1.15% CMake 0.01% TypeScript 6.96% Python 5.60% Kotlin 1.06% Scala 5.87% PHP 0.69% Hack 0.01% Rust 0.87% Ruby 6.01% Dart 5.55% Swift 0.69%
netty serialization game-server spring network websocket rpc orm hotswap mongodb

zfoo's Introduction

English | 简体中文

Ⅰ. Introduction of zfoo🚩

  • Extremely fast, asynchronous, actor design, lock free, universal RPC framework, native GraalVM support
  • High scalability, Single server deployment, microservice deployment, cluster deployment, gateway deployment
  • Can be used as a game server framework or website server framework
  • zfoo protocol supports C++ Rust Java/Kotlin/Scala JavaScript/TypeScript/ES C# Go Php Ruby Lua GDScript Python Dart Swift

Perfect work development process, complete online solution

  • Spring projects, distributed projects, container projects, hot update code without downtime hotswap
  • Excel json csv configuration is automatically mapped and parsed, Online hotswap configuration storage
  • Automapping framework for MongoDB orm
  • Event bus event
  • Time task scheduling scheduler
  • Cpu, memory, hard disk, network monitoring built into the program no code and extra tools required monitor

Ⅱ. Who uses this project

  • Projects with extremely high-performance requirements, such as website and game server frameworks, single server, global server, live chat, IM system, real-time push
  • Projects such as saving, development, deployment, operation and maintenance costs
  • As a backend infrastructure for Godot, Unity, Cocos,Webgl, H5, Network protocol supports tcp udp websocket http
  • Keep it Simple and Stupid, simple configuration, lightweight code

Ⅲ. Maven dependency✨

  • Environment requirement JDK 17+, support OpenJDK, Oracle JDK and native GraalVM
<dependency>
    <groupId>com.zfoo</groupId>
    <artifactId>boot</artifactId>
    <version>3.3.2</version>
</dependency>
  • If you don't want to depend on all zfoo modules, you only need to choose to depend on one of them
<dependency>
    <groupId>com.zfoo</groupId>
    <artifactId>protocol</artifactId>
    <version>3.3.2</version>
</dependency>

Ⅳ. Tutorials

Ⅴ. Usage⭐

1. protocol ultimate performance serialization and deserialization

// zfoo protocol registration, can only be initialized once
ProtocolManager.initProtocol(Set.of(ComplexObject.class, ObjectA.class, ObjectB.class));

// serialization
ProtocolManager.write(byteBuf, complexObject);

// deserialization
var packet = ProtocolManager.read(byteBuf);

2. net ultimate performance RPC framework, supports tcp udp websocket http

// Service provider, only need to add an annotation to the method, the interface will be automatically registered
@PacketReceiver
public void atUserInfoAsk(Session session, UserInfoAsk ask) {
}

// Consumers, synchronously requesting remote service, will block the current thread
var userInfoAsk = UserInfoAsk.valueOf(userId);
var answer = NetContext.getCosumer().syncAsk(userInfoAsk, UserInfoAnswer.class, userId).packet();

// Consumers, asynchronously requesting remote service, and will still execute logic in the current thread after the asynchronous
NetContext.getCosumer()
                    .asyncAsk(userInfoAsk, UserInfoAnswer.class, userId)
                    .whenComplete(sm -> {
                        // do something
                    );

3. hotswap hot update code, no need to stop the server, no additional configuration, just one line of code to start hot update

// Pass in the class file that needs to be updated
HotSwapUtils.hotswapClass(bytes);

4. orm automatic mapping framework based on mongodb

// You don't need to write sql and any configuration yourself, define a table in the database directly through annotation definitions
@EntityCache
public class UserEntity implements IEntity<Long> {
    @Id
    private long id;
    private String name;
}

// update database data
entityCaches.update(userEntity);

5. event use the observer design pattern, decouples different modules and improves the quality of the code

// To receive an event, you only need to add an annotation to the method and the method will be automatically listen for the event
@EventReceiver
public void onMyNoticeEvent(MyNoticeEvent event) {
    // do something
}

// fire an event
EventBus.post(MyNoticeEvent.valueOf("My event"));

6. scheduler scheduling Framework Based on Cron Expression

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

7. storage Excel to class automatic mapping framework, you only need to define a class corresponding to Excel, and directly parse Excel

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

Ⅵ. Commit specification👏

  • People who like this project are welcome to maintain this project together, and pay attention to the following specifications when submitting code
  • The code formats use the default formatting of IntelliJ Idea
  • conventional-changelog-metahub

Ⅶ. License

zfoo use Apache License Version 2.0

JetBrains Logo (Main) logo

zfoo's People

Contributors

1281956265 avatar 132982jianan avatar 37sir avatar 3ho avatar awakeyoyoyo avatar godotg avatar harochen75 avatar huoxi-any avatar islandempty avatar lan2475 avatar lucalq avatar meiwei666 avatar myzjy avatar qiaomengrui avatar qq564139153 avatar sandogeek avatar sinozozo avatar sinprog avatar thebananawolf avatar tiennm99 avatar tingyanshen avatar tursom avatar uuyycc avatar veione avatar xss9981 avatar yuao-github avatar yujuncai avatar zaoaz avatar zoneq avatar zy-hao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zfoo's Issues

群发消息

在客户端+网关+服务的模式下,服务层可以实现消息群发么?

orm落地优化

问题

if (result.getModifiedCount() == batchList.size()) {

getModifiedCount和batchList.size不一致的原因有两个

  1. 数据库中没有查到目标数据
  2. 要更新的数据和DB中的数据一致

getModifiedCount和batchList.size不一致后会再次执行persistAllAndCompare方法,但persistAllAndCompare方法并不能解决上面两个问题,反而增加了DB的压力。

解决方案

  1. 数据库中没有查到目标数据 => 业务上通过loadOrCreate获取缓存,保证数据库中一定有数据
  2. 更新数据和DB中的数据一致 => 这种无需处理,认为更新成功即可
  3. 判断逻辑改成if (result.getMatchedCount() == batchList.size())

    匹配数量不一致的原因只能是要更新的数据和DB中的数据版本不一致,这个时候可以通过persistAllAndCompare方法落地来解决

无法回滚事务

使用OrmContext提供的MongoClient无法回滚事务,自行创建的client可以回滚

[BUG] orm框架,主键必须命名为id,否则会出错

根本原因是 OrmContext.getAccessor().insert() 并没有把@Id注解的字段当作主键

例如主键命名为aaa

public class UserEntity implements IEntity<Long> {
    @Id
    private long aaa;

    @Override
    public Long id() {
        return aaa;
    }
}

插入数据库后会生成{_id:'xxxxxxxxxxxx',aaa=1}这样的数据

然后使用 OrmContext.getAccessor().load(1L, UserEntity.class) 查询的时候,因为_id不是1L,所以查询不到了

只有主键字段名为 id 的时候正常,这个是BUG吗,还是我使用方式错了?

UdpCodecHandler.encode数据时必须写入UdpAttachment吗

有个疑问:encode会写入UdpAttachment,但是接收方decode数据包时又不关心发送方写入的UdpAttachment,所以encode那里是不是去掉UdpAttachment?

NetContext.getPacketService().write(byteBuf, out.getPacket(), out.getAttachment());

public class UdpCodecHandler extends MessageToMessageCodec<DatagramPacket, EncodedPacketInfo> {
    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, DatagramPacket datagramPacket, List<Object> list) {
        ...
        var packetInfo = NetContext.getPacketService().read(sliceByteBuf);
        var sender = datagramPacket.sender();
        packetInfo.setAttachment(UdpAttachment.valueOf(sender.getHostString(), sender.getPort()));
        list.add(packetInfo);
    }

    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, EncodedPacketInfo out, List<Object> list) {
        var byteBuf = channelHandlerContext.alloc().ioBuffer();
        var udpAttachment = (UdpAttachment) out.getAttachment();
        NetContext.getPacketService().write(byteBuf, out.getPacket(), out.getAttachment());
        list.add(new DatagramPacket(byteBuf, new InetSocketAddress(udpAttachment.getHost(), udpAttachment.getPort())));
    }
}

序列化模块使用相关问题

如果序列化的对象包含java.lang.Object类型的话,该怎么使用呀。比如我要传入的是一个Map<String,Object>形式的数据,需要将他序列化。

[Serialization] Bump fury version to 0.2.0

Hi, I'm the author of Fury serialization framework, we just released fury v0.2.0, it supports jdk8~21, JDK17+ record are supported too. Actually, fury support record serialization by jit, which is super fast. Can we Bump fury version to 0.2.0 ?

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.