Crowdhailer
Creator of Raxx
Push updates to web clients over HTTP, using dedicated server-push protocol.
https://github.com/CrowdHailer/server_sent_event.ex/
Server Sent Events are a way to push updates to web clients, including browsers. See the spec for more details.
This project includes the tools for manipulating, serializing and parsing Events in this format.
It can be used to build both clients and servers.
Event Client
This library now also includes an Elixir Client for an event stream.
The client behaviour defines callbacks that handle connection/disconnect/reconnect and incoming events.
A simple client that always connects could be defined as follows
defmodule AutoConnect do
@behaviour ServerSentEvent.Client
# Start connecting to the endpoint as soon as client is started.
def init(state) do
{:connect, request(state), state}
end
# The client has successfully connected, or reconnected, to the event stream.
def handle_connect(_response, state) do
{:noreply, state}
end
# Retry connecting to endpoint 1 second after a failure to connect.
def handle_connect_failure(reason, state) do
Process.sleep(1_000)
{:connect, request(state), state}
end
# Immediatly try to reconnect when the connection is lost.
def handle_disconnect(_, state) do
{:connect, request(state), state}
end
# Update the running state of the client with the id of each event as it arrives.
# This event id is used for reconnection.
def handle_event(event, state) do
IO.puts("I just got a new event: #{inspect(event)}")
%{state | last_event_id: event.id}
end
# When stop message is received this process will exit with reason :normal.
def handle_info(:stop, state) do
{:stop, :normal, state}
end
# Not a callback but helpful pattern for creating requests in several callbacks
defp request({url: url}) do
Raxx.request(:GET, url)
|> Raxx.set_header("accept", "text/event-stream")
|> Raxx.set_header("last-event-id", state.last_event_id)
end
end
# Starting the client
{:ok, pid} = AutoConnect.start_link(%{url: "http://www.example.com/events", last_event_id: "0"})
The client can also be added to a supervision tree
children = [
{AutoConnect, %{url: "http://www.example.com/events", last_event_id: "0"}}
]
Trending in Announcing
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
New
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub.
Docs are at OpenaiEx User Gu...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly.
One of i...
New
Phoenix components for pagination, sortable tables and filter forms with Flop and (optionally) Ecto.
pagination
cursor pagination
sorta...
New
Please say hi to a new lib, Astro that aims to deliver easy-to-consume astronomy calculations of practical use. For now it only calculat...
New
Other Trending Topics
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog
It says that Fly is going all-in on sprites, which is a worry ...
New
Hey folks,
I just published a post about Hologram’s funding and where the project goes next - the short version:
Curiosum as Main Spons...
New
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using.
We’re particularly inte...
New
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










Showing Posts 1 to 9- Show Best Posts
- Show All Posts (oldest first)
- Show All Posts (newest first)
WolfDan
Is just me, or maybe you forgot to link the project @Crowdhailer ? ^^
Crowdhailer
Fixed, thanks
joefractal
Is there any javascript to go with this, so it could be used from a browser?
Crowdhailer
There is already a browser API for consuming ServerSentEvents.
The fact this API exists is the main reason I use them.
joefractal
Now I get it, thanks
Crowdhailer
0.4.3 Fixes connection edgecases in the ServerSentEvent.Client
See CHANGELOG for details
Crowdhailer
0.4.7 Make parsing 2_000x faster.
Just that.
See issue for benchmark and discussions.
https://github.com/CrowdHailer/server_sent_event.ex/pull/11
Crowdhailer
0.4.8 Add support for raxx 0.18.0
No breaking changes in this version of raxx affect this library so it now supports
0.16.x,0.17.xand0.18.xversions of raxxCrowdhailer
1.0.0 released
Removes support for pre-stable versions of Raxx when using the ServerSentEvent.Client.