-
Notifications
You must be signed in to change notification settings - Fork 267
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
fixup! Split the Peer
in two (#1347)
#1357
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1357 +/- ##
==========================================
+ Coverage 86.29% 86.36% +0.06%
==========================================
Files 119 119
Lines 9201 9225 +24
Branches 396 402 +6
==========================================
+ Hits 7940 7967 +27
+ Misses 1261 1258 -3
|
@@ -21,8 +21,10 @@ import kamon.Kamon | |||
object Monitoring { | |||
|
|||
object Metrics { |
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.
We could probably also instrument the reconnection tasks? Maybe a counter for successful/failed reconnections?
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.
Oh yeah
@@ -456,7 +467,7 @@ object PeerConnection { | |||
sealed trait Data | |||
sealed trait HasTransport extends Data { def transport: ActorRef } | |||
case object Nothing extends Data | |||
case class AuthenticatingData(pendingAuth: PendingAuth, transport: ActorRef) extends Data | |||
case class AuthenticatingData(pendingAuth: PendingAuth, transport: ActorRef) extends Data with HasTransport |
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.
nit: HasTransport
already extends Data
, so you don't need extends Data with HasTransport
(and same below).
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 know, that's because I have used the cake pattern too much. Actually that's a perfect fit for the cake pattern and I could have defined HasTransport
that way:
sealed trait HasTransport { this: Data => def transport: ActorRef }
wdyt @sstone?
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.
Done with df54c28
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.
What does that cake pattern bring here (apart from being less explicit than sealed trait HasTransport extends Data
)?
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.
Not much: it conveys the idea that HasTransport
is just a behavior and not a definition, which is closer to how I see it.
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.
Got it, I'm not very familiar with that pattern
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.
In other words you have to use Data with HasTransport
, you can't use HasTransport
by itself.
What do you guys think of removing the Meaning going from:
to:
Tradeoff being that the flow is simpler, but all messages have to go through the |
I prefer how it is now. It's really not much code and avoids too much forwarding and encapsulating. |
Apart from that, I'm in favor on merging this PR once the |
Gave it a try with 27c7e68. |
peer forward p | ||
|
||
case p: Peer.PeerMessage => | ||
// we create a peer if it doesn't exist |
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.
We should never have to create one here, right?
Are there unwanted side-effects if we do (some assumption each of the FSMs make about the other FSMs)?
Shouldn't we reject those messages if we don't have a peer actor to handle it?
It feels to me that the peer FSMs already have to know about the other FSMs and assume some of their behavior, and this change is making it slightly worse...
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.
We should never have to create one here, right?
Correct, this is only needed in the handler for PeerConnection.ConnectionReady
.
It feels to me that the peer FSMs already have to know about the other FSMs and assume some of their behavior, and this change is making it slightly worse...
There has to be an interface contract, even if it less explicit with (untyped) actors. If anything the interface is a bit simpler now. But let's revert this and we can revisit later.
This reverts commit 27c7e68.
No description provided.