Open henriiik opened 1 year ago
I haven't tried this locally yet but my guess is that EventStore doesn't let you create persistent subscriptions from follower members of a cluster. You could inspect the list of cluster members with Spear.cluster_info/2
and find the %Spear.ClusterMember{}
which is the leader (the :state
key should have a value :Leader
) and start a connection to that member for operations like creating persistent subscriptions and appending events. Spear focuses on single-server connections so there aren't conveniences built into Spear for clustering/gossip actions like switching from a follower to a leader currently.
Thank you for your response!
I haven't tried this locally yet but my guess is that EventStore doesn't let you create persistent subscriptions from follower members of a cluster. You could inspect the list of cluster members with Spear.cluster_info/2 and find the %Spear.ClusterMember{} which is the leader (the :state key should have a value :Leader) and start a connection to that member for operations like creating persistent subscriptions and appending events.
That is correct and indeed what i ended up doing.
But since the leader information is available in the headers of the error response it would save some api calls if they was exposed, would you be willing to accept a PR that exposes them? :)
Yeah, avoiding a round trip for this sounds like a nice improvement! Go ahead and open up a PR 👍
Hello!
I am trying to use
spear
create/connect to persistent subscriptions in a clustered eventstoredb setup.If the
Spear.Connection
is connected to a non-leader node an error like this is returned, which contains the info needed to re-connect to the leader node:The call to
Spear.create_persistent_subscription
returns an error like this, which was very confusing to me at first:I was able to reproduce the issue by switching the docker setup in the
spear
repo to use a clustered eventstoredb, and with some additional logging i get this:edit:
I accidentally submitted this issue before i was done writing it.
Is there recomended way to handle this? Look up leader before creating the subscription? or is this a bug?