com.twitter.finagle.builder

ServerBuilder

class ServerBuilder[Req, Rep, HasCodec, HasBindTo, HasName] extends AnyRef

A handy Builder for constructing Servers (i.e., binding Services to a port). This class is subclassable. Override copy() and build() to do your own dirty work.

The main class to use is com.twitter.finagle.builder.ServerBuilder, as so

ServerBuilder()
.codec(Http)
.hostConnectionMaxLifeTime(5.minutes)
.readTimeout(2.minutes)
.name("servicename")
.bindTo(new InetSocketAddress(serverPort))
.build(plusOneService)

The ServerBuilder requires the definition of codec, bindTo and name. In Scala, these are statically type checked, and in Java the lack of any of the above causes a runtime error.

The build method uses an implicit argument to statically typecheck the builder (to ensure completeness, see above). The Java compiler cannot provide such implicit, so we provide a separate function in Java to accomplish this. Thus, the Java code for the above is

ServerBuilder.safeBuild(
plusOneService,
ServerBuilder.get()
 .codec(Http)
 .hostConnectionMaxLifeTime(5.minutes)
 .readTimeout(2.minutes)
 .name("servicename")
 .bindTo(new InetSocketAddress(serverPort)));

Alternatively, using the unsafeBuild method on ServerBuilder verifies the builder dynamically, resulting in a runtime error instead of a compiler error.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ServerBuilder
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. type FullySpecifiedConfig = ServerConfig[Req, Rep, Yes, Yes, Yes]

  2. type This = ServerBuilder[Req, Rep, HasCodec, HasBindTo, HasName]

  3. type ThisConfig = ServerConfig[Req, Rep, HasCodec, HasBindTo, HasName]

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def backlog(value: Int): This

  8. def bindTo(address: SocketAddress): ServerBuilder[Req, Rep, HasCodec, Yes, HasName]

  9. def build(serviceFactory: ServiceFactory[Req, Rep])(implicit THE_BUILDER_IS_NOT_FULLY_SPECIFIED_SEE_ServerBuilder_DOCUMENTATION: ServerConfigEvidence[HasCodec, HasBindTo, HasName]): Server

    Construct the Server, given the provided ServiceFactory.

    Construct the Server, given the provided ServiceFactory. This is useful if the protocol is stateful (e.g., requires authentication or supports transactions).

  10. def build(service: Service[Req, Rep])(implicit THE_BUILDER_IS_NOT_FULLY_SPECIFIED_SEE_ServerBuilder_DOCUMENTATION: ServerConfigEvidence[HasCodec, HasBindTo, HasName]): Server

    Construct the Server, given the provided Service.

  11. def cancelOnHangup(yesOrNo: Boolean): This

    Cancel pending futures whenever the the connection is shut down.

    Cancel pending futures whenever the the connection is shut down. This defaults to true.

  12. def channelFactory(cf: ServerChannelFactory): This

  13. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  14. def codec[Req1, Rep1](codecFactory: CodecFactory[Req1, Rep1]): ServerBuilder[Req1, Rep1, Yes, HasBindTo, HasName]

  15. def codec[Req1, Rep1](codecFactory: (ServerCodecConfig) ⇒ Codec[Req1, Rep1]): ServerBuilder[Req1, Rep1, Yes, HasBindTo, HasName]

  16. def codec[Req1, Rep1](codec: Codec[Req1, Rep1]): ServerBuilder[Req1, Rep1, Yes, HasBindTo, HasName]

  17. val config: ServerConfig[Req, Rep, HasCodec, HasBindTo, HasName]

  18. def copy[Req1, Rep1, HasCodec1, HasBindTo1, HasName1](config: ServerConfig[Req1, Rep1, HasCodec1, HasBindTo1, HasName1]): ServerBuilder[Req1, Rep1, HasCodec1, HasBindTo1, HasName1]

    Attributes
    protected
  19. def daemon(daemonize: Boolean): This

    When true, the server is daemonized.

    When true, the server is daemonized. As with java threads, a process can only exit only when all remaining servers are daemonized. False by default.

  20. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  21. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  22. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  23. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  24. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  25. def hostConnectionMaxIdleTime(howlong: Duration): This

  26. def hostConnectionMaxLifeTime(howlong: Duration): This

  27. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  28. def keepAlive(value: Boolean): This

  29. def logChannelActivity(v: Boolean): This

  30. def logger(logger: Logger): This

  31. def maxConcurrentRequests(max: Int): This

  32. def monitor(mFactory: (String, SocketAddress) ⇒ Monitor): This

  33. def name(value: String): ServerBuilder[Req, Rep, HasCodec, HasBindTo, Yes]

  34. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  35. def newFinagleSslEngine(v: () ⇒ Engine): This

  36. def newSslEngine(newSsl: () ⇒ SSLEngine): This

    Provide a raw SSL engine that is used to establish SSL sessions.

  37. final def notify(): Unit

    Definition Classes
    AnyRef
  38. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  39. def openConnectionsThresholds(thresholds: OpenConnectionsThresholds): This

  40. def readTimeout(howlong: Duration): This

  41. def recvBufferSize(value: Int): This

  42. def reportTo(receiver: StatsReceiver): This

  43. def requestTimeout(howlong: Duration): This

  44. def sendBufferSize(value: Int): This

  45. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  46. def tls(certificatePath: String, keyPath: String, caCertificatePath: String = null, ciphers: String = null, nextProtos: String = null): This

  47. def toString(): String

    Definition Classes
    ServerBuilder → AnyRef → Any
  48. def tracer(t: Tracer): This

  49. def unsafeBuild(service: Service[Req, Rep]): Server

    Construct a Service, with runtime checks for builder completeness.

  50. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  51. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  52. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  53. def withConfig[Req1, Rep1, HasCodec1, HasBindTo1, HasName1](f: (ServerConfig[Req, Rep, HasCodec, HasBindTo, HasName]) ⇒ ServerConfig[Req1, Rep1, HasCodec1, HasBindTo1, HasName1]): ServerBuilder[Req1, Rep1, HasCodec1, HasBindTo1, HasName1]

    Attributes
    protected
  54. def writeCompletionTimeout(howlong: Duration): This

Deprecated Value Members

  1. def build(serviceFactory: ServiceFactory[Req, Rep], THE_BUILDER_IS_NOT_FULLY_SPECIFIED_SEE_ServerBuilder_DOCUMENTATION: =:=[ThisConfig, FullySpecifiedConfig]): Server

    Annotations
    @deprecated
    Deprecated

    (Since version 5.0.1) Used for ABI compat

  2. def build(serviceFactory: (ClientConnection) ⇒ Service[Req, Rep])(implicit THE_BUILDER_IS_NOT_FULLY_SPECIFIED_SEE_ServerBuilder_DOCUMENTATION: =:=[ThisConfig, FullySpecifiedConfig]): Server

    Construct the Server, given the provided ServiceFactory.

    Construct the Server, given the provided ServiceFactory. This is useful if the protocol is stateful (e.g., requires authentication or supports transactions).

    Annotations
    @deprecated
    Deprecated

    (Since version 5.0.1) Use the ServiceFactory variant instead

  3. def build(serviceFactory: () ⇒ Service[Req, Rep])(implicit THE_BUILDER_IS_NOT_FULLY_SPECIFIED_SEE_ServerBuilder_DOCUMENTATION: =:=[ThisConfig, FullySpecifiedConfig]): Server

    Construct the Server, given the provided Service factory.

    Construct the Server, given the provided Service factory.

    Annotations
    @deprecated
    Deprecated

    (Since version 5.0.1) Use the ServiceFactory variant instead

  4. def build(service: Service[Req, Rep], THE_BUILDER_IS_NOT_FULLY_SPECIFIED_SEE_ServerBuilder_DOCUMENTATION: =:=[ThisConfig, FullySpecifiedConfig]): Server

    Annotations
    @deprecated
    Deprecated

    (Since version 5.0.1) Used for ABI compat

  5. def tracerFactory(t: Tracer): This

    Annotations
    @deprecated
    Deprecated

    (Since version 7.0.0) Use tracer() instead

  6. def tracerFactory(factory: () ⇒ Tracer): This

    Annotations
    @deprecated
    Deprecated

    (Since version 7.0.0) Use tracer() instead

Inherited from AnyRef

Inherited from Any

Ungrouped