Abstract Election#

Base Election#

class smoothcrawler_cluster.election.BaseElection[source]#

Base class of election

About the election running, it could have so many way to process. So here provides some abstracted functions to let developers extend more different strategies of election processing for more different scenarios.

abstract elect(**kwargs) ElectionResult[source]#

Run the election processing to verify who is/are Runner and otherwise is/are Backup_Runner finally.

Parameters:

**kwargs (dict) – The parameters of this one specific election strategy processing.

Returns:

Final election result.

Return type:

ElectionResult

abstract parse_index(**kwargs) List[int][source]#

Parse all the member’s identity from their name.

Parameters:

**kwargs (dict) – The parameters of this one specific election strategy processing.

Returns:

A list of int object which are the identities from all members in cluster.

abstract filter(**kwargs) List[bool][source]#

Filter all member’s identity and generate winners who would be RUNNER in cluster, nor they would be BACKUP RUNNER.

Parameters:

**kwargs (dict) – The parameters of this one specific election strategy processing.

Returns:

A list of bool object which means the current crawler instance is winner.