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

Recommended configuration for development #54

Open
liamwhite opened this issue Oct 26, 2020 · 3 comments
Open

Recommended configuration for development #54

liamwhite opened this issue Oct 26, 2020 · 3 comments

Comments

@liamwhite
Copy link

If you add

  {Phoenix.PubSub, adapter: Phoenix.PubSub.Redis}

to your list of child applications, and then try to start the application in development mode (for example with iex -S mix), you will get an error from this line:

    if node_name in [nil, :nonode@nohost] do
      raise ArgumentError, ":node_name is a required option for unnamed nodes"
    end

I hacked around this by doing the following:

  children = [
    {Phoenix.PubSub,
     [
       name: Philomena.PubSub,
       adapter: Phoenix.PubSub.Redis,
       node_name: valid_node_name(node())
     ]}
  ]

  # Redis adapter really really wants you to have a unique node name,
  # so just fake one if iex is being started
  defp valid_node_name(node) when node in [nil, :nonode@nohost],
    do: Base.encode16(:crypto.strong_rand_bytes(6))

  defp valid_node_name(node), do: node

Surely there must be a better way?

@yoelfme
Copy link

yoelfme commented Mar 2, 2021

yep, I think that you can pass the --sname flag to the iex command and there set a name like:

iex --sname foo -S mix

and if you have zsh and you are using Mac you can get the current username name and pass that as a value to the flag:

iex --sname $(id -un) -S mix

@liamwhite
Copy link
Author

I guess with this issue I am asking why it matters for this library. If the entire point is connecting to a named redis instance, why can't the node just be anonymous?

@yoelfme
Copy link

yoelfme commented Mar 3, 2021

Oh got it, well maybe the authors can explained that better, I just showed u another "hack"

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

2 participants