ArangoDB-Community / arangodb-net-standard

A consistent, comprehensive, minimal interface to enable .NET applications to use the complete range of features exposed by the ArangoDB REST API.
Apache License 2.0
76 stars 29 forks source link

Built-in support for Active Failover #477

Open JLedel opened 1 year ago

JLedel commented 1 year ago

If you're using an active failover setup and happens to query a follower, or there is a leader change, you'll get an exception telling that the node is not a leader anymore.

I guess the reasonable fix is to allow the HttpApiTransport class to be created with multiple endpoints, and then have the transport silently either try the other one suggested by the header, or just go through the list of provided servers until one that's leader is found.

Is there any interest to add support for this in this project as well? If so, we could try to coordinate it so that our implementation works for this connector as well.

DiscoPYF commented 1 year ago

Hi @JLedel , it makes sense to me to add support for this in this project.

I'm not familiar with the active failover sequence and implementation in ArangoDB, I will take a closer look. But at a glance I would propose to:

What do you think?

JLedel commented 1 year ago

We looked at the go driver which just cycles between the connections until it finds a leader (for cluster as well): https://github.com/arangodb/go-driver/blob/ae64363de2bc9a13e5ef03115489e19fc9439793/cluster/cluster.go#L202

But yes, a FailOverHttpApiTransport would solve our case. We're working on it internally, so I'll make a PR once we've tested it a bit, and we can take it from there.

DiscoPYF commented 1 year ago

Sounds good 👍