Skip to content

Commit 391f601

Browse files
kislayrajCopilot
andcommitted
docs: rewrite README as polished marketing page
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent cf9c8ef commit 391f601

1 file changed

Lines changed: 101 additions & 37 deletions

File tree

README.md

Lines changed: 101 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,136 @@
11
# KislayPHP Queue
22

3-
Queue runtime for KislayPHP.
3+
[![PHP Version](https://img.shields.io/badge/PHP-8.2%2B-blue.svg)](https://php.net)
4+
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](LICENSE)
5+
[![Build Status](https://img.shields.io/github/actions/workflow/status/KislayPHP/queue/ci.yml?branch=main&label=CI)](https://github.com/KislayPHP/queue/actions)
6+
[![PIE](https://img.shields.io/badge/install-pie-blueviolet)](https://github.com/php/pie)
47

5-
Primary runtime namespace is `Kislay\Queue` with backward-compatible aliases under `KislayPHP\Queue`.
8+
> **Deterministic message queue for PHP microservices.** In-process queue with adapter interface for Redis, SQS, or any backend. Sync-first API for reliable task processing.
69
7-
## Concurrency Mode
10+
Part of the [KislayPHP ecosystem](https://skelves.com/kislayphp/docs).
811

9-
- Default API mode is synchronous.
10-
- Calls return concrete values (`bool`, payload, `int`) and do not expose Promise/Fiber APIs.
11-
- Optional RPC transport is supported internally when built with stubs, but method semantics remain synchronous.
12+
---
1213

13-
This module is intentionally sync-first to keep queue processing deterministic in long-lived PHP workers.
14+
## ✨ What It Does
1415

15-
## Installation
16+
`kislayphp/queue` provides a typed message queue primitive with a clean adapter interface. Use the built-in in-memory queue for development, or swap in Redis, SQS, or RabbitMQ for production without changing application code.
17+
18+
```php
19+
<?php
20+
$queue = new Kislay\Queue\Queue();
21+
$queue->enqueue('jobs', ['task' => 'send_email', 'to' => 'user@example.com']);
22+
23+
$job = $queue->dequeue('jobs');
24+
// process $job...
25+
```
26+
27+
---
28+
29+
## 📦 Installation
1630

1731
```bash
18-
pie install kislayphp/queue:0.0.2
32+
pie install kislayphp/queue
1933
```
2034

2135
Enable in `php.ini`:
22-
2336
```ini
2437
extension=kislayphp_queue.so
2538
```
2639

27-
## Public API
40+
---
41+
42+
## 🚀 Quick Start
2843

29-
`Kislay\Queue\Queue`:
44+
### In-Process Queue
3045

31-
- `__construct()`
32-
- `setClient(Kislay\Queue\ClientInterface $client): bool`
33-
- `enqueue(string $queue, mixed $payload): bool`
34-
- `dequeue(string $queue): mixed`
35-
- `peek(string $queue): mixed`
36-
- `size(string $queue): int`
37-
- `clear(string $queue): int`
46+
```php
47+
<?php
48+
$queue = new Kislay\Queue\Queue();
3849

39-
`Kislay\Queue\ClientInterface`:
50+
// Producer: add jobs
51+
$queue->enqueue('email-jobs', ['to' => 'alice@example.com', 'template' => 'welcome']);
52+
$queue->enqueue('email-jobs', ['to' => 'bob@example.com', 'template' => 'invoice']);
4053

41-
- `enqueue(string $queue, mixed $payload): bool`
42-
- `dequeue(string $queue): mixed`
43-
- `size(string $queue): int`
54+
// Consumer: process jobs
55+
while ($job = $queue->dequeue('email-jobs')) {
56+
send_email($job['to'], $job['template']);
57+
}
4458

45-
Legacy aliases:
59+
echo $queue->size('email-jobs'); // 0
60+
```
4661

47-
- `KislayPHP\Queue\Queue`
48-
- `KislayPHP\Queue\ClientInterface`
62+
### Custom Backend Adapter
4963

50-
## Quick Start
64+
Swap to Redis, SQS, etc. without changing your application:
5165

5266
```php
5367
<?php
68+
class RedisQueueClient implements Kislay\Queue\ClientInterface {
69+
public function __construct(private Redis $redis) {}
70+
71+
public function enqueue(string $queue, mixed $payload): bool {
72+
return (bool) $this->redis->rpush($queue, serialize($payload));
73+
}
74+
75+
public function dequeue(string $queue): mixed {
76+
$raw = $this->redis->lpop($queue);
77+
return $raw ? unserialize($raw) : null;
78+
}
79+
80+
public function size(string $queue): int {
81+
return $this->redis->llen($queue);
82+
}
83+
}
5484

5585
$queue = new Kislay\Queue\Queue();
86+
$queue->setClient(new RedisQueueClient(new Redis()));
5687

57-
$queue->enqueue('jobs', ['id' => 1, 'task' => 'send_email']);
58-
$queue->enqueue('jobs', ['id' => 2, 'task' => 'reindex']);
88+
// Same API, backed by Redis
89+
$queue->enqueue('tasks', ['id' => 123]);
90+
```
91+
92+
---
5993

60-
$next = $queue->dequeue('jobs');
61-
var_dump($next);
94+
## 📖 Public API
6295

63-
$remaining = $queue->size('jobs');
64-
var_dump($remaining);
96+
```php
97+
namespace Kislay\Queue;
98+
99+
class Queue {
100+
public function __construct();
101+
public function setClient(ClientInterface $client): bool;
102+
public function enqueue(string $queue, mixed $payload): bool;
103+
public function dequeue(string $queue): mixed;
104+
public function peek(string $queue): mixed;
105+
public function size(string $queue): int;
106+
public function clear(string $queue): int; // returns count cleared
107+
}
108+
109+
interface ClientInterface {
110+
public function enqueue(string $queue, mixed $payload): bool;
111+
public function dequeue(string $queue): mixed;
112+
public function size(string $queue): int;
113+
}
65114
```
66115

67-
## Notes
116+
Legacy aliases: `KislayPHP\Queue\Queue`, `KislayPHP\Queue\ClientInterface`
117+
118+
---
119+
120+
## 💡 When to Use Each Extension
121+
122+
| Need | Use |
123+
|---|---|
124+
| In-process task queue | **queue** (this) |
125+
| Realtime push / fanout to connected clients | [eventbus](https://github.com/KislayPHP/eventbus) |
126+
| Background async computation | [core](https://github.com/KislayPHP/core) `async()` |
127+
128+
---
129+
130+
## 🔗 Ecosystem
131+
132+
[core](https://github.com/KislayPHP/core) · [gateway](https://github.com/KislayPHP/gateway) · [discovery](https://github.com/KislayPHP/discovery) · [metrics](https://github.com/KislayPHP/metrics) · **queue** · [eventbus](https://github.com/KislayPHP/eventbus)
68133

69-
- Use this extension for in-process queue semantics and adapter integration points.
70-
- If you need event-driven fanout or socket transport, use `kislayphp/eventbus`.
71-
- For full ecosystem communication guidelines, see `SERVICE_COMMUNICATION.md`.
134+
## 📄 License
72135

136+
[Apache License 2.0](LICENSE) · **[Full Docs](https://skelves.com/kislayphp/docs)**

0 commit comments

Comments
 (0)