<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: godotg</title>
    <description>The latest articles on Forem by godotg (@godotg).</description>
    <link>https://forem.com/godotg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1027941%2F04fcb21d-55c0-496c-9120-841a8b7898b9.jpeg</url>
      <title>Forem: godotg</title>
      <link>https://forem.com/godotg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/godotg"/>
    <language>en</language>
    <item>
      <title>From Open Source to Exit: The Open-Source Decentralized Networking Library Officially Releases Its First Release</title>
      <dc:creator>godotg</dc:creator>
      <pubDate>Tue, 24 Oct 2023 02:52:42 +0000</pubDate>
      <link>https://forem.com/godotg/from-open-source-to-exit-the-open-source-decentralized-networking-library-officially-releases-its-first-release-5574</link>
      <guid>https://forem.com/godotg/from-open-source-to-exit-the-open-source-decentralized-networking-library-officially-releases-its-first-release-5574</guid>
      <description>&lt;h1&gt;
  
  
  1. Background of zfoo
&lt;/h1&gt;

&lt;h2&gt;
  
  
  For security reasons, many industries do not need to disclose the protocol format of network communication protocols.
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5NabVWvi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aygkehrrqdyqycjwjfdy.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5NabVWvi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aygkehrrqdyqycjwjfdy.jpg" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For example, the securities and finance industry involves financial transactions, and it is preferable to keep these transactions as private as possible, to avoid others from seeing them.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. High Security Requirements: The financial industry deals with a significant amount of sensitive information, such as bank accounts and transaction records. To ensure data security, financial institutions typically use proprietary communication protocols developed in-house or provided by specific vendors to ensure security and prevent malicious attacks.

2. Fixed Partnerships: Financial institutions often have fixed business partners, such as other financial institutions and payment providers, and the communication requirements between these parties are stable. Therefore, using undisclosed protocol formats can improve the efficiency and stability of network communication.

3. Market Competition and Trade Secrets: The financial industry is highly competitive, and each institution wants to protect its business secrets, including trading strategies and algorithms. Public communication protocol formats may expose these trade secrets, so the financial industry tends to use undisclosed protocol formats.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Xo8khDMS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/shdz96o9dts139xqeyzy.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Xo8khDMS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/shdz96o9dts139xqeyzy.jpg" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Similarly, the gaming industry has strict security requirements for network communication protocols.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Copyright Protection: The gaming industry is highly creative and competitive. Game developers often use their own unique network communication protocols to protect their intellectual property and copyrights, preventing other developers from illegally copying or imitating their games. Therefore, undisclosed protocol formats can increase the difficulty of piracy prevention and copyright protection.

2. High Security Requirements: Games involve sensitive data like user information and in-game transactions. To safeguard player account security and prevent cheating, game developers typically use proprietary communication protocols developed in-house or provided by specific vendors to ensure security and prevent malicious attacks.

3. Game Customization: Different games have significant differences in functionality and gameplay. Game developers often need to customize network communication protocols to meet the specific requirements of their games. Therefore, using undisclosed protocol formats can better achieve game customization and personalization.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Performance considerations: Many industries have high network performance requirements.
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PmiWgFJY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7f03s3e531j0nz0l5if9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PmiWgFJY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7f03s3e531j0nz0l5if9.jpg" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The financial industry's network communication protocols require high performance because the speed of transactions and data transmission is crucial in financial markets. In the financial industry, every second of transaction speed and real-time data delivery latency is of paramount importance to traders and investors.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. The performance of network communication protocols directly affects the speed of trade execution and the real-time nature of data. Higher performance means faster transmission speed and lower latency, enabling more timely execution of trades and receipt of market data.

2. Fast trade execution speed is particularly important for high-frequency traders. High-frequency trading involves executing a large number of trades quickly to profit from small price movements. This strategy requires extremely fast trade execution, and the performance of communication protocols directly impacts efficiency and profits.

