Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce heartbeatbuild logic duplication #1808

Merged

Conversation

onsriahi14
Copy link
Contributor

No description provided.

Copy link

Pull reviewers stats

Stats of the last 30 days for popstellar:

User Total reviews Time to review Total comments
matteosz
🥇
3
▀▀
1d 22h 20m
6
▀▀
MariemBaccari
🥈
2
6d 11h 51m
1
K1li4nL
🥉
2
18d 4h 13m
▀▀
3
Tyratox
1
3d 10h 1m
3
arnauds5
1
9h 6m
0
1florentin
1
6d 20h 7m
0
sgueissa
1
17d 23h 19m
▀▀
4
t1b00
1
7d 16h 20m
1
ljankoschek
1
7h 42m
0
simone-kalbermatter
1
16d 1h 26m
▀▀
9
▀▀▀
onsriahi14
1
2d 14h 7m
0
Kaz-ookid
1
2d 5h 33m
1
⚡️ Pull request stats

@onsriahi14 onsriahi14 marked this pull request as ready for review April 14, 2024 14:45
@onsriahi14 onsriahi14 requested a review from a team as a code owner April 14, 2024 14:45
@onsriahi14 onsriahi14 linked an issue Apr 14, 2024 that may be closed by this pull request
Copy link
Contributor

@t1b00 t1b00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a few minor code quality tweaks that are possible but other than that LGTM!

val securityModuleActorRef: AskableActorRef = system.actorOf(Props(SecurityModuleActor(RuntimeEnvironment.securityPath)))

// Create necessary actors for server-server communications
val heartbeatGenRef: ActorRef = system.actorOf(HeartbeatGenerator.props(dbActorRef))
val monitorRef: ActorRef = system.actorOf(Monitor.props(heartbeatGenRef))
// val heartbeatGenRef: ActorRef = system.actorOf(HeartbeatGenerator.props(dbActorRef))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be good to remove the unnecessary code :)

val heartbeat: HashMap[Channel, Set[Hash]] =
Await.ready(askForHeartbeat, duration).value.get match
case Success(DbActor.DbActorGenerateHeartbeatAck(Some(map))) => map
case Failure(ex: DbActorNAckException) => HashMap.empty[Channel, Set[Hash]] // Specific failure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why keep the specific failure if the handling is the same as the case _? Isn't it possible to combine both?

val setOfChannels = getAllChannels
if (setOfChannels.isEmpty) return None
var heartbeatMap: HashMap[Channel, Set[Hash]] = HashMap()
setOfChannels.foreach(channel => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can replace this by a setOfChannels.map and avoid the HashMap creation

@onsriahi14 onsriahi14 requested a review from t1b00 April 14, 2024 16:36
Copy link
Contributor

@K1li4nL K1li4nL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of moving parts in the code you are touching, good job overall ! Some nitpicks and some simplification that I believe could make the code better

t1b00
t1b00 previously approved these changes Apr 15, 2024
@onsriahi14 onsriahi14 requested a review from K1li4nL April 19, 2024 14:09
Copy link
Contributor

@K1li4nL K1li4nL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last comments, after that we should be good !

@@ -369,6 +370,21 @@ final case class DbActor(
(publicKey, privateKey)
}

@throws[DbActorNAckException]
private def generateHeartbeat(): Option[HashMap[Channel, Set[Hash]]] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like an Option is not necessary here, you might as well return an empty map directly ?


monitorRef ! PoisonPill
mockConnectionMediator.expectTerminated(monitorRef)

Copy link
Contributor

@K1li4nL K1li4nL Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

250: blank line


monitorRef ! PoisonPill
mockConnectionMediator.expectTerminated(monitorRef)

Copy link
Contributor

@K1li4nL K1li4nL Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

269: blank line

Copy link

sonarcloud bot commented Apr 19, 2024

Quality Gate Passed Quality Gate passed for 'PoP - PoPCHA-Web-Client'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Apr 19, 2024

Copy link

sonarcloud bot commented Apr 19, 2024

Quality Gate Passed Quality Gate passed for 'PoP - Be1-Go'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Apr 19, 2024

Quality Gate Passed Quality Gate passed for 'PoP - Fe1-Web'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Apr 19, 2024

Quality Gate Passed Quality Gate passed for 'PoP - Fe2-Android'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@onsriahi14 onsriahi14 requested a review from K1li4nL April 19, 2024 20:10
Copy link
Contributor

@K1li4nL K1li4nL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@onsriahi14 onsriahi14 added this pull request to the merge queue Apr 19, 2024
Merged via the queue into master with commit c5d8af4 Apr 19, 2024
18 checks passed
@onsriahi14 onsriahi14 deleted the work-be2-onsriahi-Reduce-heartbeatbuild-logic-duplication branch April 19, 2024 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BE2]: Reduce heartbeat build logic duplication
3 participants