-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #345 from scalacenter/topic/cancel-gracefully
Redesign file watching and add client listeners
- Loading branch information
Showing
16 changed files
with
250 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package bloop.engine | ||
|
||
import com.martiansoftware.nailgun.{NGClientDisconnectReason, NGClientListener, NGContext} | ||
|
||
sealed trait CloseEvent | ||
case object Heartbeat extends CloseEvent | ||
case object SocketError extends CloseEvent | ||
case object SocketTimeout extends CloseEvent | ||
case object SessionShutdown extends CloseEvent | ||
case object InternalError extends CloseEvent | ||
|
||
sealed trait ClientPool { | ||
def addListener(f: CloseEvent => Unit): Unit | ||
def removeAllListeners(): Unit | ||
} | ||
|
||
case object NoPool extends ClientPool { | ||
override def addListener(f: CloseEvent => Unit): Unit = () | ||
override def removeAllListeners(): Unit = () | ||
} | ||
|
||
case class NailgunPool(context: NGContext) extends ClientPool { | ||
override def addListener(f: CloseEvent => Unit): Unit = { | ||
context.addClientListener(new NGClientListener { | ||
override def clientDisconnected(reason: NGClientDisconnectReason): Unit = { | ||
f(reason match { | ||
case NGClientDisconnectReason.HEARTBEAT => Heartbeat | ||
case NGClientDisconnectReason.SOCKET_ERROR => SocketError | ||
case NGClientDisconnectReason.SOCKET_TIMEOUT => SocketTimeout | ||
case NGClientDisconnectReason.SESSION_SHUTDOWN => SessionShutdown | ||
case NGClientDisconnectReason.INTERNAL_ERROR => InternalError | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
override def removeAllListeners(): Unit = context.removeAllClientListeners() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.