3. Additionally, the financial industry has high requirements for real-time data transmission. Traders and investors need timely access to market data, including stock prices, futures quotes, economic indicators, and more. Poor protocol performance can lead to delayed data transmission, affecting trading decisions and investment outcomes.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0RJ7Vpy1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1lhkaipxsrzhj30o8p7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0RJ7Vpy1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1lhkaipxsrzhj30o8p7.jpg" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The gaming industry's network communication protocols require high performance because online games demand low latency, fast data transmission, and stable connections.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Games require low-latency network communication protocols to ensure that players' in-game actions are immediately relayed to the server and the real-time updates of other players' states. Lower latency allows players' actions to be perceived by the server and other players more quickly, enhancing gameplay and realism.

2. Games require fast data transmission, especially in large-scale multiplayer online games or games that involve a significant amount of real-time data transmission (such as shooting games). High-speed data transmission ensures a smooth gaming experience, avoiding lag or high latency issues.

3. Online games necessitate stable connections to prevent players from encountering disconnections or network issues during gameplay. A stable connection is fundamental to the gaming experience, as interruptions or connectivity problems can significantly impact the player's experience.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.zhihu.com/question/531266095/answer/2502012979"&gt;How to view the popularity of "Genshin Impact" private servers?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  2. Introduction to zfoo
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IFxeaJx4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3pe0y0tnpr2fscyu7158.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IFxeaJx4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3pe0y0tnpr2fscyu7158.png" alt="Image description" width="800" height="542"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/zfoo-project/zfoo"&gt;A communication network library with decentralized protocols, allowing everyone to have a unique protocol&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;zfoo is an application-layer network protocol that allows for custom protocol rules while balancing compatibility and performance.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pLHp83ez--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gg4poy6bk87sx7o8ir3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pLHp83ez--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gg4poy6bk87sx7o8ir3w.png" alt="Image description" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/godotengine/awesome-godot"&gt;Already submitted to awesome godot&lt;/a&gt;, currently, there is no backend framework with better support for GdScript than zfoo.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  3. Why did zfoo go open source and then seemingly disappear?
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This year, the focus is primarily on researching AI technology and has led to new considerations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Technically, zfoo has already reached a stable state with no significant updates needed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There will mainly be maintenance rather than major updates, and this is not a strict "disappearance." The focus is shifting towards game development using the Godot engine.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open-source projects involve more than one developer, and more responsibilities are being delegated to other developers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>fast framework for binary serialization and deserialization in Java, and has the fewest serialization bytes</title>
      <dc:creator>godotg</dc:creator>
      <pubDate>Thu, 16 Feb 2023 09:12:24 +0000</pubDate>
      <link>https://forem.com/godotg/fast-framework-for-binary-serialization-and-deserialization-in-java-and-has-the-fewestserialization-bytes-54ko</link>
      <guid>https://forem.com/godotg/fast-framework-for-binary-serialization-and-deserialization-in-java-and-has-the-fewestserialization-bytes-54ko</guid>
      <description>&lt;h3&gt;
  
  
  Ⅰ. Introduction
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/zfoo-project/zfoo/blob/main/protocol/README.md" rel="noopener noreferrer"&gt;zfoo protocol&lt;/a&gt;
It is currently the fastest framework for binary serialization and deserialization in Java, and has the fewest
serialization bytes&lt;/li&gt;
&lt;li&gt;The protocol is currently natively supported &lt;strong&gt;C++ Java Javascript C# Go Lua GDScript&lt;/strong&gt;，It's easy to do cross-platform&lt;/li&gt;
&lt;li&gt;The protocol can customize the private protocol format to make your protocol more secure, and supports adding fields
and being compatible with previous and subsequent protocols&lt;/li&gt;
&lt;li&gt;Compatible with Protobuf, it supports the generation of Protobuf protocol files, and provides a generation method from
POJO to PROTO&lt;/li&gt;
&lt;li&gt;There are already quite a few JetBrains plugins that can do it in the way to generate POJOs, and you can search for
Proto in the plugin of Idea&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Ⅱ. Quick use
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Environmental requirements &lt;strong&gt;JDK 11+&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Protocol is an independent project, does not depend on other projects, can be directly opened, locally installed to&lt;br&gt;
its own local maven repository, can be used alone&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// The zfoo protocol is registered and 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(buffer);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Ⅲ. Performance testing
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Single-threaded environment, 50% faster than Protobuf and 100% faster than Kryo without any JVM parameter
tuning,&lt;a href="//src/test/java/com/zfoo/protocol/SpeedTest.java"&gt;参见性能测试&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Thread safety, the performance of zfoo and Protobuf is not affected in any way, kryo will lose some performance&lt;br&gt;
because of thread insecurity,&lt;a href="//src/test/java/com/zfoo/protocol/SpeedTest.java"&gt;参见性能测试&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test the environment&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;system：win10
cpu： i9900k
内存：64g
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Single-threaded test with abscissa as the number of objects serialized and deserialized and time spent in milliseconds
on the ordinate&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnsumvvk3qsnxlvp49yd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnsumvvk3qsnxlvp49yd.png" alt=" " width="800" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0pxj770stklf7bae88ey.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0pxj770stklf7bae88ey.png" alt=" " width="800" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd95hovp99ajebcqx8i3o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd95hovp99ajebcqx8i3o.png" alt=" " width="800" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Ⅳ. Why fast
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use Javassist bytecode to enhance the dynamic generation of serialization and deserialization functions for sequential
execution, and sequential functions can be easily JIT compiled to achieve extreme performance&lt;/li&gt;
&lt;li&gt;Natively integrated with netty's high-performance Byte Buf&lt;/li&gt;
&lt;li&gt;With primitive type collection, there is no boxing and unboxing, invalid GCs are avoided, and the performance is fast
enough&lt;/li&gt;
&lt;li&gt;Inherently thread-safe and lock-free; kryo forces each thread to have its own instance of Kryo, which is a heavy
design, especially in scenarios with many threads&lt;/li&gt;
&lt;li&gt;No reflections, no unsafe operation; The use of objenesis in Kryo resulted in a lot of unsafe, and warnings when
running in Java 11&lt;/li&gt;
&lt;li&gt;Flattening the call depth of the method stack, and there is no performance penalty for nesting data structures, such
as List&amp;gt;&amp;gt;; Comparing kryo and protobuf data structure nesting results in a performance penalty&lt;/li&gt;
&lt;li&gt;There is no risk of vulnerability injection, only bytecode enhancement will be performed during initialization, and no
bytecode operations will be performed in the later stage
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The data compression volume is small, and the compression volume is smaller than that of Kryo and Protobuf; Smaller than kryo because kryo needs to write the registration number of each object
Intelligent syntax, incorrect protocol definitions will fail to start the program and give an error warning
Improve development efficiency, fully support POJO development, very easy to use
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Ⅴ. Why small
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Lightweight implementation, core serialization and deserialization code of about a thousand lines&lt;/li&gt;
&lt;li&gt;Optimized the zigzag and varint encoding algorithms for int and long, avoiding some redundant method calls and bit
operations&lt;/li&gt;
&lt;li&gt;The data compression volume is small, and the compression volume is smaller than that of Kryo and Protobuf; Smaller
than kryo because kryo needs to write the registration number of each object&lt;/li&gt;
&lt;li&gt;Intelligent syntax, incorrect protocol definitions will fail to start the program and give an error warning&lt;/li&gt;
&lt;li&gt;Improve development efficiency, fully support POJO development, very easy to use
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The current size of the serialized object is as follows:
Simple objects, zfoo package size 8, kryo package size 5, protobuf package size 8
Regular objects, ZFOO package size 430, KRYO package size 483, Protobuf package size 793
For complex objects, ZFOO package size 2216, KRYO package size 2528, and Protobuf package size 5091
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Ⅵ. Data type
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Default data format support eliminates the need for users to register&lt;br&gt;
manually.&lt;a href="//src/test/java/com/zfoo/protocol/packet/ComplexObject.java"&gt;参考类定义&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;boolean，byte，short，int，long，float，double，char，String&lt;/li&gt;
&lt;li&gt;Boolean，Byte，Short，Integer，Long，Float，Double，Character，If it is null during serialization, a default value of 0
will be given (the default value of Character is Character.MIN VALUE)&lt;/li&gt;
&lt;li&gt;int[]，Integer[]，If it is null, it is parsed as an array of length 0

