Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Created July 26, 2020 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/8d5f12dce2f081717605dbaf9544f120 to your computer and use it in GitHub Desktop.
Save chelseatroy/8d5f12dce2f081717605dbaf9544f120 to your computer and use it in GitHub Desktop.
Conditional Statement—Responding to Data Manipulation Requests
...
else: #if the request is to get, set, or delete
if self.leader:
self.current_operation = string_operation
key_value_store.write_to_log(string_operation, term_absent=True)
if self.current_operation.split(" ")[0] in ["set", "delete"]:
broadcast(self, with_return_address(self, "append_entries [" + self.current_operation + "]"))
send_pending = False
else:
response = "I am not the leader. Please leave me alone."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment