Giter Site home page Giter Site logo

iodine- / split-evaluator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from splitio/split-evaluator

0.0 2.0 0.0 63 KB

Wrapper of NodeJS SDK that exposes evaluation of features as a microservice

Home Page: https://split.io

License: Other

Dockerfile 2.18% JavaScript 97.82%

split-evaluator's Introduction

Split Evaluator service

This services exposes a set of APIs to produce server side evaluation of flags by wrapping a NodeJS SDK.

Usage with NodeJS

  1. nvm use

  2. npm install

  3. SPLITIO_API_KEY=xxxxxxx SPLITIO_EXT_API_KEY=yyyyyy SPLITIO_SERVER_PORT=7548 SPLITIO_DEBUG='on' npm start

    SPLITIO_API_KEY could be overriden quickly, but we recommend the usage of node-config, switch the environment variable NODE_ENV. Please read the details here.
    SPLITIO_EXT_API_KEY could be any value you like, against which we will compare the received Authorization header. SPLITIO_SERVER_PORT is the port number on which the server will run, default is 7548.
    For logging details see the NodeJS SDK docs.

Services

GET
  /get-treatment

QUERY PARAMS
  key:
    This is the key used in the getTreatment call.
  bucketing-key:
    (Optional) This is the bucketing key used in the getTreatment call.
  split-name:
    This should be the name of the split you want to include in the getTreatment call.
  attributes:
    (Optional) This should be a json string of the attributes you want to include in the getTreatment call.

EXAMPLE
  curl 'http://localhost:4444/get-treatment?key=my-customer-key&split-name=my-experiment&attributes=\{"attribute1":"one","attribute2":2,"attribute3":true\}' -H 'Authorization: {SPLITIO_EXT_API_KEY}'

RESPONSE
  {
    "splitName": "my-experiment",
    "treatment": "on"
  }

GET
  /get-treatments

QUERY PARAMS
  keys:
    This is the array of keys to be used in the getTreatments call. Each key should specify a `matchingKey` 
    and a `trafficType`. You can also specify a `bucketingKey`.
  attributes:
    (Optional) This should be a json string of the attributes you want to include in the getTreatments call.

EXAMPLE
  curl 'http://localhost:4444/get-treatments?keys=\[\{"matchingKey":"my-first-key","trafficType":"account"\},\{"matchingKey":"my-second-key","bucketingKey":"my-bucketing-key","trafficType":"user"\}\]&attributes=\{"attribute1":"one","attribute2":2,"attribute3":true\}' -H 'Authorization: {SPLITIO_EXT_API_KEY}'

RESPONSE
  [
    { "splitName": "my-experiment", "treatment":"on" },
    { "splitName": "my-second-experiment", "treatment":"off" },
    ...
    { "splitName": "my-last-experiment", "treatment":"visa" }
  ]

GET 
  /admin/version

EXAMPLE 
  curl 'http//localhost:4444/admin/version' -H 'Authorization: {SPLITIO_EXT_API_KEY}'
  
RESPONSE
  {
    version: '1.0.2',
    sdk: 'nodejs',
    sdkVersion: '9.3.4'
  }

GET 
  /admin/machine

EXAMPLE 
  curl 'http//localhost:4444/admin/machine' -H 'Authorization: {SPLITIO_EXT_API_KEY}'
  
RESPONSE
  {
    ip: '10.0.0.125',
    name: 'machine_name'
  }

GET 
  /admin/ping

EXAMPLE 
  curl 'http//localhost:4444/admin/ping' -H 'Authorization: {SPLITIO_EXT_API_KEY}'
  
RESPONSE
  200: 'pong'

GET 
  /admin/healthcheck

EXAMPLE 
  curl 'http//localhost:4444/admin/healthcheck' -H 'Authorization: {SPLITIO_EXT_API_KEY}'
  
RESPONSE
  200: 'Split Evaluator working as expected.'
  500: 'Split evaluator engine is not evaluating traffic properly.'

GET 
  /admin/uptime

EXAMPLE 
  curl 'http//localhost:4444/admin/uptime' -H 'Authorization: {SPLITIO_EXT_API_KEY}'
  
RESPONSE
  200: '0d 23h 5m 10s'

Running the service in Docker container

Command to build & run the docker container :

By default te server uses the port 7548, which is the one exposed by the container. You can use a different one by setting the SPLITIO_SERVER_PORT environment variable, but their exposure of that port to the host will depend on your settings. You can just leave the default port and map it to whatever port you need

Pull the image: docker pull splitsoftware/split-evaluator:<VERSION>

Run the container:

docker run -e SPLITIO_API_KEY={YOUR_API_KEY} -e SPLITIO_DEBUG='off' -e SPLITIO_SERVER_PORT=7549 -p 4444:7549 splitsoftware/split-evaluator:<VERSION>

NOTE: SPLITIO_DEBUG & SPLITIO_SERVER_PORT are optionals

Configs:

SPLITIO_EXT_API_KEY : Callhome will validate every request against Authorization header. This is not a Split API key but an arbitrary value.
SPLITIO_API_KEY : Api-Key for you Split Environment.
SPLITIO_DEBUG : (Optional) Usable for enabling/disabling the logs of the SDK. By default they are off.
SPLITIO_SERVER_PORT : TCP Port of the server inside the container.

Build Docker Image

This command must be executed at root folder docker build -t splitsoftware/split-evaluator:<VERSION> . && docker build -t splitsoftware/split-evaluator:latest .

Push Docker Image

Before pushing image you must be logged in docker cloud. So run this command: docker login And push the image: docker push splitsoftware/split-evaluator:<VERSION> && docker push splitsoftware/split-evaluator:latest

Pushing latest image. If tag is not explicit on docker pull command, the tag will be set by Docker engine as latest. So it is important create an image with this tag and push it.

docker build -t splitsoftware/split-evaluator:latest .
docker push splitsoftware/split-evaluator:latest

split-evaluator's People

Contributors

facundocabrera avatar marquezmanu avatar nicozelaya avatar nikoe14 avatar patricioe avatar sanjeevkarani avatar sarrubia avatar

Watchers

 avatar  avatar

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.