green-discovery v1.0.4
green-discovery
A service discovery application for AWS Greengrass.
Current version: 1.0.3
Lead Maintainer: Halim Qarroum
Table of contents
Install
green add npm://green-discovery
Description
This application acts as a service discovery agent for AWS Greengrass that connects to every green application deployed on your Greengrass Cores. It exposes an Expressify API that allows applications to register themselves and to list available services on the local Greengrass Core.
This application is automatically deployed on all of your Greengrass Core(s) if you orchestrate your deployments using the green-cli
command-line tool.
API
This application exposes an Expressify API which is accessible from any green application locally, but also from the AWS IoT Core service from the cloud remotely. The available API endpoints are documented and described below.
Method | Resource | Return code(s) | Payload required | Description |
---|---|---|---|---|
GET | /applications | 200 | No | The green-discovery application is able to list the available applications registered on the service discovery agent under the /applications resource using the GET method. |
GET | /applications/:name | 200/404 | No | This application can also return the description of a given application under the /applications/:name resource, where the name placeholder is the name of the application. |
POST | /applications | 200/400 | Yes | To register a new application on the service discovery agent, you can issue a POST request along with the payload of the green-app.json of the application against the /applications resource. The schema of the given payload will be validated before any registration. |
DELETE | /applications/:name | 200/400/404 | No | To unregister an already registered application, you can issue a DELETE request against the /applications resource by giving the name of the application as a parameter. |
SUBSCRIBE | /applications | 200 | No | Using this route, green applications can subscribe to changes impacting registrations and unregistrations of services. |
Events
While application can retrieve on demand the currently available services running on a Greengrass core, they can also be advertised of any change in the registration or unregistration of services by listening, using Expressify, on the /applications
resource as stated in the API section, which will emit a service.registred
event upon the registration of a new service, and a service.unregistered
event upon the unregistration of an existing service.
For more information on how to call an Expressify endpoint and subsribe to resources, please read the documentation associated with the expressify
framework, and its associated expressify-mqtt
strategy which is used in green applications.
See also
- The green-cli command-line tool.
- The green-http API endpoint for Greengrass.
- The green-sdk software development kit for green applications.
- The Expressify framework.