gitmyhub

mars

C++ ★ 18k updated 9mo ago

Mars is a cross-platform network component developed by WeChat.

Mars is WeChat's open-source networking and logging library for mobile apps, providing reliable low-battery push messaging and async compressed logging on iOS, Android, macOS, and Windows.

C++PythonAndroidiOSGradlezlibsetup: hardcomplexity 4/5

Mars is a cross-platform networking and logging component built by the WeChat mobile team at Tencent. WeChat handles billions of users, and Mars is the low-level plumbing it relies on to send small messages between phones and servers reliably while using as little battery and mobile data as possible. The project open-sources that plumbing so other apps can adopt the same approach instead of writing their own stack.

Mars has four pieces. comm is a shared library of utilities such as sockets, threads, message queues, and coroutines. Xlog is a high-performance, reliable log component that writes log files asynchronously, compresses them with zlib, and automatically cleans up its log directory. SDT is a network-detection component that helps diagnose why a connection failed. STN, the largest part, is the signalling network component: it manages long-lived connections to a server (a long-link) for push-style messaging and short-link requests for one-shot calls, handles reconnection, and adapts to a mobile app's lifecycle, including background/foreground transitions and network changes.

You would use Mars when building a mobile app that needs a small but reliable conversation with a backend (chat messages, signals, presence) and you care about battery and data usage on flaky mobile networks. It is suitable for small-volume data transmission, not large file transfer. The codebase is written in C++ and builds on iOS, OS X, Android, and Windows. Android integration is offered as a Gradle dependency (mars-wrapper for a quick start, mars-core or standalone mars-xlog for production), while iOS, OS X, and Windows builds use Python build scripts requiring Python 3.10 or higher.

Where it fits