Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

com.twitter.admin.Service <= ServerBuilder

  • Loading branch information...
commit 89ac034d934f6d492771b564b8869768c08586cd 1 parent 8b2a3c9
@mariusae mariusae authored
View
29 finagle-ostrich3/src/main/scala/com/twitter/finagle/builder/ServerBuilderToTwitterService.scala
@@ -0,0 +1,29 @@
+package com.twitter.finagle.builder
+
+/**
+ * Make a com.twitter.admin.Service from a finagle ServerBuilder.
+ */
+
+import com.twitter.admin
+import com.twitter.util.Duration
+import com.twitter.conversions.time._
+
+import com.twitter.finagle.Service
+
+class ServerBuildertoTwitterService[Req, Rep](
+ builder: ServerBuilder[Req, Rep],
+ service: Service[Req, Rep],
+ gracePeriod: Duration = 10.seconds)
+ extends admin.Service
+{
+ private[this] var server: Option[Server] = None
+
+ def start() {
+ if (!server.isDefined)
+ server = Some(builder.build(service))
+ }
+
+ def shutdown() {
+ server foreach { _.close(gracePeriod) }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.