-
Notifications
You must be signed in to change notification settings - Fork 2
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
Change RequestResponseProtocol to use a Message type parameter in anticipation of Functions #108
Conversation
cb33192
to
e4e078b
Compare
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.
Looks good, but a small clarification needed in the scaladoc for RequestResponseProtocol
@@ -4,28 +4,44 @@ import de.up.hpi.informationsystems.adbms.relation.Relation | |||
|
|||
object RequestResponseProtocol { | |||
|
|||
/** Message type to be subclassed and used as [[Request]] and [[Response]] type information | |||
* |
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.
One could explain a little bit more, how this works and why it is needed. I think that's not obvious.
You can add an example usage.
Use the word marker trait, as all descendants will never be implemented, right?
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.
You're right it's a little thin there.
There is a slight problem with the system we want at the moment though which relates to the trait Message
explanation, though:
In how I am currently implementing SequentialFunction
(in the experimental script), I lose the Message
type information of the Response
being passed back to the initial caller of the function. I am unsure if this is due to type erasure and has been that way regardless or if it is because of the following:
When I send messages to multiple recipients in a start
or next
step, I wait for them, collect all individual responses and then have to:
- unpack the
Responses
to get theRelation
tounion
them - re-pack into the appropriate
Responses
to pass on to the nextnext
orend
step
I am currently doing this like this:
// Receive
case message: Success[Message] =>
// are we still waiting for messages? if so, become current state with the received message remembered
// if not:
val constructor = message.getClass.getConstructors()(0) // get constr to be able to repack as (hopefully) the correct `Response` subtype
val unionResponse = (previouslyReceivedResponses :+ message)
.foldLeft(constructor.newInstance(Relation.empty).asInstanceOf[Success[Message]])((a: Success[Message], b: Success[Message]) =>
constructor.newInstance(a.result.unionAll(b.result)).asInstanceOf[Success[Message]])
// use unionResponse to continue with next steps
Due to me losing the specific Response
(or rather Success
) subtype I can then not match for a specific answer anymore.
If this persists we don't get anything from the current Message
type parameter, right?
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.
discussed in skype
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.
example can follow later, when functors are implemented
Proposed Changes
RequestResponseProtocol
to be compatible with envisionedMultiDactorFunctions
, specifically theSequentialFunction
Message
types toRequest
,Response
, and the subtypes (Success
andFailure
)Message definitions will change from:
to
Related