Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yxonic/quickrabbit
quickrabbit generates strongly-typed functions for implementing RPC, task queue, Pub/Sub, etc., using RabbitMQ
https://github.com/yxonic/quickrabbit
rabbitmq rpc typescript
Last synced: about 1 month ago
JSON representation
quickrabbit generates strongly-typed functions for implementing RPC, task queue, Pub/Sub, etc., using RabbitMQ
- Host: GitHub
- URL: https://github.com/yxonic/quickrabbit
- Owner: yxonic
- License: mit
- Created: 2020-10-05T07:43:53.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-10-11T08:46:24.000Z (over 4 years ago)
- Last Synced: 2024-11-08T15:34:10.672Z (3 months ago)
- Topics: rabbitmq, rpc, typescript
- Language: TypeScript
- Homepage:
- Size: 77.1 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# quickrabbit
`quickrabbit` generates strongly-typed easy-to-use APIs for implementing cross-language actions such as RPC, task queue and Pub/Sub, using RabbitMQ. It is based on the awesome [`quicktype`](https://github.com/quicktype/quicktype) library.
**STILL WORK IN PROGRESS!**
Supported output languages: TypeScript, Python, Java, Go, Rust.
## TODO
- [ ] Message type and error handling.
- [ ] Renderer for all languages.
- [ ] Parser.
- [ ] CLI.
- [ ] Testing.## Usage
1. Create a shared `rabbit` project across all related projects.
2. Add type declarations in `rabbit` using [extended annotations](#extended-annotations).
3. Configure git submodule for each project.
4. Add `quickrabbit` to build process.
5. Use generated function declarations!## Extended Annotations
Grammar:
```ts
/// name[key]: action[, action, ...]
class TypeName
```Supported actions: call, return, commit, reply, publish, subscribe.
```ts
/// check[rpc.check]: call
class CheckArg {
command: string
}/// check[rpc.check]: return
class CheckRet {
available: boolean
}/// run[rpc.run]: commit
class RunArg {
command: string
}/// run[rpc.run]: reply
class RunMsg {
time: Date
message: string
}/// logCreate[logging.create]: publish,subscribe
class CreateMsg {
id: string
name: string
time: Date
}/// logAll[logging.*]: subscribe
class LogMsg {
time: Date
}
```Generated (TypeScript):
```ts
// type declarations by quicktype
...// main class with auto-generated functions
class QuickRabbit {
...check(arg: CheckArg): Promise {
...
}
checkImpl(f: (arg: CheckArg) => CheckRet | Promise) {
...
}run(arg: RunArg, handler: (msg: RunMsg) => void) {
...
}
runImpl(f: (arg: CheckArg, reply: (msg: RunMsg) => void)) {
...
}logCreatePublish(msg: CreateMsg) {
...
}
logCreateSubscribe(msg: CreateMsg) {
...
}logAllSubscribe(handler: (msg: LogMsg) => void) {
...
}
}// create connection
export async function connect() {
...
return new QuickRabbit(...)
}
```