Skip to content

Server-sent events (SSE) client implementation for Ruby

License

Notifications You must be signed in to change notification settings

raycast/ruby-eventsource

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LaunchDarkly SSE Client for Ruby

Gem Version Circle CI

A client for the Server-Sent Events protocol. This implementation runs on a worker thread, and uses the http gem to manage a persistent connection. Its primary purpose is to support the LaunchDarkly SDK for Ruby, 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:
gem install ld-eventsource
  1. Import the code:
require 'ld-eventsource'
  1. Create a new SSE client instance and register your event handler:
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.

Contributing

We welcome questions, suggestions, and pull requests at our Github repository. Pull requests should be done from a fork.

About

Server-sent events (SSE) client implementation for Ruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 97.4%
  • Shell 2.6%