--
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/91c7ed55-adf1-4b19-bc67-bb73ea71948a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Here are some answers to your questions about external service modelling:1 - Suppose a sub project api that declare a service is made, do I have to use namedCall, pathCall or restCall identifier ?
namedCall,pathCallandrestCallare just different ways to specify the same thing, ultimately. From left to right, they go from more abstract with less control to more concrete and specific.restCallis the most powerful and specific: anything you can declare withnamedCallandpathCallcan also be declared withrestCall. When in doubt, userestCall.They're all described in detail at https://www.lagomframework.com/documentation/1.3.x/scala/ServiceDescriptors.html#Call-identifiers.
In this situation, you aren't deciding on paths, you are specifying the ones actually used by the external service.A Lagom Service interface is a way of describing how to use a REST API to clients. When you build a Lagom service, you use a Service interface to describe it, so that Lagom can dynamically generate a client. What we're doing here is using a Lagom Service interface to describe a third-party service that isn't built in Lagom. Lagom can still use that interface on the client to dynamically generate a client.and in the case of path what is the linked between the external services url and the path I decide (is there one ?).
To put this another way: there are two ways to write any kind of specification. You can write the spec first and the build the implementation from the spec. This is what you usually do when building a Lagom service. Alternatively, you could build the implementation first and then reverse engineer a specification from it. This is effectively what you're doing when you integrate a non-Lagom service into Lagom.
If I used named call, how do I specify the method of the external services (GET, POST...) ?
If you don't use
restCall, the method is guessed from the request type of the service call: if it'sNotUsed,GET; otherwisePOST.2 - The external services is declared in sbt build.sbt file. How do I bind the given name of the service when the declaration is done to my api service call ?
External services are declared as a map of name -> URL. The name is the one declared in the Service Descriptor
named("someName").
trait WebComponentService extends Service {
def send_abstract_stimuli: ServiceCall[AbstractStimuli, NotUsed]
def send_behavior_3s: ServiceCall[BehavioralState, NotUsed]
override final def descriptor = {
import Service._
named("web-component").withCalls(
restCall(Method.POST, "/abstract/stimuli", send_abstract_stimuli),
restCall(Method.POST, "/behavior/3s", send_behavior_3s)
)
}
}
lagomUnmanagedServices in ThisBuild := Map(
"web-component" -> "http://localhost:9000"
)
abstract class xxxxxApplication(context: LagomApplicationContext)
extends LagomApplication(context)
with AhcWSComponents {
// Bind the services that this server provides
override lazy val lagomServer = LagomServer.forServices(
//.. some server binding ...
)
lazy val webComponentService = serviceClient.implement[WebComponentService]
// ... some other lazy val serviceClient declaration ...
}