Anoma.Node.Examples.ENode (Anoma v0.25.0)

Summary

Types

t()

I am the state of a TCP listener.

Functions

I initialize the ETS table to keep track of creates nodes.

I kill all the nodes in the vm.

I start a new node given a node id and returns its process id.

I stop a node and assert that's is gone.

Types

@type t() :: %Anoma.Node.Examples.ENode{
  grpc_port: integer(),
  node_id: String.t() | nil,
  pid: pid() | nil,
  tcp_ports: [integer()]
}

I am the state of a TCP listener.

My fields contain information to listen for TCP connection with a remote node.

Fields

  • :node_id - The key of this router. This value is used to announce myself to other
  • :pid - the pid of the supervision tree.
  • :tcp_ports - The ports on which the node is listening for connections.
  • :grpc_ports - The ports on which the node is listening for grpc connections.

Functions

Link to this function

initialize_ets()

I initialize the ETS table to keep track of creates nodes.

My only reason for existence is to keep track of the nodes that are created in the system and their GRPC ports.

Link to this function

kill_all_nodes()

@spec kill_all_nodes() :: :ok

I kill all the nodes in the vm.

Link to this function

start_node(opts \\ [])

@spec start_node(Keyword.t()) :: t() | {:error, :failed_to_start_node}

I start a new node given a node id and returns its process id.

When a node is started, I put its ENode struct in an ETS table for later retrieval.

When a node is already spawned, I lookup the ENode struct in the ETS table. Some meta data (in particular, the GRPC port) is only available when the node is started so I fetch that data from the ETS table.

Link to this function

stop_node(node)

@spec stop_node(t()) :: :ok

I stop a node and assert that's is gone.