Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 2 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 (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-01-31T16:53:15.000Z (12 months ago)
- Last Synced: 2024-04-20T12:53:33.954Z (9 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: 89.8 KB
- Stars: 36
- Watchers: 40
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
LaunchDarkly SSE Client for Ruby
================================[![Gem Version](https://badge.fury.io/rb/ld-eventsource.svg)](http://badge.fury.io/rb/ld-eventsource)
[![Run CI](https://github.com/launchdarkly/ruby-eventsource/actions/workflows/ci.yml/badge.svg)](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 2.5, or 9.2 for JRuby.
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.