{"id":30527413,"url":"https://github.com/dcarea/cloudeventdotnet","last_synced_at":"2025-08-27T02:23:39.721Z","repository":{"id":49400236,"uuid":"517540547","full_name":"DCArea/CloudEventDotNet","owner":"DCArea","description":"Publish/Subscribe CloudEvents in .NET, inspired by Dapr Pub/Sub","archived":false,"fork":false,"pushed_at":"2024-07-17T02:14:40.000Z","size":300,"stargazers_count":5,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-21T14:50:31.595Z","etag":null,"topics":["cloudevents","event-driven","eventbus","kafka","microservice","microservices-architecture","pubsub","redis"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DCArea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-25T06:13:38.000Z","updated_at":"2024-07-17T07:21:45.000Z","dependencies_parsed_at":"2024-07-15T13:41:27.824Z","dependency_job_id":null,"html_url":"https://github.com/DCArea/CloudEventDotNet","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/DCArea/CloudEventDotNet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCArea%2FCloudEventDotNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCArea%2FCloudEventDotNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCArea%2FCloudEventDotNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCArea%2FCloudEventDotNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DCArea","download_url":"https://codeload.github.com/DCArea/CloudEventDotNet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCArea%2FCloudEventDotNet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272280763,"owners_count":24906216,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-27T02:00:09.397Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudevents","event-driven","eventbus","kafka","microservice","microservices-architecture","pubsub","redis"],"created_at":"2025-08-27T02:23:38.773Z","updated_at":"2025-08-27T02:23:39.710Z","avatar_url":"https://github.com/DCArea.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CloudEventDotNet\r\n\r\nPublish/Subscribe CloudEvents in .NET, inspired by Dapr Pub/Sub Component\r\n\r\n## Features\r\n\r\n* Publish/Subscribe events with CloudEvent format\r\n* With both Kafka and Redis support\r\n* At-Least-Once delivery guarantee\r\n* Redeliver failed events\r\n* Obeservability support (traces/metrics)\r\n* ***DOES NOT*** support delivery events in order\r\n\r\n## Usage\r\n\r\n### Install package\r\n```shell\r\ndotnet add package CloudEventDotNet\r\ndotnet add package CloudEventDotNet.Redis # With Redis Stream\r\ndotnet add package CloudEventDotNet.Kafka # With Apache Kafka\r\n```\r\n\r\n### Configure pubsub:\r\n```csharp\r\nservices.AddCloudEvents(defaultPubSubName: \"kafka\", defaultTopic: \"my-topic\")\r\n    .Load(typeof(OrderCancelled).Assembly)\r\n    .AddKafkaPubSub(\"kafka\", options =\u003e\r\n    {\r\n        options.ProducerConfig = new ProducerConfig\r\n        {\r\n            BootstrapServers = broker,\r\n        };\r\n    }, options =\u003e\r\n    {\r\n        options.ConsumerConfig = new ConsumerConfig\r\n        {\r\n            BootstrapServers = broker,\r\n            GroupId = consumerGroup,\r\n        };\r\n    })\r\n    .AddRedisPubSub(\"redis\", options =\u003e\r\n    {\r\n        options.ConnectionMultiplexerFactory = () =\u003e redis;\r\n        options.MaxLength = maxLength;\r\n    }, options =\u003e\r\n    {\r\n        options.ConnectionMultiplexerFactory = () =\u003e redis;\r\n        options.ConsumerGroup = consumerGroup;\r\n    })\r\n    .AddPubSubDeadLetterSender(opts =\u003e // enable dead letter\r\n    {\r\n        opts.Topic = \"DL\";\r\n    });\r\n```\r\n\r\n#### Define cloud event:\r\n```csharp\r\n[CloudEvent] // register event with default pubsub name and topic\r\npublic record OrderCancelled(Guid OrderId, string Reason);\r\n```\r\n\r\n#### Define cloud event with custom metadata\r\n```csharp\r\n[CloudEvent(PubSubName = \"redis\", Topic = \"another-topic\", Type = \"a-custom-type\")]\r\npublic record OrderCancelled(Guid OrderId, string Reason);\r\n```\r\n\r\n### Publish a cloud event:\r\n```csharp\r\nvar pubsub = serviceProvider.GetRequiredService\u003cICloudEventPubSub\u003e();\r\nawait pubsub.PublishAsync(new OrderCancelled(order.Id, reason));\r\n```\r\n\r\n### Subscribe and process cloud event:\r\n``` csharp\r\npublic class OrderCancelledHandler : ICloudEventHandler\u003cOrderCancelled\u003e\r\n{\r\n    public async Task HandleAsync(CloudEvent\u003cPingEvent\u003e cloudEvent, CancellationToken token)\r\n    {\r\n        // ...\r\n    }\r\n}\r\n```\r\n\r\n## Performance\r\n\r\nThe benchmark result on a 4*2.4GHz Core VM:\r\n\r\n|      | Kafka | Redis |  \r\n| --- | --- | --- |  \r\n| Publish | ~100k/s | ~90k/s |  \r\n| Subscribe | ~150k/s | ~40k/s |  \r\n\r\nThe benchmark code is located at `perf/CloudEventTester`\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcarea%2Fcloudeventdotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcarea%2Fcloudeventdotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcarea%2Fcloudeventdotnet/lists"}