Giter Site home page Giter Site logo

js-poll-ssm's Introduction

Dynamic Application Config for NodeJS Apps

Avoid redeploying your NodeJS app on AWS just to avail of new paramaters/config values.

In production, at runtime, resources outside our control may require that we adapt to these events.

Some examples:

  • Our data provider chnages a URL
  • We need to change the poll timeout on a connection
  • Our thread pool size has to be altererd
  • Query timeouts need to be extended due to load
  • An API Token is updated

This is available via the excellent Netflix Hystrix, but not for JavaScript/Node.

In a lot of environments this requires a redepoly of an application; as these values are often embedded in the app at deploy time / compile time in the form of Environemt variables or config file. They are read once and persist until an application restarts.

No code changing then we should not have to redeploy.

This pattern is described in 'Release It' - a must read bible for the professional software engineer.

So now you're faced with a full pipeline release cycle, canary releases to perform that downtime free deplyoment - but there are no code changes, just config. Time to separate that out..

Decouple from config

It doesn't need to be this way - all you need is a value changed - this module addresses this by polling a Config store, be it:

  • AWS SSM
  • Redis [TODO]
  • Consul [TODO]

and updating the value of your Env vars

Starting it up

  • 1 Set your provider, curretly only AWS works: PROVIDER_TYPE='aws'
  • 2 Export AWS_ACCESS_KEY_ID='your key'
  • 3 Export AWS_SECRET_ACCESS_KEY='your key'
  • 4 Export your key prefix, this is the unique app path to be searched: KEY_PREFIX=/my/app/hola-mundo/ (All keys under that 'namespace' will be set as Env vars)
  • 5 Export your gobal key prefix, this is for shared app params: GLOBAL_KEY_PREFIX=/my/apps/globals/
  • 6 Export POLL_TIME set a poll timer for the refresh
LOG_LEVEL=debug NODE_ENV=development node src/index.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.