{"action":"created","issue":{"url":"https://api.github.com/repos/bitwalker/swarm/issues/81","repository_url":"https://api.github.com/repos/bitwalker/swarm","labels_url":"https://api.github.com/repos/bitwalker/swarm/issues/81/labels{/name}","comments_url":"https://api.github.com/repos/bitwalker/swarm/issues/81/comments","events_url":"https://api.github.com/repos/bitwalker/swarm/issues/81/events","html_url":"https://github.com/bitwalker/swarm/issues/81","id":310550991,"number":81,"title":"Node affinity / bias `key_to_node`","user":{"login":"hickscorp","id":822933,"avatar_url":"https://avatars1.githubusercontent.com/u/822933?v=4","gravatar_id":"","url":"https://api.github.com/users/hickscorp","html_url":"https://github.com/hickscorp","followers_url":"https://api.github.com/users/hickscorp/followers","following_url":"https://api.github.com/users/hickscorp/following{/other_user}","gists_url":"https://api.github.com/users/hickscorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hickscorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hickscorp/subscriptions","organizations_url":"https://api.github.com/users/hickscorp/orgs","repos_url":"https://api.github.com/users/hickscorp/repos","events_url":"https://api.github.com/users/hickscorp/events{/privacy}","received_events_url":"https://api.github.com/users/hickscorp/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-02T17:39:19Z","updated_at":"2018-04-02T18:08:03Z","closed_at":"2018-04-02T18:08:03Z","author_association":"NONE","body":"It would be great to have functionality allowing overriding the `key_to_node` not to use whatever is passed into `name`, and have something arbitrary instead.\r\n\r\nIdeally, it would be a function passed via config, that would be called every time something is about to be hashed.\r\n\r\nImagine a process named `{Vote.Logic, 1}`, its state `{Vote.Logic.State, 1}`. When they get started, their name gets hashed independently, and they end up running on different nodes, adding tons of network lag between the two processes.\r\nMy suggestion is to allow swarm to be configured with a `name_to_key` function that would be called every time something is about to get hashed, such as:\r\n\r\n```\r\nconfig :swarm, name_to_key: fn name ->\r\n  case name do\r\n    {_module, identifier} -> identifier\r\n    name -> name\r\n  end\r\nend\r\n```\r\n\r\nSwarm would call this function and end up hashing its result, not the `name` of the process, therefore allowing processes that should stay close to one another to run on the same node."},"comment":{"url":"https://api.github.com/repos/bitwalker/swarm/issues/comments/377997049","html_url":"https://github.com/bitwalker/swarm/issues/81#issuecomment-377997049","issue_url":"https://api.github.com/repos/bitwalker/swarm/issues/81","id":377997049,"user":{"login":"hickscorp","id":822933,"avatar_url":"https://avatars1.githubusercontent.com/u/822933?v=4","gravatar_id":"","url":"https://api.github.com/users/hickscorp","html_url":"https://github.com/hickscorp","followers_url":"https://api.github.com/users/hickscorp/followers","following_url":"https://api.github.com/users/hickscorp/following{/other_user}","gists_url":"https://api.github.com/users/hickscorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hickscorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hickscorp/subscriptions","organizations_url":"https://api.github.com/users/hickscorp/orgs","repos_url":"https://api.github.com/users/hickscorp/repos","events_url":"https://api.github.com/users/hickscorp/events{/privacy}","received_events_url":"https://api.github.com/users/hickscorp/received_events","type":"User","site_admin":false},"created_at":"2018-04-02T18:08:02Z","updated_at":"2018-04-02T18:08:02Z","author_association":"NONE","body":"@slashdotdash Indeed, that works. Thanks!"}}
{"actor":{"display_login":"hickscorp"}}