Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(subscription_server.ex): on reconnect, state got duplicate callba… #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# AbsintheWebSocket
# AbsintheWebSocketHR

This libary uses WebSockets to communicate with a GraphQL endpoint built using Absinthe and Phoenix Channels. Its primary goal is to allow clients to use [Subscriptions](https://hexdocs.pm/absinthe/subscriptions.html), although it also supports queries. It uses [WebSockex](https://github.com/Azolo/websockex) as a WebSocket client. It also handles the specifics of Phoenix Channels (heartbeats) and how Absinthe subscriptions were implemented on top of them.
This libary uses WebSockets to communicate with a GraphQL endpoint built using Absinthe and Phoenix Channels. Its primary goal is to allow clients to use [Subscriptions](https://hexdocs.pm/absinthe/subscriptions.html), although it also supports queries. It uses [WebSockex](https://github.com/Azolo/websockex) as a WebSocket client. It also handles the specifics of Phoenix Channels (heartbeats) and how Absinthe subscriptions were implemented on top of them.

It is a fork of https://hexdocs.pm/absinthe_websocket, it contains following bug fix: [https://github.com/karlosmid/absinthe_websocket/commit/b08e0cf07c1dcdbb98e14c3905d8ee7b777aee66](https://github.com/karlosmid/absinthe_websocket/commit/b08e0cf07c1dcdbb98e14c3905d8ee7b777aee66)

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
use Mix.Config
import Config

# import_config "#{Mix.env}.exs"
3 changes: 1 addition & 2 deletions lib/absinthe_websocket/subscription_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ defmodule AbsintheWebSocket.SubscriptionServer do
def handle_cast({:subscribe, subscription_name, callback, query, variables}, %{socket: socket, subscriptions: subscriptions} = state) do
AbsintheWebSocket.WebSocket.subscribe(socket, self(), subscription_name, query, variables)

callbacks = Map.get(subscriptions, subscription_name, [])
subscriptions = Map.put(subscriptions, subscription_name, [callback | callbacks])
subscriptions = Map.put(subscriptions, subscription_name, [callback])
state = Map.put(state, :subscriptions, subscriptions)

{:noreply, state}
Expand Down
12 changes: 6 additions & 6 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
defmodule AbsintheWebSocket.Mixfile do
use Mix.Project

@version "0.2.2"
@url "https://github.com/annkissam/absinthe_websocket"
@version "0.2.3"
@url "https://github.com/karlosmid/absinthe_websocket"
@maintainers [
"Eric Sullivan",
"Karlo Šmid",
]

def project do
[
app: :absinthe_websocket,
app: :absinthe_websocket_hr,
version: @version,
elixir: "~> 1.5",
start_permanent: Mix.env == :prod,
Expand All @@ -35,7 +35,7 @@ defmodule AbsintheWebSocket.Mixfile do
[
{:websockex, "~> 0.4"},
{:poison, "~> 2.0 or ~> 3.0 or ~> 4.0"},
{:ex_doc, "~> 0.19", only: :dev},
{:ex_doc, "~> 0.28", only: :dev},
]
end

Expand All @@ -48,7 +48,7 @@ defmodule AbsintheWebSocket.Mixfile do

defp package do
[
name: :absinthe_websocket,
name: :absinthe_websocket_hr,
maintainers: @maintainers,
licenses: ["MIT"],
links: %{github: @url},
Expand Down
16 changes: 9 additions & 7 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
%{
"earmark": {:hex, :earmark, "1.3.0", "17f0c38eaafb4800f746b457313af4b2442a8c2405b49c645768680f900be603", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.19.1", "519bb9c19526ca51d326c060cb1778d4a9056b190086a8c6c115828eaccea6cf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"makeup": {:hex, :makeup, "0.5.5", "9e08dfc45280c5684d771ad58159f718a7b5788596099bdfb0284597d368a882", [:mix], [{:nimble_parsec, "~> 0.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"makeup_elixir": {:hex, :makeup_elixir, "0.10.0", "0f09c2ddf352887a956d84f8f7e702111122ca32fbbc84c2f0569b8b65cbf7fa", [:mix], [{:makeup, "~> 0.5.5", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.4.0", "ee261bb53214943679422be70f1658fff573c5d0b0a1ecd0f18738944f818efe", [:mix], [], "hexpm"},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
"websockex": {:hex, :websockex, "0.4.1", "d7b7191ec3d5dd136683b60114405a5a130a175faade773a07cb52dbd98f9442", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.3.0", "17f0c38eaafb4800f746b457313af4b2442a8c2405b49c645768680f900be603", [:mix], [], "hexpm", "f8b8820099caf0d5e72ae6482d2b0da96f213cbbe2b5b2191a37966e119eaa27"},
"earmark_parser": {:hex, :earmark_parser, "1.4.26", "f4291134583f373c7d8755566122908eb9662df4c4b63caa66a0eabe06569b0a", [:mix], [], "hexpm", "48d460899f8a0c52c5470676611c01f64f3337bad0b26ddab43648428d94aabc"},
"ex_doc": {:hex, :ex_doc, "0.28.4", "001a0ea6beac2f810f1abc3dbf4b123e9593eaa5f00dd13ded024eae7c523298", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "bf85d003dd34911d89c8ddb8bda1a958af3471a274a4c2150a9c01c78ac3f8ed"},
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
"makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm", "fec8660eb7733ee4117b85f55799fd3833eb769a6df71ccf8903e8dc5447cfce"},
"websockex": {:hex, :websockex, "0.4.1", "d7b7191ec3d5dd136683b60114405a5a130a175faade773a07cb52dbd98f9442", [:mix], [], "hexpm", "9017f2477d0aa5449fab6005d2a450e8365dcda780d3d05784182471df4f86ae"},
}