&lt;ul&gt;
&lt;li&gt;Native generic List, Set, Map, deserialization return type Hash Set, Array List, Hash Map, and null pointer
safe (returns a collection of size 0)&lt;/li&gt;
&lt;li&gt;List，You must specify a generic class if [1,1,null,1] is sent and [1,1,0,1] is received&lt;/li&gt;
&lt;li&gt;List，If [obj,obj,null,obj] is sent, [obj,obj,null,obj] is received, that is, the reference type is
null before serialization, and it is also null after serialization&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Unsupported data formats, because ZFOO automatically recognizes unsupported types and gives error warnings, so users&lt;br&gt;
don't have to care too much&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;int[][]，Arrays above two dimensions, considering that not all languages support multidimensional arrays&lt;/li&gt;
&lt;li&gt;List[]，Map[]，The Java language itself does not support generic class arrays&lt;/li&gt;
&lt;li&gt;List，Map，Generics are set in arrays, which looks strange and has few actual uses&lt;/li&gt;
&lt;li&gt;Enumerated classes, considering that many other languages do not support enumerated classes, can be replaced at
the code level with int or string&lt;/li&gt;
&lt;li&gt;Custom generic class XXX Class, generic classes are prone to performance and parsing problems in many
frameworks, and are not supported in all languages&lt;/li&gt;
&lt;li&gt;Circular references, although the underlying support circular references, but considering that circular references
bring semantically difficult to understand and prone to errors, so they are blocked&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Ⅶ. Protocol specifications
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The protocol class must be a simple javabean, not inheriting from any other class, but can inherit an interface&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In order to prevent objects in the code and avoid some potential concurrency problems caused by the mixing of objects&lt;br&gt;
in the protocol layer and the po layer, zfoo mandates that protocol classes must implement the IPacket interface&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Now the interface of IPacket is just an identification interface, inheriting the design of IPacket is mainly to make 
the code more elegant and easier to understand, and it is not a lot of work to inherit only Object

