Class

com.lightbend.lagom.scaladsl.client

LagomClientFactory

Related Doc: package client

Permalink

abstract class LagomClientFactory extends LagomServiceClientComponents with LagomConfigComponent

Convenience for constructing service clients in a non Lagom server application.

LagomClientFactory should be used only if your application DO have its own akka.actor.ActorSystem and Akka Streams akka.stream.Materializer, in which case you should reuse then when building a LagomClientFactory.

The easiest way to reuse your existing akka.actor.ActorSystem and Akka Stream akka.stream.Materializer is to extend the LagomClientFactory and add a constructor where you can pass them as arguments (see example below).

There is one more component that you’ll need to provide when creating a LagomClientFactory, that is a service locator. It is up to you what service locator you use, it could be a third party service locator, or a service locator created from static configuration.

Lagom provides a number of built-in service locators, including a StaticServiceLocator, a RoundRobinServiceLocator and a ConfigurationServiceLocator. The easiest way to use these is to mix in their respective Components traits.

For example, here’s a client factory built using the static service locator, which uses a static URI, and reusing an akka.actor.ActorSystem and Akka Streams akka.stream.Materializer created outside it:

import java.net.URI
import com.lightbend.lagom.scaladsl.client._
import play.api.libs.ws.ahc.AhcWSComponents

class MyLagomClientFactory(val actorSystem: ActorSystem, val materialzer: Materializer)
  extends LagomClientFactory("my-client")
  with StaticServiceLocatorComponents
  with AhcWSComponents {

  override def staticServiceUri = URI.create("http://localhost:8080")
}


val actorSystem = ActorSystem("my-app")
val materializer = ActorMaterializer()(actorSystem)
val clientFactory = new MyLagomClientFactory(actorSystem, materializer)
Source
ServiceClient.scala
Linear Supertypes
LagomConfigComponent, LagomServiceClientComponents, TopicFactoryProvider, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. LagomClientFactory
  2. LagomConfigComponent
  3. LagomServiceClientComponents
  4. TopicFactoryProvider
  5. AnyRef
  6. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new LagomClientFactory(clientName: String, classLoader: ClassLoader = ...)

    Permalink

    clientName

    The name of the service that is consuming the Lagom service. This will impact how calls made through clients generated by this factory will identify themselves.

    classLoader

    A classloader, it will be used to create the service proxy and needs to have the API for the client in it.

Abstract Value Members

  1. abstract def actorSystem: ActorSystem

    Permalink
    Definition Classes
    LagomServiceClientComponents
  2. abstract def materializer: Materializer

    Permalink
    Definition Classes
    LagomServiceClientComponents
  3. abstract def serviceLocator: ServiceLocator

    Permalink
    Definition Classes
    LagomServiceClientComponents
  4. abstract def wsClient: WSClient

    Permalink
    Definition Classes
    LagomServiceClientComponents

Concrete Value Members

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from LagomClientFactory to any2stringadd[LagomClientFactory] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (LagomClientFactory, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from LagomClientFactory to ArrowAssoc[LagomClientFactory] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. lazy val applicationLifecycle: ApplicationLifecycle

    Permalink
  7. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  8. lazy val circuitBreakerMetricsProvider: CircuitBreakerMetricsProvider

    Permalink
    Definition Classes
    LagomServiceClientComponents
  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. def config: Config

    Permalink
    Definition Classes
    LagomConfigComponent
  11. lazy val configuration: Configuration

    Permalink
    Definition Classes
    LagomClientFactory → LagomConfigComponent
  12. lazy val defaultExceptionSerializer: ExceptionSerializer

    Permalink
    Definition Classes
    LagomServiceClientComponents
  13. def ensuring(cond: (LagomClientFactory) ⇒ Boolean, msg: ⇒ Any): LagomClientFactory

    Permalink
    Implicit information
    This member is added by an implicit conversion from LagomClientFactory to Ensuring[LagomClientFactory] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: (LagomClientFactory) ⇒ Boolean): LagomClientFactory

    Permalink
    Implicit information
    This member is added by an implicit conversion from LagomClientFactory to Ensuring[LagomClientFactory] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: Boolean, msg: ⇒ Any): LagomClientFactory

    Permalink
    Implicit information
    This member is added by an implicit conversion from LagomClientFactory to Ensuring[LagomClientFactory] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. def ensuring(cond: Boolean): LagomClientFactory

    Permalink
    Implicit information
    This member is added by an implicit conversion from LagomClientFactory to Ensuring[LagomClientFactory] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. lazy val environment: Environment

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  20. lazy val executionContext: ExecutionContext

    Permalink
  21. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  22. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from LagomClientFactory to StringFormat[LagomClientFactory] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  23. final def getClass(): Class[_]

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

    Permalink
    Definition Classes
    AnyRef → Any
  25. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  26. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  27. final def notify(): Unit

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

    Permalink
    Definition Classes
    AnyRef
  29. def optionalTopicFactory: Option[TopicFactory]

    Permalink
    Definition Classes
    TopicFactoryProvider
  30. final def releaseInternalResources(): Future[Done]

    Permalink

    Releases the internal resources manages by this LagomClientFactory.

    Releases the internal resources manages by this LagomClientFactory.

    Attributes
    protected
  31. lazy val scaladslWebSocketClient: ScaladslWebSocketClient

    Permalink
    Definition Classes
    LagomServiceClientComponents
  32. lazy val serviceClient: ServiceClient

    Permalink
    Definition Classes
    LagomServiceClientComponents
  33. lazy val serviceInfo: ServiceInfo

    Permalink
  34. lazy val serviceResolver: ServiceResolver

    Permalink
    Definition Classes
    LagomServiceClientComponents
  35. def stop(): Unit

    Permalink

    Override this method if your LagomClientFactory implementation needs to free any resource.

    Override this method if your LagomClientFactory implementation needs to free any resource.

    For example, when implementing your own LagomClientFactory, you may choose to reuse an existing akka.actor.ActorSystem, but use a internal akka.stream.Materializer. In which case, you can use this method to only shutdown the akka.stream.Materializer.

    If you override this method, make sure you also release the internally managed resources by calling #releaseInternalResources() method.

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

    Permalink
    Definition Classes
    AnyRef
  37. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  38. def topicPublisherName: Option[String]

    Permalink
    Definition Classes
    TopicFactoryProvider
  39. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. def [B](y: B): (LagomClientFactory, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from LagomClientFactory to ArrowAssoc[LagomClientFactory] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from LagomConfigComponent

Inherited from TopicFactoryProvider

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from LagomClientFactory to any2stringadd[LagomClientFactory]

Inherited by implicit conversion StringFormat from LagomClientFactory to StringFormat[LagomClientFactory]

Inherited by implicit conversion Ensuring from LagomClientFactory to Ensuring[LagomClientFactory]

Inherited by implicit conversion ArrowAssoc from LagomClientFactory to ArrowAssoc[LagomClientFactory]

Ungrouped