Development Guide

    Coding Guide

    Neuron code follows the principle of high readability and has the following specification requirements:

    • Macros are all uppercase, except for macros, which are all lowercase.
    • Variables, functions, structures, and other names are meaningful English words separated by underscores.
    • Each C file should be the smallest set of strongly related functions.
    • Only functions and variables that need to be exported externally are added to the header file.
    • Neuron uses clang format for code formatting, and the clang format file is located in the Neuron root directory.
    • Functions should be as short as possible. Each function only implements one function. The logic of the function is clear (it can be easily understood by looking at previously written code after a period of time), and the maximum length of the function should not exceed 80 lines.

    This project has a main branch, main. Please ensure that main is compiled and usable at any time. At the same time, there are branches corresponding to different versions of this project, and you can choose your own branches for development.

    Modify Code

    Run all unit tests

    1. $ ctest --output-on-failure

    Functional testing

    Run all functional tests

    • A PR only does one thing. If there are multiple bug fixes, please submit a PR for each bug;
      • First, fork this project and create your own github.com/your/neuron warehouse;
      • Clone your own Neuron warehouse to the local location:
        1. For example, create a new branch based on the main branch;
        2. Make changes on the newly created branch and submit the changes;
        3. Before pushing the modified branch to your own warehouse, switch to the branch and run the following command to pull the latest remote code:
        4. If the new remote code is retrieved in the previous step, switch to the previously created branch and run branch merge operation.
          1. $ git rebase main
          If you encounter a file conflict, you need to resolve the conflict;
        5. After the previous step is completed, you can push the branch you created to your own warehouse:
        6. Finally, send a PR to the corresponding branch of emqx/neuron from the newly pushed branch of your warehouse;
      • Provide a complete description of the problems solved/new features added/the intent of the modifications made to the code in the title and text of the PR;

      • Wait patiently for the developer’s response, and we will respond soon.

      Debugging

      1. Use logs to print relevant debugging information.
      2. Combining libasan runtime memory analysis, most memory issues can be resolved.