The design of inheriting IPacket also has cross-language considerations, which greatly simplifies the difficulty 
of serialization and deserialization in other languages and unifies the code implementation of other languages
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The protocol number is defined as a short type to reduce the packet size and memory size, a packet can be reduced by 2
bytes, and the application memory of each protocol can also be reduced by 6 byte(protocols + IProtocolRegistration +
protocolIdMap)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;It is difficult for a project's protocol body class to exceed 3 w, and there will be tools that automatically package 
your protocol number a little more compactly, so that your protocol number will not exceed 3 w
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;There are two ways to indicate that the protocol class must be labeled with the protocol number&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first uses annotations: &lt;a class="mentioned-user" href="https://dev.to/protocol"&gt;@protocol&lt;/a&gt;(id = protocolId)
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  @Protocol(id = 104)
  public class SimpleObject implements IPacket {

      public int c;
      public boolean g;

  }
&lt;/code&gt;&lt;/pre&gt;



&lt;ul&gt;
&lt;li&gt;The second uses static constants + interfaces: the value of this protocol number must be the same as the value
returned by the IPacket interface, which can slightly improve performance
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  public class SimpleObject implements IPacket {

      public static final short PROTOCOL_ID = 104;

      public int c;

      public boolean g;

      @Override
      public short protocolId() {
          return PROTOCOL_ID;
      }

  }
&lt;/code&gt;&lt;/pre&gt;



