FriendshipServiceVerticle

class FriendshipServiceVerticle(userRepository: UserRepository, friendshipRepository: FriendshipRepository, friendshipRequestRepository: FriendshipRequestRepository, messageRepository: MessageRepository, kafkaProducer: KafkaProducerVerticle, credentials: DatabaseCredentials? = null, shouldConnectToDB: Boolean? = true) : AbstractVerticle, FriendshipService

FriendshipServiceVerticle is the main entry point for the Friendship Service. It is responsible for handling all the business logic related to friendships, friendship requests, messages and users. It also deploys the KafkaFriendshipProducerVerticle to publish events to the Kafka broker.

Parameters

userRepository

The repository to interact with the User entity.

friendshipRepository

The repository to interact with the Friendship entity.

friendshipRequestRepository

The repository to interact with the FriendshipRequest entity.

messageRepository

The repository to interact with the Message entity.

credentials

The database credentials to connect to the MySQL database.

shouldConnectToDB

A flag to determine if the service should connect to the database, used for testing purposes.

Constructors

Link copied to clipboard
constructor(userRepository: UserRepository, friendshipRepository: FriendshipRepository, friendshipRequestRepository: FriendshipRequestRepository, messageRepository: MessageRepository, kafkaProducer: KafkaProducerVerticle, credentials: DatabaseCredentials? = null, shouldConnectToDB: Boolean? = true)

Functions

Link copied to clipboard
open override fun acceptFriendshipRequest(request: FriendshipRequest)

Accepts a friendship request. Also publishes a FriendshipRequestAccepted event to the Kafka broker and the Vert.x event bus.

Link copied to clipboard
open override fun addFriendship(friendship: Friendship)

Stops the FriendshipServiceVerticle and closes the database connections.

Link copied to clipboard
open override fun addFriendshipRequest(friendshipRequest: FriendshipRequest)

Adds a friendship request.

Link copied to clipboard
open override fun addMessage(message: Message)

Adds a message to the repository.

Link copied to clipboard
open override fun addUser(user: User)

Adds a user to the repository.

Link copied to clipboard
open fun config(): JsonObject
Link copied to clipboard

Connects to the MySQL database using the provided credentials or the default credentials given by the environment variables.

Link copied to clipboard
open override fun deleteFriendship(friendshipID: Friendship.FriendshipID): Friendship?

Deletes a friendship by its ID. Also publishes a FriendshipRemoved event to the Kafka broker and the Vert.x event bus.

Link copied to clipboard
open override fun deleteMessage(messageID: Message.MessageID): Message?

Deletes a message by its ID.

Link copied to clipboard
open fun deploymentID(): String
Link copied to clipboard
open override fun getAllFriendsByUserId(userID: User.UserID): Iterable<User>

Retrieves all friendships of a user.

Link copied to clipboard

Retrieves all friendship requests in the repository.

Link copied to clipboard

Retrieves all friendship requests of a user.

Link copied to clipboard
open override fun getAllFriendships(): Array<Friendship>

Retrieves all friendships.

Link copied to clipboard
open override fun getAllMessages(): Array<Message>

Retrieves all messages in the repository.

Link copied to clipboard

Retrieves all messages exchanged between 2 users.

Link copied to clipboard

Retrieves all messages sent by a user.

Link copied to clipboard
open override fun getFriendship(friendshipID: Friendship.FriendshipID): Friendship?

Retrieves a friendship by its ID.

Link copied to clipboard

Retrieves a friendship request by its ID.

Link copied to clipboard
open override fun getMessage(messageID: Message.MessageID): Message?

Retrieves a message by its ID.

Link copied to clipboard
open override fun getUser(userID: User.UserID): User?

Retrieves a user by their ID.

Link copied to clipboard
open override fun getVertx(): Vertx
Link copied to clipboard
open override fun init(p0: Vertx, p1: Context)
Link copied to clipboard
Link copied to clipboard
open override fun receivedMessage(message: Message)

Handles a received message. Also publishes a MessageReceived event to the Kafka broker and the Vert.x event bus.

Link copied to clipboard
open override fun rejectFriendshipRequest(friendshipRequest: FriendshipRequest): FriendshipRequest?

Rejects a friendship request. Also publishes a FriendshipRequestRejected event to the Kafka broker and the Vert.x event bus.

Link copied to clipboard
open override fun sentMessage(message: Message)

Handles a sent message. Also publishes a MessageSent event to the Kafka broker and the Vert.x event bus.

Link copied to clipboard
open override fun start(p0: Promise<Void>)

open override fun start()

Deploys the KafkaFriendshipProducerVerticle to publish events to the Kafka broker.

Link copied to clipboard
open fun stop()
open override fun stop(p0: Promise<Void>)