Search code examples
scalamicroservicesreactivelagom

Name call in lagom service call?


I am starting lagom and going through the doc and found this sample code :

named("hello").withCalls(
  namedCall("hello", sayHello)
)

And when implemented using REST, it says this call will have a path of /hello.

Now the question is , /hello refers to which hello, first "hello" in named("hello") or second hello in namedCall("hello") and does this both "hello" name should have to be same ?


Solution

  • The first hello is a name for the service. When a client looks up the service, it will use that name, passing it to the ServiceLocator, which, depending on its implementation, may translate it to a DNS lookup, or something similar.

    The second hello refers to the /hello path.

    They certainly do not have to be the same. This would also work:

    named("hello").withCalls(
      namedCall("sayHello", sayHello)
    )
    

    In that case, the path would be /sayHello.