Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains a client library for communicating with the 'legion-discovery' service discovery program.
- connect :: Name -> Version -> Set ServiceAddr -> Manager -> IO Discovery
- query :: Name -> VersionRange -> Discovery -> IO (Set ServiceAddr)
- withService :: ServiceAddr -> Discovery -> IO a -> IO a
- newLB :: Discovery -> Name -> VersionRange -> IO LBHttp
- withResponse :: Request -> LBHttp -> (Maybe (Response BodyReader) -> IO a) -> IO a
- data LBHttp
- data Discovery
- newtype Name = Name {}
- newtype ServiceAddr = ServiceAddr {}
Establishing a Connection.
:: Name | The name of the local program. This is used to track and display a network graph of service dependencies. |
-> Version | The version of the local program. |
-> Set ServiceAddr | The well-known set of urls where the discovery service lives. |
-> Manager | The http manager used to manage communication to the discovery
service, and also for communication with any services accessed
via the |
-> IO Discovery |
Create a connection to the discovery service.
Performing Queries.
:: Name | The name of the service you are looking for. |
-> VersionRange | The range of service versions with which you are compatible. |
-> Discovery | A handle on the discovery service. |
-> IO (Set ServiceAddr) |
Query the discovery service.
Registering a Service.
:: ServiceAddr | The service address on which your service instance can be contacted. |
-> Discovery | A handle on the discovery service, obtained via |
-> IO a | The IO action to perform while registered as a service. |
-> IO a |
Run a registered service, making sure to unregister upon ternination.
HTTP Utilities.
:: Discovery | A handle on the discovery service, obtained via |
-> Name | The name of the target service. |
-> VersionRange | The range of service versions with which you are compatible. |
-> IO LBHttp | Returns a load balanced http client, for use with |
Create a new load balanced http client, for use with withResponse
.
withResponse :: Request -> LBHttp -> (Maybe (Response BodyReader) -> IO a) -> IO a Source #
Analog of withResponse
, but automatically replaces the host, port,
and scheme portions of the Request
with values obtained from the
load balancer.
If a Nothing
value is passed to the response handler, that means
that there are no available instances that match the query params that were
passed to newLB
.
Other Types.
newtype ServiceAddr Source #
The type of a service address.
A ServiceAddr
is a wrapper around an unstructured text value. The
meaning of the text value is dependent on the registered service,
as it is the one responsible for publishing the service address. We
highly recommend that registered services choose to publish a
fully qualified URL as their service address.