Skip to content

knowvishnu/ais-service-discovery-js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloud Application Framework

logo

Description

This repository interfaces Serice Discovery, in this instance CloudMap, in order to locate and communicate with different services. As opposed to storing ARN's in environment variables, this library will interface CloudMap to find a service by a user friendly naming convention, and will understand what 'type' of service you've requested, and use the correct code to communicate/call that service.

Services supported

  • Lambda (request|call).
  • SNS (publish). // subscribe not supported by SNS.
  • SQS (queue|listen),
  • Automation//SSM task (automate | script).
  • Step function (state-machine).

TODO

  • Http (request|call).
  • Fargate/ECS Task (run).

Note:

This library requires Node 8 and above. Node 6 and below will soon be EOL and unsupported.

Examples:

Import

const ServiceDiscovery = require('@peak-ai/ais-service-discovery');

Call a function

await ServiceDiscovery.request('namespace.service->handler',  body);

Publish an SNS event

await ServiceDiscovery.publish('namspace.service-name->topic', event, opts);

Add message to queue

await ServiceDiscovery.queue('namespace.service-name->queue-name', message, opts // optional);

List to queue

const messages = await ServiceDiscovery.listen('namespace.service-name->queue-name', opts // optional);
messages.on('message', (message) => {

});

Register a service (Cloudformation)

CloudMapService:
  Type: AWS::ServiceDiscovery::Service
  Properties:
    Description: discover handlers for ais-service-segment-explorer
    Name: segment-explorer
    NamespaceId: ${cf:ais-${opt:stage}-service-discovery.NamespaceId}

CreateRefreshSegmentInstance:
  Type: "AWS::ServiceDiscovery::Instance"
  Properties:
    InstanceAttributes:
      arn: ${self:service}-${opt:stage}-refresh-segment
      type: function
    InstanceId: refresh-segment
    ServiceId:
      Ref: CloudMapService

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%