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

Violation of the Swarm.Distribution.Strategy definition is actually accepted #140

Open
balena opened this issue May 14, 2020 · 0 comments
Open

Comments

@balena
Copy link

balena commented May 14, 2020

{:error, {:invalid_ring, :no_nodes}} ->

By definition, Swarm.Distribution.Strategy.key_to_node/2 can return node() | :undefined. However this exact line is actually accepting {:error, {:invalid_ring, :no_nodes}} as a valid return value, which is actually what HashRing.key_to_node/2 returns in case of error.

So Swarm.Distribution.Ring.key_to_node/2 should actually return :undefined instead of {:error, reason} to honour the strategy definition:

defmodule Swarm.Distribution.Ring do
  ...
  def key_to_node(ring, key) do
    case HashRing.key_to_node(ring, key) do
      {:error, _reason} -> :undefined
      node -> node
    end
  end
end
balena added a commit to team-telnyx/swarm that referenced this issue May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant