-
Notifications
You must be signed in to change notification settings - Fork 8
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
Reduce heartbeatbuild logic duplication #1808
Conversation
…gic-duplication stay up to date# the commit.
…Reduce-heartbeatbuild-logic-duplication
…educe-heartbeatbuild-logic-duplication
Pull reviewers statsStats of the last 30 days for popstellar:
|
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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
There was a problem hiding this 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
be2-scala/src/main/scala/ch/epfl/pop/decentralized/Monitor.scala
Outdated
Show resolved
Hide resolved
be2-scala/src/main/scala/ch/epfl/pop/decentralized/Monitor.scala
Outdated
Show resolved
Hide resolved
be2-scala/src/main/scala/ch/epfl/pop/decentralized/Monitor.scala
Outdated
Show resolved
Hide resolved
be2-scala/src/main/scala/ch/epfl/pop/pubsub/graph/handlers/ParamsWithMapHandler.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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]]] = { |
There was a problem hiding this comment.
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) | ||
|
There was a problem hiding this comment.
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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
269: blank line
Quality Gate passed for 'PoP - PoPCHA-Web-Client'Issues Measures |
Quality Gate passed for 'PoP - Be2-Scala'Issues Measures |
Quality Gate passed for 'PoP - Be1-Go'Issues Measures |
Quality Gate passed for 'PoP - Fe1-Web'Issues Measures |
Quality Gate passed for 'PoP - Fe2-Android'Issues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM !
No description provided.