&lt;ul&gt;
&lt;li&gt;The third use: Register the agreement through Protocol Manager.initProtocolAuto() without writing the protocol
number
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  public class SimpleObject implements IPacket {

      public int c;

      public boolean g;

  }
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;&lt;p&gt;If you add a field for version compatibility, you need to add a Compatible annotation, and the order needs to be&lt;br&gt;&lt;br&gt;
naturally increased, so as to ensure that the old and new protocols can be compatible with each other&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;In order to be compatible with versions and avoid modifying field names, default uses field names to read and write&lt;br&gt;&lt;br&gt;
in the natural order of strings (can also be customized), so it will cause exceptions in serialization&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;The official environment does not necessarily have to delete an unwanted field in order to be version compatible and&lt;br&gt;&lt;br&gt;
avoid reducing fields&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Among the six principles of design patterns, the principle of opening and closing is open to expansion and closed to&lt;br&gt;&lt;br&gt;
modification. The design of the protocol should also adhere to this principle when it comes to functionality,&lt;br&gt;&lt;br&gt;
prioritizing the addition of new protocols over modifying existing ones&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Ⅷ. Use Protobuf in zfoo
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;zfoo only provides protobuf in the way of pojo like jprotobuf, but it can generate proto files for clients to use&lt;br&gt;
through pojo objects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/jhunters/jprotobuf" rel="noopener noreferrer"&gt;jprotobuf&lt;/a&gt; you can directly use simple pojo objects without having to&lt;br&gt;
understand proto file operations and syntax&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generate a proto file for the client to use through the pojo&lt;br&gt;
object, &lt;a href="//src/test/resources/protobuf.xml"&gt;Generate a proto configuration&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can also customize your own build method,&lt;br&gt;
&lt;a href="https://github.com/zfoo-project/tank-game-server/tree/main/common/src/main/java/com/zfoo/tank/common/generate" rel="noopener noreferrer"&gt;Use code custom generation to proto&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>career</category>
      <category>learning</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Extremely fast enterprise server framework, can be used in RPC, web server framework, game server framework.</title>
      <dc:creator>godotg</dc:creator>
      <pubDate>Thu, 16 Feb 2023 09:02:07 +0000</pubDate>
      <link>https://forem.com/godotg/extremely-fast-enterprise-server-framework-can-be-used-in-rpc-web-server-framework-game-server-framework-4a8m</link>
      <guid>https://forem.com/godotg/extremely-fast-enterprise-server-framework-can-be-used-in-rpc-web-server-framework-game-server-framework-4a8m</guid>
      <description>&lt;p&gt;Why is zfoo protocol ?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The protocol currently supports C++ C# Go Java Javascript TypeScript GDScript Lua&lt;/li&gt;
&lt;li&gt;Universal distributed server protocol implementation, there are implementations in other languages, which can easily
implement RPC, servers, and microservices on other platforms&lt;/li&gt;
&lt;li&gt;The fastest custom format framework for Java binary serialization, with the fewest serialized bytes, more secure and
compatible&lt;/li&gt;
&lt;li&gt;In the single-threaded benchmark test, serialization and deserialization are 50% faster than Protobuf and 100% faster
than Kryo&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ⅰ. Introduction of zfoo🚩&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Extremely fast, asynchronous, Actor design pattern, lock-free design, RPC framework based on Spring MVC&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fastest serialization and deserialization&lt;/strong&gt;，use &lt;a href="//protocol/README.md"&gt;zfoo protocol&lt;/a&gt; as a network protocol&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;High scalability&lt;/strong&gt;，Single server deployment, microservice deployment, cluster deployment, gateway deployment&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Can be used as a game server framework or website server framework.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Perfect work development process, complete online solution&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Spring projects, distributed projects, container projects， &lt;strong&gt;hot update code without
downtime&lt;/strong&gt; &lt;a href="//hotswap/src/test/java/com/zfoo/hotswap/ApplicationTest.java"&gt;hotswap&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Excel json csv configuration is automatically mapped and parsed，&lt;strong&gt;Online hotswap
configuration&lt;/strong&gt; &lt;a href="//storage/src/test/java/com/zfoo/storage/ApplicationTest.java"&gt;storage&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Automapping framework for MongoDB &lt;a href="//orm/README.md"&gt;orm&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Event bus &lt;a href="//event/src/test/java/com/zfoo/event/ApplicationTest.java"&gt;event&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Time task scheduling &lt;a href="//scheduler/README.md"&gt;scheduler&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;cpu, memory, hard disk, network monitoring built into the program&lt;/strong&gt; no code and extra tools
required &lt;a href="//monitor/src/test/java/com/zfoo/monitor/ApplicationTest.java"&gt;monitor&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Ⅱ. Who use this project
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Projects with extremely high performance requirements, such as website and game server frameworks, single server,
global server, live chat, IM system, real-time push&lt;/li&gt;
&lt;li&gt;Projects such as saving, development, deployment, operation and maintenance costs&lt;/li&gt;
&lt;li&gt;As a backend infrastructure for &lt;strong&gt;Godot，Unity，Cocos，Webgl，H5&lt;/strong&gt;，Network protocol supports tcp udp websocket http&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://baike.baidu.com/item/KISS%E5%8E%9F%E5%88%99/3242383" rel="noopener noreferrer"&gt;Keep it Simple and Stupid&lt;/a&gt; ，simple configuration, lightweight code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Ⅲ. Tutorials
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="//./doc/FAQ.md"&gt;FAQ&lt;/a&gt;，There are standard demo display and instructions in the test folder of each project directory,&lt;br&gt;
which can be run directly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://github.com/zfoo-project/tank-game-server" rel="noopener noreferrer"&gt;tank-game-server&lt;/a&gt; Online game《The Fight of Tanks》，novice friendly,&lt;br&gt;
difficulty 2 stars&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Quick star, tank game entry &lt;a href="http://tank.zfoo.net" rel="noopener noreferrer"&gt;tank.zfoo.net&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Quick star, tank background management &lt;a href="http://tank-admin.zfoo.net" rel="noopener noreferrer"&gt;tank-admin.zfoo.net&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/zfoo-project/godot-bird" rel="noopener noreferrer"&gt;godot-bird&lt;/a&gt; bird and bird，powered by godot&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/zfoo-project/fivechess" rel="noopener noreferrer"&gt;cocos-fivechess&lt;/a&gt; five chess，use cocos as client&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Ⅳ. Install and use⭐
&lt;/h2&gt;

