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
- Alphabetic
- By Inheritance
- LagomClientFactory
- LagomConfigComponent
- LagomServiceClientComponents
- TopicFactoryProvider
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
LagomClientFactory(clientName: String, classLoader: ClassLoader = ...)
- 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
-
abstract
def
actorSystem: ActorSystem
- Definition Classes
- LagomServiceClientComponents
-
abstract
def
materializer: Materializer
- Definition Classes
- LagomServiceClientComponents
-
abstract
def
serviceLocator: ServiceLocator
- Definition Classes
- LagomServiceClientComponents
-
abstract
def
wsClient: WSClient
- Definition Classes
- LagomServiceClientComponents
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
+(other: String): String
- Implicit
- This member is added by an implicit conversion from LagomClientFactory to any2stringadd[LagomClientFactory] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
-
def
->[B](y: B): (LagomClientFactory, B)
- Implicit
- 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()
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
lazy val
applicationLifecycle: ApplicationLifecycle
- Definition Classes
- LagomClientFactory → LagomServiceClientComponents
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
lazy val
circuitBreakerMetricsProvider: CircuitBreakerMetricsProvider
- Definition Classes
- LagomServiceClientComponents
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
config: Config
- Definition Classes
- LagomConfigComponent
-
lazy val
configuration: Configuration
- Definition Classes
- LagomClientFactory → LagomConfigComponent
-
lazy val
defaultExceptionSerializer: ExceptionSerializer
- Definition Classes
- LagomServiceClientComponents
-
def
ensuring(cond: (LagomClientFactory) ⇒ Boolean, msg: ⇒ Any): LagomClientFactory
- Implicit
- This member is added by an implicit conversion from LagomClientFactory to Ensuring[LagomClientFactory] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: (LagomClientFactory) ⇒ Boolean): LagomClientFactory
- Implicit
- This member is added by an implicit conversion from LagomClientFactory to Ensuring[LagomClientFactory] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean, msg: ⇒ Any): LagomClientFactory
- Implicit
- This member is added by an implicit conversion from LagomClientFactory to Ensuring[LagomClientFactory] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean): LagomClientFactory
- Implicit
- This member is added by an implicit conversion from LagomClientFactory to Ensuring[LagomClientFactory] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
lazy val
environment: Environment
- Definition Classes
- LagomClientFactory → LagomServiceClientComponents
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
lazy val
executionContext: ExecutionContext
- Definition Classes
- LagomClientFactory → LagomServiceClientComponents
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
formatted(fmtstr: String): String
- Implicit
- 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()
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
optionalTopicFactory: Option[TopicFactory]
- Definition Classes
- TopicFactoryProvider
-
final
def
releaseInternalResources(): Future[Done]
Releases the internal resources manages by this LagomClientFactory.
Releases the internal resources manages by this LagomClientFactory.
- Attributes
- protected
-
lazy val
scaladslWebSocketClient: ScaladslWebSocketClient
- Definition Classes
- LagomServiceClientComponents
-
lazy val
serviceClient: ServiceClient
- Definition Classes
- LagomServiceClientComponents
-
lazy val
serviceInfo: ServiceInfo
- Definition Classes
- LagomClientFactory → LagomServiceClientComponents
-
lazy val
serviceResolver: ServiceResolver
- Definition Classes
- LagomServiceClientComponents
-
def
stop(): Unit
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.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
topicPublisherName: Option[String]
The name of the topic publisher.
The name of the topic publisher.
Since topic publishers don't actually provide any components, they just consume a LagomServer and publish the topics they find there, this can be used to signal that a topic publisher has been provided to publish topics, so that the LagomServerComponents can detect a misconfiguration where one hasn't been provided.
- returns
The name of the topic publisher that has published topics, if one has been provided.
- Definition Classes
- TopicFactoryProvider
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
→[B](y: B): (LagomClientFactory, B)
- Implicit
- This member is added by an implicit conversion from LagomClientFactory to ArrowAssoc[LagomClientFactory] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc