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

Safe HaskellNone
LanguageHaskell2010

Network.Legion.Discovery.Client

Contents

Description

This module contains a client library for communicating with the 'legion-discovery' service discovery program.

Synopsis

Establishing a Connection.

connect Source #

Arguments

:: 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 withResponse function.

-> IO Discovery 

Create a connection to the discovery service.

Performing Queries.

query Source #

Arguments

:: 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.

withService Source #

Arguments

:: ServiceAddr

The service address on which your service instance can be contacted.

-> Discovery

A handle on the discovery service, obtained via connect.

-> 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.

newLB Source #

Arguments

:: Discovery

A handle on the discovery service, obtained via connect.

-> 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 withResponse.

Create a new load balanced http client, for use with withResponse.

withResponse :: Request -> LBHttp -> (Maybe (Response BodyReader) -> IO a) -> IO a Source #

Analog of 'http-client''s 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.

httpLbs :: Request -> LBHttp -> IO (Maybe (Response ByteString)) Source #

Analog of 'http-client''s httpLbs, but automatically replaces the host, port, and scheme portions of the Request with values obtained from the load balancer.

If a Nothing value is returned, that means that there are no available instances that match the query params that were passed to newLB.

Other Types.

data LBHttp Source #

A handle on the load balancing context.

Instances

data Discovery Source #

This type represents a handle on the discovery service.

newtype Name Source #

The name of a service.

Constructors

Name 

Fields

Instances

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.

Constructors

ServiceAddr 

Fields