Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meulengracht/libgracht
Gracht (english: canal) is a lightweight, cross-platform, low-dependency, and modular protocol/rpc library.
https://github.com/meulengracht/libgracht
cross-platform library lightweight protocol rpc
Last synced: 2 months ago
JSON representation
Gracht (english: canal) is a lightweight, cross-platform, low-dependency, and modular protocol/rpc library.
- Host: GitHub
- URL: https://github.com/meulengracht/libgracht
- Owner: Meulengracht
- License: gpl-3.0
- Created: 2021-01-05T07:07:09.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-06-10T08:51:08.000Z (8 months ago)
- Last Synced: 2024-06-10T10:43:05.314Z (8 months ago)
- Topics: cross-platform, library, lightweight, protocol, rpc
- Language: C
- Homepage:
- Size: 454 KB
- Stars: 8
- Watchers: 1
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# libgracht
A lightweight, cross-platform, low-dependency, and modular protocol/rpc library. Gracht is built upon an abstracted concept of links, which can be anything and hence allows gracht to work on any platform. The links that are provided by default are unix/windows-sockets and a native interface for the Vali OS IPC (which the library is originally built for). Gracht protocols are defined in the in its own format, where we support different kinds of primitives:
- Types
- Enums
- Structures (nested, variable)
- Synchronous function calls
- Asynchronous function calls
- Asynchronous events with parametersThe library itself supports different kind of ways to send/receive messages. This can be done individually or in bulk. Multiple messages can be invoked and awaited with a single call.
Links are defined in include/gracht/links and are seperate objects that must be created before the client or server gets created/initialized. If you want to implement your own link interface you can take a look at the required functions under /include/gracht/link/link.h.
The library itself relies on very little functionality from the OS itself to work.
Required operating system functionality:
- Epoll/completion port-like interface. (aio.h)
- Threading model with conditions and mutexes. (thread_api.h)Supported links:
- Socket (link/socket/*)
- Vali-IPC (link/vali-ipc/*)Supported languages for code generation are:
- CSupported platforms:
- Windows
- Linux
- Vali/MollenOS## Protocol Format
```
/**
* Test example of gracht protocol message version 2
* Includes example of a test protocol and some test structures
*/import "shared_types" // imports file shared_types.gr
namespace testdefine uint32_t from "stdint.h"
enum error_codes {
ok = 0,
invalid_parameters = -1,
invalid_result = -2
}struct transfer_device {
string device;
}struct transfer_bit {
int start;
int length;
}struct transfer_request {
transfer_device device;
transfer_bit[] bits;
}struct transfer_complete_event {
uint32_t id;
}service disk (1) {
func transfer(transfer_request request) : (int status) = 1;
func transfer_many(transfer_request[] request) : (int[] statuses) = 2;
event transfer_complete : transfer_complete_event = 3;
}
```## Protocol generator
The protocol generator is located in /generator/ folder and can be used to generate headers and implementation files. Three header files can be generated
and two implementation files can be generated per protocol.The header files generated are:
namespace_svcname_service.h
namespace_svcname_service_server.h
namespace_svcname_service_client.hThe source file generated is:
namespace_svcname_service_server.c
namespace_svcname_service_client.cIn the header files are instructions for how to declare the protocols in your files and documentation for how to setup the protocol callbacks (if any).
```
usage: parser.pyarguments:
-h, --help show this help message and exit
--service servicefile The service file that should be parsed
--include INCLUDE The services that should be generated from the file, comma-seperated list, default is all
--out OUT Protocol files output directory
--client Generate client side files
--server Generate server side files
--lang-c Generate c-language headers and implementation files
```## Examples
Examples for libgracht are located under tests/ directory and show minimal implementations for using the client and server in combination with the socket link.