https://github.com/launchdarkly/ruby-eventsource
Server-Sent Events client for Ruby
https://github.com/launchdarkly/ruby-eventsource
eventsource feature-flags feature-toggles launchdarkly launchdarkly-sdk launchdarkly-sdk-component managed-by-terraform ruby server-sent-events
Last synced: 3 months ago
JSON representation
Server-Sent Events client for Ruby
- Host: GitHub
- URL: https://github.com/launchdarkly/ruby-eventsource
- Owner: launchdarkly
- License: other
- Created: 2019-01-03T02:56:56.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2026-01-16T15:01:40.000Z (3 months ago)
- Last Synced: 2026-01-17T05:09:52.579Z (3 months ago)
- Topics: eventsource, feature-flags, feature-toggles, launchdarkly, launchdarkly-sdk, launchdarkly-sdk-component, managed-by-terraform, ruby, server-sent-events
- Language: Ruby
- Homepage:
- Size: 130 KB
- Stars: 46
- Watchers: 41
- Forks: 20
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
LaunchDarkly SSE Client for Ruby
================================
[](http://badge.fury.io/rb/ld-eventsource)
[](https://github.com/launchdarkly/ruby-eventsource/actions/workflows/ci.yml)
A client for the [Server-Sent Events](https://www.w3.org/TR/eventsource/) protocol. This implementation runs on a worker thread, and uses the [`http`](https://rubygems.org/gems/http) gem to manage a persistent connection. Its primary purpose is to support the [LaunchDarkly SDK for Ruby](https://github.com/launchdarkly/ruby-client), but it can be used independently.
Parts of this code are based on https://github.com/Tonkpils/celluloid-eventsource, but it does not use Celluloid.
Supported Ruby versions
-----------------------
This gem has a minimum Ruby version of 3.1.
Quick setup
-----------
1. Install the Ruby SDK with `gem`:
```shell
gem install ld-eventsource
```
2. Import the code:
```ruby
require 'ld-eventsource'
```
3. Create a new SSE client instance and register your event handler:
```ruby
sse_client = SSE::Client.new("http://hostname/resource/path") do |client|
client.on_event do |event|
puts "I received an event: #{event.type}, #{event.data}"
end
end
```
For other options available with the `Client` constructor, see the [API documentation](https://www.rubydoc.info/gems/ld-eventsource).
Contributing
------------
We welcome questions, suggestions, and pull requests at our [Github repository](https://github.com/launchdarkly/ruby-eventsource). Pull requests should be done from a fork.