utils.functions package#

Submodules#

utils.functions.utility_functions module#

Utility functions’ module.

This module contains utility functions used in other modules.

exception utils.functions.utility_functions.KafkaTopicAlreadyExists[source]#

Bases: Warning

Warning to indicate that kafka topic already exists

utils.functions.utility_functions.add_new_chat(session: Session, chat_title: str, chat_context: str) str[source]#

Add new chat to database.

Parameters:
  • session – Application session object

  • chat_title – Chat title

  • chat_context – Chat context

Returns:

Added Chat uuid string to the database.

utils.functions.utility_functions.create_apache_kafka_topic(topic_title: str) None[source]#

Function for creating Apache Kafka Topic.

In the event where :topic_title already exists as a kafka topic, the resolution strategy is thus: - Raise a KafkaTopicAlreadyExists warning about the duplicate topic creation issue - Employ uuid.uuid4() to create a UUID suffix that is appended to topic_title to form a new topic string. - Call create_apache_kafka_topic() with the new topic string.

Parameters:

topic_title – Title of the Apache Kafka topic intended to be created

Returns:

None

utils.functions.utility_functions.create_message_JSON(content: str, thread_id: int, context_id: int, partition_hint: int, parent_message_id: int) MessageJSON[source]#

This function returns the MessageJSON object equivalent of the supplied arguments.

Parameters:
  • content

  • thread_id

  • context_id

  • partition_hint

  • parent_message_id

Returns:

MessageJSON object (basically a python dictionary)

utils.functions.utility_functions.generate_message_from_user(user: User, thread_id: int, context_id: int, partition_hint: int, parent_message_id: int | None = None) MessageJSON[source]#

Given user object, generate and return message from user.

Parameters:
  • user – Instantiated user object

  • thread_id – Thread ID

  • context_id – Context ID

  • partition_hint – Partition Hint

  • parent_message_id – Parent Message ID (optional)

Returns:

MessageJSON of the generated message.

Module contents#