basho / clique

CLI Framework for Erlang
Apache License 2.0
147 stars 49 forks source link

Make command callbacks only run on local node #8

Open andrewjstone opened 9 years ago

andrewjstone commented 9 years ago

When using the set command the registered callback will be called on local or remote nodes automatically depending upon the --node and --all flags. Right now however, command callbacks must do the cross node calls themselves instead of being told where to run. Make this more inline with set and call the functions in the right locations automatically.

andrewjstone commented 9 years ago

After thinking about this more I think it's overkill, (at least for now). Most commands are status which show summary information and require contacting multiple nodes. Sometimes there is interest for info on a given node, but this still may require using cluster metadata or rpc-ing all nodes as is currently done in riak-admin handoff status. In this case running a callback function only on the given node is actually the wrong thing to do. Therefore we must maintain 2 ways to register commands which seems to unnecessarily complicate thing.

As some commands will want to contact a given node or all nodes, the functions are exported already from riak_cli_nodes to find all nodes and contact a given node via rpc.

As another 'intermediate' step I created a PR that includes a riak_cli_typecast module that will build up a library of usable functions that can be used to simplify command registration.