Skip to content

Implement build target change notifications #684

Open
@jvican

Description

@jvican

Build target notifications are a BSP mechanism to notify the client the server has updated one of its project models and it has to update it accordingly. For example, whenever a new dependency is added to a project in a build tool, the client needs to know about it to index it and can get the notifications to start that process as soon as it's known by the BSP server. It is IMO one of the most importants features in the BSP protocol as it heavily improves the communication between client and server and allows instant and incremental reloads.

Bloop has to provide these build target notifications. This is a ticket to register my thoughts on how we can implement them in our current architecture.

I propose that whenever a BSP session is started, we start a task a long-running task that would file watch on all the JSON configuration files under the configuration directory (typically .bloop). The idea is that this talk will have a reference to the client so that it can push notifications on file change.

As we don't want to bother the client when a file change happens and doesn't modify anything, we should use all the machinery we have in Build.checkForChange to only update those configuration files that really changed (checkForChange hashes the contents to figure that out):

https://github.com/scalacenter/bloop/blob/master/frontend/src/main/scala/bloop/engine/Build.scala#L20-L62

After we recycle some of this logic, we should be in a solid position to provide build target change notifications reliably. There is however one missing piece: we need to properly cancel the file watcher whenever there has been a fatal error in the connection or the connection has ended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    build serverAny issue or pull request that has to do with hot compilers or BSP.feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions