Added/update docstring
This commit is contained in:
@@ -20,19 +20,17 @@ class Communicator:
|
||||
"""
|
||||
|
||||
def __init__(self, currentconsumer: str, uuid: str):
|
||||
"""
|
||||
Initialize object
|
||||
:param consumerlocator:
|
||||
:param uuid:
|
||||
"""Initialize object
|
||||
:param consumerlocator: the current consumer's IP address as a string
|
||||
:param uuid: string typed UUID.
|
||||
"""
|
||||
self.currenctconsumer=currentconsumer
|
||||
self.uuid = uuid
|
||||
|
||||
def sendmessage(self, message: str) -> None:
|
||||
"""
|
||||
Send message to consumer.
|
||||
:param message:
|
||||
:return: none
|
||||
"""Send message to the current consumer. Logs the process.
|
||||
:param message: the message of type string that will be sent.
|
||||
:return: None
|
||||
"""
|
||||
currentconsumer=self.currenctconsumer
|
||||
LOGGER.info(f"Sending message to {currentconsumer}")
|
||||
@@ -40,9 +38,8 @@ class Communicator:
|
||||
LOGGER.debug(f"Message status code is:{postresponse.status_code}")
|
||||
|
||||
def discoveravailableconsumers(self) -> list:
|
||||
"""
|
||||
Get the list of available consumer from the current primary consumer.
|
||||
:return:
|
||||
"""Get the list of available consumer from the current primary consumer. Logs the received list.
|
||||
:return: list of consumers' IP addresses
|
||||
"""
|
||||
try:
|
||||
currentconsumer = self.currenctconsumer
|
||||
@@ -55,9 +52,8 @@ class Communicator:
|
||||
return []
|
||||
|
||||
def isconsumeravailable(self) -> bool:
|
||||
"""
|
||||
Readiness probe primary consumer.
|
||||
:return:
|
||||
"""Readiness probe current consumer. Logs the result.
|
||||
:return: True if available, False otherwise
|
||||
"""
|
||||
currentconsumer = self.currenctconsumer
|
||||
try:
|
||||
@@ -70,10 +66,9 @@ class Communicator:
|
||||
return isavailable
|
||||
|
||||
def checkconsumer(self, consumer: str) -> bool:
|
||||
"""
|
||||
Readiness probe of a prticular consumer.
|
||||
:param consumer:
|
||||
:return:
|
||||
"""Readiness probe of a particular consumer. Logs the result.
|
||||
:param consumer: the consumer's IP address
|
||||
:return: True if available, False otherwise
|
||||
"""
|
||||
try:
|
||||
response = requests.get(f'http://{consumer}/consumers')
|
||||
@@ -84,10 +79,9 @@ class Communicator:
|
||||
LOGGER.info(f"Consumer {consumer} availability: {isavailable}")
|
||||
return isavailable
|
||||
|
||||
def set_currentconsumer(self,currenctconsumer):
|
||||
"""
|
||||
Set current consumer
|
||||
:param currenctconsumer:
|
||||
:return:
|
||||
def set_currentconsumer(self,currenctconsumer) -> None:
|
||||
"""Set current consumer
|
||||
:param currenctconsumer: the consumer's IP address
|
||||
:return: None
|
||||
"""
|
||||
self.currenctconsumer=currenctconsumer
|
||||
|
||||
Reference in New Issue
Block a user