承接 becklyn/eventor-symfony 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

becklyn/eventor-symfony

最新稳定版本:3.0.0

Composer 安装命令:

composer require becklyn/eventor-symfony

包简介

A minimalistic library for abstracting pub/sub operations (ported for Symfony)

README 文档

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:

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);
    }
}

统计信息

  • 总下载量: 1.25k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2022-08-23