&lt;h4&gt;
  
  
  1. Environmental Requirements and Installation
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;JDK 11+&lt;/strong&gt;，&lt;strong&gt;OpenJDK&lt;/strong&gt; or &lt;strong&gt;Oracle JDK&lt;/strong&gt; ，maven install to local repository&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;If you do not have JDK 11+ installed, the quick installation method is to download directly 
from Project Structure, Platform Settings, SDKs in the upper right corner of Idea
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. &lt;a href="//protocol/README.md"&gt;protocol&lt;/a&gt; fastest serialization and deserialization
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 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);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. &lt;a href="//net/README.md"&gt;net&lt;/a&gt; fastest RPC framework, supports tcp udp websocket http
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 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 -&amp;gt; {
                        // do something
                    );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  4. &lt;a href="//hotswap/src/test/java/com/zfoo/hotswap/ApplicationTest.java"&gt;hotswap&lt;/a&gt; hot update code, no need to stop the server, no additional configuration, just one line of code to start hot update
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Pass in the class file that needs to be updated
HotSwapUtils.hotswapClass(bytes);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  5. &lt;a href="//orm/README.md"&gt;orm&lt;/a&gt; automatic mapping framework based on mongodb，The secondary cache is designed using &lt;a href="https://github.com/ben-manes/caffeine" rel="noopener noreferrer"&gt;caffeine&lt;/a&gt; to fully release the database pressure
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 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&amp;lt;Long&amp;gt; {
    @Id
    private long id;
    private String name;
}

// update database data
entityCaches.update(userEntity);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  6. &lt;a href="//event/src/test/java/com/zfoo/event/ApplicationTest.java"&gt;event&lt;/a&gt; use the observer design pattern, decouples different modules and improves the quality of the code
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 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.submit(MyNoticeEvent.valueOf("My event"));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  7. &lt;a href="//scheduler/README.md"&gt;scheduler&lt;/a&gt; scheduling Framework Based on Cron Expression
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Scheduler(cron = "0/1 * * * * ?")
public void cronSchedulerPerSecond() {
    // do something
}
```

`

#### 8. [storage](storage/src/test/java/com/zfoo/storage/ApplicationTest.java) Excel to class automatic mapping framework, you only need to define a class corresponding to Excel, and directly parse Excel

```
@Resource
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 uses the default formatting of IntelliJ Idea
- [conventional-changelog-metahub](https://github.com/pvdlg/conventional-changelog-metahub#commit-types)

Ⅵ. License
-----------

zfoo use [Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)

![JetBrains Logo (Main) logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>softwaredevelopment</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
