-
Notifications
You must be signed in to change notification settings - Fork 284
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2299 +/- ##
===========================================
- Coverage 89.81% 88.65% -1.16%
===========================================
Files 177 178 +1
Lines 15556 15729 +173
===========================================
- Hits 13971 13945 -26
- Misses 1585 1784 +199 |
8c24f2d
to
71d25a9
Compare
414de98
to
d2345cd
Compare
Default value changes to Session.dropped and Protocol.dropped
Remove session_exists
Minor refactoring
Exclude PendingObjectModel from collect_db_models
d288c6e
to
febc8ea
Compare
0ee1235
to
d28862f
Compare
d28862f
to
e2fec91
Compare
related to: #2223 |
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.
The golem.network.pending
part looks very complicated. Would it be possible to expose simple API/shortcuts as I suggested in https://github.com/golemfactory/golem/issues/2223#issuecomment-368491180 ? (pending.put()
, pending.get()
, pending.waiting()
)
class PendingMessage(PendingObjectModel): | ||
|
||
type = IntegerField() | ||
slots = MessageSlotsField() |
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.
This class should probably implement .as_message()
method. (It should know how to create a message from itself)
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.
Will do
golem/network/pending.py
Outdated
def get(cls, | ||
key_id: str, | ||
task_id: Optional[object] = ANY, | ||
subtask_id: Optional[object] = ANY) -> Iterator[PendingMessage]: |
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.
To be consistent with .put()
this should return Message
iterator
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.
Will do
return reduce(operator.and_, clauses) | ||
|
||
|
||
class PendingTaskSession(PendingObjectModel): |
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.
Since in current implementation TaskSession
instance is bound to a subtask, is it necessary to have separate PendingSession
and PendingMessage
? Logically we're interested in sending a pending message, and address:port should be accessible from PeerKeeper
.
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.
PendingMessage
is enough to send the message, but might not be enough to correctly process the response and send the following messages; e.g. self.result_owner
is required in some places.
I don't think the API is that simple, since this is not a message queue. Sessions are lost on both ends, and sending a mid-protocol message requires consistency (on both ends). Pending task session's data may be redundant, but at least it's complete. Please correct me if I'm missing something. |
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, but why we need aux database?
@@ -116,15 +117,12 @@ def interpret(self, msg): | |||
) | |||
BasicSafeSession.interpret(self, msg) | |||
|
|||
def send(self, msg, send_unverified=False): | |||
def send(self, msg) -> bool: | |||
"""Send given message if connection was verified or send_unverified | |||
option is set to True. |
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.
Probably need to change docs
@Elfoniok The main database is mildly congested at times and the second database is there in order not to make the situation worse. |
@jiivan Another approach would be to store session's state outside the |
session.db
for storing unsent messages and session detailsConnectionLost
error from twistedSession.send
now returns a success boolean valuesend_unverified
argument fromSession.send
in favor of theSession.can_be_unverified
collectionnode_info
toTaskSession
'sHello
message