Browse Source

Add to docs.

Roberto Ostinelli 3 years ago
parent
commit
73842a36b9
4 changed files with 45 additions and 29 deletions
  1. 0 21
      LICENSE.md
  2. 35 0
      README.md
  3. 2 4
      src/syn.erl
  4. 8 4
      src/syn_event_handler.erl

+ 0 - 21
LICENSE.md

@@ -1,21 +0,0 @@
-# License
-
-Copyright (c) 2015-2021 Roberto Ostinelli and Neato Robotics, Inc.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.

+ 35 - 0
README.md

@@ -90,3 +90,38 @@ Ensure that `syn` is started with your application, for example by adding it in
     %% ...
     %% ...
 ]}.
 ]}.
 ```
 ```
+
+## Contributing
+So you want to contribute? That's great! Please follow the guidelines below. It will make it easier to get merged in.
+
+Before implementing a new feature, please submit a ticket to discuss what you intend to do. Your feature might already be in the works, or an alternative implementation might have already been discussed.
+
+Do not commit to master in your fork. Provide a clean branch without merge commits. Every pull request should have its own topic branch. In this way, every additional adjustments to the original pull request might be done easily, and squashed with `git rebase -i`. The updated branch will be visible in the same pull request, so there will be no need to open new pull requests when there are changes to be applied.
+
+Ensure that proper testing is included. To run Syn tests you simply have to be in the project's root directory and run:
+
+```bash
+$ make test
+```
+
+## License
+
+Copyright (c) 2015-2021 Roberto Ostinelli and Neato Robotics, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

+ 2 - 4
src/syn.erl

@@ -30,11 +30,9 @@
 %% Syn implement Scopes. A Scope is a way to create a logical overlay network running on top of the Erlang distribution cluster.
 %% Syn implement Scopes. A Scope is a way to create a logical overlay network running on top of the Erlang distribution cluster.
 %% Nodes that belong to the same Scope will form a "sub-cluster", and will synchronize data between themselves and themselves only.
 %% Nodes that belong to the same Scope will form a "sub-cluster", and will synchronize data between themselves and themselves only.
 %%
 %%
-%% This allows for improved scalability, as it is possible to divide an Erlang cluster into sub-clusters which
-%% hold specific portions of data.
-%%
 %% Every node in an Erlang cluster is automatically added to the Scope `default'. It is therefore not mandatory
 %% Every node in an Erlang cluster is automatically added to the Scope `default'. It is therefore not mandatory
-%% to use scopes, but it is advisable to do so when scalability is a concern.
+%% to use scopes, but it is advisable to do so when scalability is a concern, as it is possible to divide
+%% an Erlang cluster into sub-clusters which hold specific portions of data.
 %%
 %%
 %% Please note that most of the methods documented here that allow to specify a Scope will raise a
 %% Please note that most of the methods documented here that allow to specify a Scope will raise a
 %% `error({invalid_scope, Scope})' if the local node has not been added to the specified Scope or if the Pids
 %% `error({invalid_scope, Scope})' if the local node has not been added to the specified Scope or if the Pids

+ 8 - 4
src/syn_event_handler.erl

@@ -34,6 +34,9 @@
 %% In your module you need to specify the behavior `syn_event_handler' and implement the callbacks.
 %% In your module you need to specify the behavior `syn_event_handler' and implement the callbacks.
 %% All callbacks are optional, so you just need to define the ones you need.
 %% All callbacks are optional, so you just need to define the ones you need.
 %%
 %%
+%% All of the callbacks, except for `resolve_registry_conflict/3', are called on all the nodes of the cluster.
+%% This allows you to receive events for the processes running on nodes that get shut down, or in case of net splits.
+%%
 %% While all callbacks do not have a direct effect on Syn (their return value is ignored), a special case is the callback
 %% While all callbacks do not have a direct effect on Syn (their return value is ignored), a special case is the callback
 %% `resolve_registry_conflict/3'. If specified, this is the method that will be used to resolve registry conflicts when detected.
 %% `resolve_registry_conflict/3'. If specified, this is the method that will be used to resolve registry conflicts when detected.
 %%
 %%
@@ -41,18 +44,19 @@
 %% When this happens, the cluster experiences a registry naming conflict.
 %% When this happens, the cluster experiences a registry naming conflict.
 %%
 %%
 %% Syn will resolve this Process Registry conflict by choosing a single process. By default, Syn keeps track of the time
 %% Syn will resolve this Process Registry conflict by choosing a single process. By default, Syn keeps track of the time
-%% when a registration takes place with {@link erlang:system_time/0},
-%% compares values between conflicting processes and:
+%% when a registration takes place with {@link erlang:system_time/0}, compares values between conflicting processes and:
 %% <ul>
 %% <ul>
 %% <li>Keeps the one with the higher value (the process that was registered more recently).</li>
 %% <li>Keeps the one with the higher value (the process that was registered more recently).</li>
 %% <li>Kills the other process by sending a kill signal with `exit(Pid, {syn_resolve_kill, Name, Meta})'.</li>
 %% <li>Kills the other process by sending a kill signal with `exit(Pid, {syn_resolve_kill, Name, Meta})'.</li>
 %% </ul>
 %% </ul>
 %% This is a very simple mechanism that can be imprecise, as system clocks are not perfectly aligned in a cluster.
 %% This is a very simple mechanism that can be imprecise, as system clocks are not perfectly aligned in a cluster.
-%% If something more elaborate is desired you MAY specify a custom handler that implements the `resolve_registry_conflict/3' callback.
+%% If something more elaborate is desired, or if you do not want the discarded process to be killed (i.e. to perform
+%% a graceful shutdown), you MAY specify a custom handler that implements the `resolve_registry_conflict/3' callback.
 %% To this effect, you may also store additional data to resolve conflicts in the `Meta' value, since it will be passed
 %% To this effect, you may also store additional data to resolve conflicts in the `Meta' value, since it will be passed
 %% into the callback for both of the conflicting processes.
 %% into the callback for both of the conflicting processes.
 %%
 %%
-%% If implemented, this method MUST return the `pid()' of the process that you wish to keep. The other process will be killed.
+%% If implemented, this method MUST return the `pid()' of the process that you wish to keep. The other process will not
+%% be killed, so you will have to decide what to do with it.
 %%
 %%
 %% Important Note: the conflict resolution method will be called on the two nodes where the conflicting processes are running on.
 %% Important Note: the conflict resolution method will be called on the two nodes where the conflicting processes are running on.
 %% Therefore, this method MUST be defined in the same way across all nodes of the cluster and have the same effect
 %% Therefore, this method MUST be defined in the same way across all nodes of the cluster and have the same effect