this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Pass cluster opts to ClusterNode

garrison 75e20e96 df305aa2

+14 -14
+7 -6
lib/cluster_node.ex
··· 16 16 17 17 :coordinator_names, 18 18 :coordinator_id, 19 - :initial_cluster_config, 19 + :initial_cluster_opts, 20 20 21 21 :slots, 22 22 ] ··· 28 28 cluster_name: Keyword.fetch!(opts, :cluster), 29 29 coordinator_names: Keyword.fetch!(opts, :coordinators), 30 30 coordinator_id: Keyword.get(opts, :coordinator_id), 31 - initial_cluster_config: Keyword.fetch!(opts, :initial_cluster_config), 31 + initial_cluster_opts: Keyword.fetch!(opts, :initial_cluster_opts), 32 32 slots: Keyword.fetch!(opts, :slots), 33 33 } 34 34 end ··· 37 37 defmodule State do 38 38 @enforce_keys [ 39 39 :node_config, 40 + :initial_cluster_config, 40 41 :coordinator_pid, 41 42 :server_supervisor_pid, 42 43 ] ··· 46 47 def init(opts) do 47 48 #SimProcess.flag(:trap_exit, true) 48 49 node_config = NodeConfig.from_opts(opts) 50 + initial_cluster_config = ClusterConfig.from_opts(node_config.initial_cluster_opts) 49 51 50 52 coordinator_pid = start_coordinator(node_config) 51 53 server_supervisor_pid = start_server_supervisor(node_config) 52 54 53 55 state = %State{ 54 56 node_config: node_config, 57 + initial_cluster_config: initial_cluster_config, 55 58 coordinator_pid: coordinator_pid, 56 59 server_supervisor_pid: server_supervisor_pid, 57 60 } ··· 79 82 80 83 defp ensure_cluster_config(%State{} = state) do 81 84 %{ 85 + initial_cluster_config: initial_cluster_config, 82 86 coordinator_pid: coordinator_pid, 83 - node_config: %NodeConfig{ 84 - initial_cluster_config: %ClusterConfig{} = cluster_config, 85 - }, 86 87 } = state 87 88 88 89 SimProcess.spawn_link(fn -> 89 - do_ensure_cluster_config(coordinator_pid, cluster_config) 90 + do_ensure_cluster_config(coordinator_pid, initial_cluster_config) 90 91 end) 91 92 :ok 92 93 end
+7 -8
lib/sandbox.ex
··· 1 1 defmodule Hobbes.Sandbox do 2 - alias Hobbes.{ClusterConfig, ClusterNode} 2 + alias Hobbes.ClusterNode 3 3 alias Trinity.Sim 4 4 5 5 import ExUnit.Assertions, only: [assert: 1] ··· 27 27 ] 28 28 end 29 29 30 - defp init_distributed_cluster(num_coordinators, %ClusterConfig{} = cluster_config) do 30 + defp init_distributed_cluster(num_coordinators, opts) do 31 31 # Starting a distributed cluster is sim-only for now 32 32 assert Sim.simulated?() 33 33 ··· 44 44 cluster: "cluster", 45 45 coordinators: coordinators, 46 46 coordinator_id: i, 47 - initial_cluster_config: cluster_config, 47 + initial_cluster_opts: opts, 48 48 49 49 # TODO: configurable 50 50 slots: default_slots(), ··· 58 58 coordinators 59 59 end 60 60 61 - defp init_local_cluster(num_coordinators, %ClusterConfig{} = cluster_config) do 61 + defp init_local_cluster(num_coordinators, opts) do 62 62 coordinators = Enum.map(0..(num_coordinators - 1), fn i -> 63 63 # TODO: name should include cluster name 64 64 String.to_atom("coordinator-#{i}") ··· 72 72 cluster: "cluster", 73 73 coordinators: coordinators, 74 74 coordinator_id: i, 75 - initial_cluster_config: cluster_config, 75 + initial_cluster_opts: opts, 76 76 77 77 # TODO: configurable 78 78 slots: default_slots(), ··· 87 87 @spec start_cluster(keyword) :: {:ok, [atom] | [{atom, atom}]} 88 88 def start_cluster(opts) do 89 89 num_coordinators = Keyword.get(opts, :num_coordinators, 3) 90 - config = ClusterConfig.from_opts(opts) 91 90 92 91 coordinators = 93 92 if Keyword.get(opts, :distributed) do 94 - init_distributed_cluster(num_coordinators, config) 93 + init_distributed_cluster(num_coordinators, opts) 95 94 else 96 - init_local_cluster(num_coordinators, config) 95 + init_local_cluster(num_coordinators, opts) 97 96 end 98 97 99 98 {:ok, coordinators}