becklyn / eventor-symfony
A minimalistic library for abstracting pub/sub operations (ported for Symfony)
Installs: 1 244
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.1
- cloudevents/sdk-php: ^1.0
- guzzlehttp/psr7: ^2.4
- illuminate/collections: ^8.12 | ^9.25
- open-telemetry/opentelemetry: ^0.0.15
- psr/http-client: ^1.0
- symfony/config: 6.1.*
- symfony/dependency-injection: 6.1.*
- symfony/framework-bundle: ^6.1
- symfony/http-client: 6.1.*
- symfony/http-foundation: 6.1.*
- symfony/http-kernel: 6.1.*
- symfony/serializer: 6.1.*
Requires (Dev)
README
🔮 A minimalistic library for abstracting pub/sub operations (ported for Symfony)
→ eventor is clerk for pub/sub 😉
→ the original Go implementation can be found here
Installation
composer require becklyn/eventor-symfony
Supported brokers
eventor has builtin support for the following brokers:
- Dapr Pub/sub API - APIs for building portable and reliable microservices
Usage
Being a minimalistic library, eventor only provides you with the basics. The rest is up to your specific need.
Env variables
DAPR_HOST=http://localhost:3500 # Default: (null) DAPR_PUBSUB=pubsubname # Default: (null)
Publish
class Message { public function __construct( private readonly string $id, private readonly string $body, ) {} public function id(): string { return $this->id; } public function body(): string { return $this->body; } }
class PublishExample { public function __construct( private readonly Publisher $publisher, ) { $this->publisher->publish("topic", new Message( id: "0", body: "Hello World", )); } }
Subscribe
class DaprSubscriptionController extends AbstractController { public function __construct( private readonly DaprSubscriptionRegistry $subscriptionRegistry, ) { new On( fn (Message $msg) => echo($msg), $this->$subscriber, "topic", ); } #[Route('/dapr/subscribe', methods: [Request::METHOD_GET])] public function handleSubscribe() : Response { return $this->subscriptionRegistry->handleSubscribe(); } #[Route('/dapr/pubsubname/topic', methods: [Request::METHOD_POST])] public function handleTopic(Request $request): Response { return $this->subscriptionRegistry->handleTopic($request); } }