Skip to content

Named sessions#8

Merged
j-mie6 merged 10 commits into
j-mie6:masterfrom
josh-ja-walker:named-sessions
Dec 22, 2025
Merged

Named sessions#8
j-mie6 merged 10 commits into
j-mie6:masterfrom
josh-ja-walker:named-sessions

Conversation

@PriyanshC
Copy link
Copy Markdown

  1. (Optionally) pass names in on construction of RemoteView
  2. Added this name field to JSON serialisers
    Then needs picking up on debug-app side with serde.

* @param debugName An identifying name
* @return A new instance of `RemoteView`
*/
def dill(debugName: String): RemoteView = RemoteView.dill(defaultAddress, Some(debugName))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This is a bit sus: there would be ambiguity with the method below if I called dill("foo"), so I think we need to be a bit more careful. I'm unsure exactly how though, thoughts?

Copy link
Copy Markdown
Author

@PriyanshC PriyanshC Dec 20, 2025

Choose a reason for hiding this comment

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

Had a bad feeling about that. Could use builder methods?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Doesn't feel particularly idiomatic... I think the debugName is the "more important" of the two, right? Perhaps we could just make dill and dillWithAddress or something?

@PriyanshC PriyanshC requested a review from j-mie6 December 20, 2025 15:45
Copy link
Copy Markdown
Owner

@j-mie6 j-mie6 left a comment

Choose a reason for hiding this comment

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

Ah I see, yeah this is probably fine. However, I would probably make it a setName method to make it clear it alters it... I'd prefer immutable with case class, but then the sessionId is already a var.

@PriyanshC
Copy link
Copy Markdown
Author

Isn't that a bit more verbose for a user by forcing multiple lines of stmts?

val view = RemoteView.dill
view.setName("..")
parser.attach(view)

@j-mie6
Copy link
Copy Markdown
Owner

j-mie6 commented Dec 21, 2025

True, but the mutation irks me a little. Perhaps we could make it do a proper copy. The issue I have is with the sessionId, which is a true variable...

@j-mie6
Copy link
Copy Markdown
Owner

j-mie6 commented Dec 21, 2025

I suppose that mutable.ListBuffer's += method returns this.type, so there is a precedent for it. But you should actually return this.type (it means that it is guaranteed to return this, gives a clearer indication of mutation happening)

@PriyanshC
Copy link
Copy Markdown
Author

Maybe an alternative to get sessionId as val- Add another app endpoint dedicated for id provisioning, which is called when constructing a RemoteView and so the returned id can be immutably set

@j-mie6
Copy link
Copy Markdown
Owner

j-mie6 commented Dec 21, 2025

Not a bad solution... that way we can switch to case class and have a happier existance.

@PriyanshC PriyanshC requested a review from j-mie6 December 22, 2025 10:03
implicit val responsePayloadRW: up.ReadWriter[NewSessionResponse] = up.macroRW[NewSessionResponse]

val response: Try[Response[Either[ResponseException[String, Exception], NewSessionResponse]]] = basicRequest
.readTimeout(ConnectionTimeout)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I assume these four lines are the same for all endpoint calls, could we factor them out into a dillRequest endpoint builder? then dillRequest.post(newSessionEndpoint).response...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not named as dillRequest since it's 'generic' to Remotes but yes 👍

// Identifies a session for the receiver
private var sessionId: Int = -1

case class RemoteView private (protected val port: Int, protected val address: String, protected val debugName: Option[String] = None) extends DebugView.Reusable with DebugView.Pauseable with DebugView.Manageable {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

should be final, shouldn't need protected val, just write port: Int, etc

def apply(userPort: Int = defaultPort, userAddress: String = defaultAddress, debugName: Option[String] = None): RemoteView = {
require(userPort <= MaxUserPort, s"Remote View port invalid : $userPort > $MaxUserPort")
require(checkIp(userAddress), s"Remote View address invalid : $userAddress")
require(debugName.forall(!_.isEmpty), "debugName should not be empty")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

_.nonEmpty

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oh lol I was searching for _.isNonEmpty 😞

* @param skipBreakpoint How many breakpoints to skip after this breakpoint (not required).
*/
private [debug] case class RemoteViewResponse(message: String, sessionId: Int, skipBreakpoint: Int = -1, newRefs: Seq[CodedRef] = Nil)
private [debug] case class RemoteViewResponse(message: String, skipBreakpoint: Int = -1, newRefs: Seq[CodedRef] = Nil)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

final case class

@PriyanshC PriyanshC requested a review from j-mie6 December 22, 2025 10:40
@j-mie6 j-mie6 merged commit 18217c4 into j-mie6:master Dec 22, 2025
12 checks passed
@j-mie6
Copy link
Copy Markdown
Owner

j-mie6 commented Dec 22, 2025

I guess we now need this to be implemented DILL side and released asap?

@PriyanshC
Copy link
Copy Markdown
Author

Yepp

@PriyanshC PriyanshC deleted the named-sessions branch December 22, 2025 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants