Class/Object

com.twitter.finagle.builder

ServerBuilder

Related Docs: object ServerBuilder | package builder

Permalink

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.

Defaults

The following defaults are applied to servers constructed via ServerBuilder, unless overridden with the corresponding method. These defaults were chosen carefully so as to work well for most use cases. Before changing any of them, make sure that you know exactly how they will affect your application -- these options are typically only changed by expert users.

- openConnectionsThresholds: None - maxConcurrentRequests: Int.MaxValue - backlog: OS-defined default value

Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ServerBuilder
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

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

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

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

    Permalink

Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

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

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

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

    Permalink

    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).

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

    Permalink

    Construct the Server, given the provided Service.

  9. def cancelOnHangup(yesOrNo: Boolean): This

    Permalink

    Cancel pending futures whenever the the connection is shut down.

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

  10. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. def codec[Req1, Rep1](codecFactory: (ServerCodecConfig) ⇒ Codec[Req1, Rep1]): ServerBuilder[Req1, Rep1, Yes, HasBindTo, HasName]

    Permalink
  12. def codec[Req1, Rep1](codecFactory: CodecFactory[Req1, Rep1]): ServerBuilder[Req1, Rep1, Yes, HasBindTo, HasName]

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

    Permalink
  14. def configured[P, HasCodec1, HasBindTo1, HasName1](param: P)(implicit arg0: Param[P]): ServerBuilder[Req, Rep, HasCodec1, HasBindTo1, HasName1]

    Permalink
    Attributes
    protected
  15. def copy[Req1, Rep1, HasCodec1, HasBindTo1, HasName1](ps: Params, newServer: (Params) ⇒ finagle.Server[Req1, Rep1]): ServerBuilder[Req1, Rep1, HasCodec1, HasBindTo1, HasName1]

    Permalink
    Attributes
    protected
  16. def daemon(daemonize: Boolean): This

    Permalink

    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.

  17. def enableAdmissionControl(enable: Boolean): This

    Permalink

    Configure admission control filters in the server Stack.

    Configure admission control filters in the server Stack.

    See also

    com.twitter.finagle.filter.ServerAdmissionControl

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  20. def exceptionCategorizer(exceptionStatsHandler: ExceptionStatsHandler): This

    Permalink

    Provide an alternative to putting all request exceptions under a "failures" stat.

    Provide an alternative to putting all request exceptions under a "failures" stat. Typical implementations may report any cancellations or validation errors separately so success rate considers only valid non cancelled requests.

    exceptionStatsHandler

    function to record failure details.

  21. def finalize(): Unit

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

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

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

    Permalink
  25. def hostConnectionMaxLifeTime(howlong: Duration): This

    Permalink
  26. final def isInstanceOf[T0]: Boolean

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

    Permalink
  28. def logChannelActivity(v: Boolean): This

    Permalink
  29. def logger(logger: Logger): This

    Permalink
  30. def maxConcurrentRequests(max: Int): This

    Permalink

    Configures the maximum concurrent requests that are admitted by the server at any given time.

    Configures the maximum concurrent requests that are admitted by the server at any given time. If the server receives a burst of traffic that exceeds this limit, the burst is rejected with a Failure.Rejected exception. Note, this failure signals a graceful rejection which is transmitted to clients by certain protocols in Finagle (e.g. Http, ThriftMux).

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

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

    Permalink
  33. final def ne(arg0: AnyRef): Boolean

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

    Permalink
  35. def newSslEngine(newSsl: () ⇒ SSLEngine): This

    Permalink

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

  36. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  37. final def notifyAll(): Unit

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

    Permalink
  39. val params: Params

    Permalink
  40. def readTimeout(howlong: Duration): This

    Permalink
  41. def recvBufferSize(value: Int): This

    Permalink
  42. def reportTo(receiver: StatsReceiver): This

    Permalink
  43. def requestTimeout(howlong: Duration): This

    Permalink
  44. def sendBufferSize(value: Int): This

    Permalink
  45. def stack[Req1, Rep1](server: StackBasedServer[Req1, Rep1]): ServerBuilder[Req1, Rep1, Yes, HasBindTo, HasName]

    Permalink

    Overrides the stack and com.twitter.finagle.Server that will be used by this builder.

    Overrides the stack and com.twitter.finagle.Server that will be used by this builder.

    server

    A StackBasedServer representation of a com.twitter.finagle.Server. server is materialized with the state of configuration when build is called. There is no guarantee that all builder parameters will be used by the resultant Server; it is up to the discretion of server itself and the protocol implementation.

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

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

    Permalink
  48. def toString(): String

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

    Permalink
  50. def trafficClass(value: Option[Int]): This

    Permalink

    Configures the traffic class.

    Configures the traffic class.

    See also

    Listener.TrafficClass

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

    Permalink

    Construct a Service, with runtime checks for builder completeness.

  52. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  55. def writeCompletionTimeout(howlong: Duration): This

    Permalink

Deprecated Value Members

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

    Permalink
    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

    Permalink

    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

    Permalink

    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

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 5.0.1) Used for ABI compat

  5. def channelFactory(cf: ServerChannelFactory): This

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 2015-11-18) use com.twitter.finagle.netty3.numWorkers flag instead

  6. def stack[Req1, Rep1](mk: (Params) ⇒ finagle.Server[Req1, Rep1]): ServerBuilder[Req1, Rep1, Yes, HasBindTo, HasName]

    Permalink

    Overrides the stack and com.twitter.finagle.Server that will be used by this builder.

    Overrides the stack and com.twitter.finagle.Server that will be used by this builder.

    mk

    A function that materializes a Server from a set of Params. mk is passed the state of configuration when build is called. There is no guarantee that all the builder parameters will be used by the server created by mk; it is up to the discretion of the server and protocol implementation.

    Annotations
    @deprecated
    Deprecated

    (Since version 7.0.0) Use stack(server: StackBasedServer)

  7. def tracerFactory(t: Tracer): This

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 7.0.0) Use tracer() instead

  8. def tracerFactory(factory: Factory): This

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 7.0.0) Use tracer() instead

Inherited from AnyRef

Inherited from Any

Ungrouped