legion-discovery-client: Client library for communicating with legion-discovery.

[ apache, deprecated, library, web ] [ Propose Tags ]
Deprecated

Please see README.md


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.1.0, 0.1.1.1, 0.2.0.1
Dependencies aeson (>=0.11.2.1 && <1.2), base (>=4.7 && <4.10), bytestring (>=0.10.6.0 && <0.11), Cabal (>=1.22.5.0 && <1.25), containers (>=0.5.6.2 && <0.6), http-client (>=0.5.6.1 && <0.6), http-types (>=0.9.1 && <0.10), load-balancing (>=1.0 && <1.1), monad-logger (>=0.3.20.2 && <0.4), resourcet (>=1.1.7.5 && <1.2), safe-exceptions (>=0.1.4.0 && <0.2), text (>=1.2.2.1 && <1.3), text-show (>=3.4.1.1 && <3.7), transformers (>=0.4.2.0 && <0.6) [details]
License Apache-2.0
Copyright 2016 Rick Owens
Author Rick Owens
Maintainer rick@owensmurray.com
Category Web
Home page https://github.com/owensmurray/legion-discovery-client#readme
Source repo head: git clone https://github.com/owensmurray/legion-discovery-client
Uploaded by taphu at 2017-08-13T15:43:25Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 4210 total (16 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for legion-discovery-client-0.2.0.1

[back to package description]

legion-discovery-client

This is a Haskell client library used to communicate with the Legion Discovery discovery service.

Performing a query without registering a service.

If you want to perform a query without registering yourself a service, the following example is how you might typically accomplish that. Note that even though you are not starting a service, you must still specify a name and a version for the local program. The reason for this is that Legion Discovery keeps track of all requests in order to build a dependency graph of your service ecosystem.

import Network.HTTP.Client as C
import OM.Discovery (connect, query)

...

let
  name = "my-program" {- the name of this client program. -}
  version = "0.1" {- the version of this client program.  -}
  targetService = "some-service" {- the name of the service you are looking for. -}
  targetRange = "> 1.1.1 && < 1.2" {- the range of acceptable versions you wish to find. -}
in do
  manager <- C.newManager C.defaultManagerSettings
  discovery <- connect name version manager

  servicesInstances <- query targetService targetRange discovery
  ...

Registering a service.

The following example shows how to register a service, using withService.

import Network.HTTP.Client as C
import OM.Discovery (connect, withService)

...

let
  name = "my-program" {- the name of this client program. -}
  version = "0.1" {- the version of this client program.  -}
  serviceAddr = "http://ec2-foo-bar.amazon.com:8080" {- the address on which your service is running. -}
in do
  manager <- C.newManager C.defaultManagerSettings
  discovery <- connect name version manager

  withService serviceAddr discovery $ do
    {-
      Your service code here. When this IO block exits (for any reason,
      including exceptions) then the service will unregister itself.
    -}