Skip to content

resilient-http/specification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 

Repository files navigation

Resilient specification

This document explains how the Resilient discovery interface works and should be implemented by compatible servers.

Since new versions of Resilient you can communicate with non-compatible lookup servers via middleware adapters. For instance you can use Consul with Resilient via its middleware

Request flow algorithm

You can take a look to the discovery server algorithm graph here

Discovery server API

The following API must be implemented by any of the discovery server consumed by Resilient

Request

Resilient will perform a HTTP request to the configured discovery servers in order to retrieve the service servers URLs.

It could perform a request to a custom path, transport any HTTP header and use any HTTP verb. Resilient it's really flexible and configurable to define how the discovery request should be performed from the client

Discovery servers must be always a valid URL, including the protocol schema

Example

Using the JavaScript Resilient client:

var client = Resilient({
  discovery: {
    // define the discovery servers list
    servers: ['http://discover1.server.me', 'http://discover2.server.me']
    // transport custom headers, for example to authenticate
    headers: {
      'Accept': 'application/json',
      'API-Token': 'd1964f12ff0388cc897d22b717d0fc3861df8063' 
    },
    // use POST to retrieve the servers list (default GET)
    method: 'POST'
  }
})

Response

When Resilient ask to a discovery server, it should return a valid JSON array of strings which contains a valid URL schema

Mandatory headers
Content-Type: application/json
Response body

It should return an array of strings which implements the following JSON schema

{
  "type": "array",
  "items": {
    "type": "string",
    "require": true,
    "patternProperties": "^(?:([^:\/?#]+):\/\/)?((?:([^\/?#@]*)@)?([^\/?#:]*)(?:\:(\d*))?)?"
  },
  "minItems": 0,
  "uniqueItems": true
}
Example
[
  "http://api1.server.me",
  "http://api2.server.me",
  "http://api3.server.me"
]
Valid URLs
http://server.me
http://server.me:8080
https://server.me/api/1.0
https://192.168.1.100:8000
Invalid URLs
server.me
http://server.me/?version=1.0

Servers

Discussion

Please, the opened issue to contribute and join to the discussion

License

MIT - Resilient project contributos

About

Specification for the Resilient discovery API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published