{"id":50878338,"url":"https://github.com/lightbend/service-locator-dns","last_synced_at":"2026-07-03T02:01:13.066Z","repository":{"id":57726163,"uuid":"69429822","full_name":"lightbend/service-locator-dns","owner":"lightbend","description":"This project is deprecated","archived":true,"fork":false,"pushed_at":"2018-05-22T15:09:37.000Z","size":85,"stargazers_count":59,"open_issues_count":4,"forks_count":19,"subscribers_count":9,"default_branch":"master","last_synced_at":"2026-01-14T17:14:16.194Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lightbend.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-28T05:45:54.000Z","updated_at":"2025-06-02T19:29:05.000Z","dependencies_parsed_at":"2022-09-17T14:31:26.972Z","dependency_job_id":null,"html_url":"https://github.com/lightbend/service-locator-dns","commit_stats":null,"previous_names":["typesafehub/service-locator-dns"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/lightbend/service-locator-dns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightbend%2Fservice-locator-dns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightbend%2Fservice-locator-dns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightbend%2Fservice-locator-dns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightbend%2Fservice-locator-dns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lightbend","download_url":"https://codeload.github.com/lightbend/service-locator-dns/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightbend%2Fservice-locator-dns/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35069183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-15T12:00:25.786Z","updated_at":"2026-07-03T02:01:13.061Z","avatar_url":"https://github.com/lightbend.png","language":"Scala","funding_links":[],"categories":["服务发现"],"sub_categories":["微服务框架"],"readme":"# Deprecation notice\n\nThis project has been deprecated in favor of Lightbend Orchestration\n\nhttps://developer.lightbend.com/docs/lightbend-orchestration/latest/index.html\n\n\n# Service Locator DNS\n\n[![Build Status](https://api.travis-ci.org/lightbend/service-locator-dns.png?branch=master)](https://travis-ci.org/lightbend/service-locator-dns)\n\n## Motivation\n\nDNS SRV is specification that describes how to locate services over the DNS protocol. Service discovery backends commonly offer DNS SRV as a protocol, and so this project leverages that capability.\n\n## Introduction\n\n[DNS SRV](https://tools.ietf.org/html/rfc2782) lookups for [Akka](http://akka.io/) and [Lagom](http://www.lagomframework.com/) which therefore includes [Mesos/Marathon](https://mesosphere.github.io/marathon/), [Kubernetes](http://kubernetes.io/) and [Consul](https://www.consul.io/) usage. This project provides two libraries:\n\n* a pure-Akka based service locator for locating services by name and returning their hosts and ports; and\n* a Lagom service locator utilizing the Akka one.\n\nThis project uses the wonderful [akka-dns](https://github.com/ilya-epifanov/akka-dns) project in order to offer non-blocking DNS lookups for SRV records.\n\n## Usage\n\nThe service locator is written using Akka and can be used directly as via its Actor. Alternatively Lagom can be configured to use this project's service locator with no additional coding for your project.\n\n### Pure Akka usage\n\nYou'll need a resolver for akka-dns:\n\n```scala\nresolvers += bintrayRepo(\"hajile\", \"maven\")\n```\n\nFor pure Akka based usage (without Lagom):\n\n```scala\nlibraryDependencies += \"com.lightbend\" %% \"service-locator-dns\" % \"2.3.0\"\n```\n\nAn example:\n\n```scala\n  // Requisite import\n  import com.lightbend.dns.locator.ServiceLocator\n  \n  // Create a service locator\n  val serviceLocator = system.actorOf(ServiceLocator.props, ServiceLocator.Name)\n  \n  // Send a request to get addresses. Expect a `ServiceLocator.Addresses` reply.\n  serviceLocator ! ServiceLocator.GetAddresses(\"_some-service._tcp.marathon.mesos\")\n```\n\n### Lagom Java usage\n\nAlternatively, when using from Lagom and Java:\n\n```scala\nlibraryDependencies += \"com.lightbend\" %% \"lagom13-java-service-locator-dns\" % \"2.3.0\"\n```\n\nSimply adding the above dependency to a Lagom project should be sufficient. There is a `ServiceLocatorModule` that will be automatically discovered by the Lagom environment. All of your Lagom service locator calls will automatically route via the service locator implementation that this project provides.\n\n### Lagom Scala usage\n\nAlternatively, when using from Lagom and Scala:\n\n```scala\nlibraryDependencies += \"com.lightbend\" %% \"lagom13-scala-service-locator-dns\" % \"2.3.0\"\n```\n\nWhen declaring your Lagom application you will also be required to mix in the `com.lightbend.lagom.scaladsl.dns.DnsServiceLocatorComponents` trait:\n\n```scala\nimport com.lightbend.lagom.scaladsl.dns.DnsServiceLocatorComponents  \n...\n\nclass LagomLoader extends LagomApplicationLoader {\n  override def load(context: LagomApplicationContext) = \n    new MyLagomApplication(context) with DnsServiceLocatorComponents\n...\n```\n\n## Advanced configuration\n\nYour platform may require differing \"transformers\" that will translate a service name\ninto a DNS SRV name to be looked up. Here is the Typesafe config declaration to be \nconsidered in its entirety.\n\n```\nservice-locator-dns {\n  # A list of translators - their order is significant. Translates a service name passed to the\n  # service locator into a name that will be used for DNS SRV resolution. Only the first match\n  # will be used. This can be easily overridden by providing a SERVICE_LOCATOR_DNS_NAME_TRANSLATORS\n  # environment variable.\n  #\n  # The default translator below should be all that is required for a DC/OS or Mesos/Marathon\n  # environment. Kubernetes DNS SRV records take the form:\n  #\n  #   _my-port-name._my-port-protocol.my-svc.my-namespace.svc.cluster.local\n  #\n  # ...which implies that your service name should provide the port name. For example with\n  # Cassandra where there are typically 3 ports (\"native\" =\u003e 9042, \"rpc\" =\u003e 9160 and \"storage\" =\u003e 7200),\n  # your service name might use a hyphen as a delim for the namespace, service name and port name e.g.\n  # \"customers-cassandra-native\". In this case your translator would look like:\n  #\n  #   \"(.*)-(.*)-(.*)\" = \"_$3._tcp.$2.$1.svc.cluster.local\"\n  #\n  # You may also want to encode the service's protocol into its name given that the caller\n  # that is interested in the service location will typically know whether it will be tcp or udp\n  # (or anything else). Taking the above example, you might then have \"customers-cassandra-native-tcp\"\n  # and translate these four components.\n  #\n  # You can of course have multiple translators though and statically declare the translations as\n  # your service's configuration (you'll be supplying environment specific configuration quite typically\n  # anyway...), and thus keep your service names nice and clean.\n  #\n  # By default though, we don't translate much i.e. we let it all pass through and put the onus on the\n  # client to specify the right service name.\n  name-translators = [\n    {\n      \"^.*$\" = \"$0\"\n    }\n  ]\n  name-translators = ${?SERVICE_LOCATOR_DNS_NAME_TRANSLATORS}\n\n  # A list of translators - their order is significant. Translates the SRV lookup name for downstream processing by\n  # the library. The name will initially be looked up (after being passed through name-translators), and then the\n  # result will be mapped according to this translation table.\n  #\n  # For example, this entry will rewrite any queries starting with _api._tcp and ensuring they become _api._http\n  #\n  # \"^_api[.]_tcp[.](.+)$\" = \"_api.http.$1\",\n  #\n  # By default, we don't transluate i.e. we let it all pass through.\n  srv-translators = [\n    {\n      \"^.*$\" = \"$0\"\n    }\n  ]\n  srv-translators = ${?SERVICE_LOCATOR_DNS_SRV_TRANSLATORS}\n\n  # The amount of time to wait for a DNS resolution to occur for the first and second lookups of a given\n  # name.\n  resolve-timeout1 = 1 second\n\n  # The amount of time to wait for a DNS resolution to occur for the third lookup of a given\n  # name.\n  resolve-timeout2 = 2 seconds\n}\n```\n\n## Maintenance\n\nEnterprise Suite Platform Team \u003ces-platform@lightbend.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flightbend%2Fservice-locator-dns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flightbend%2Fservice-locator-dns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flightbend%2Fservice-locator-dns/lists"}