/wineryjs

Winery.js: a framework for service experimentation

Primary LanguageTypeScriptOtherNOASSERTION

Build status

Winery.js

Winery.js is a framework that enables services to run experiments along with production traffic in the same process. Besides A/B testing, it supports experimentation at per-request level, which minimizes turnaround time when code evolves fast. Winery.js also provides a structure for creating applications declaratively, with the access to Napa.js capabilities, such as multi-threading, pluggable logging, metric, and etc. Before this work was branched out as an open source project, it has been used in Bing to empower feature experiments for machine learned models.

Installation

npm install winery

Quick Start

const hub = require('winery').hub();
hub.register('winery/examples/playground', ['playground']);

const request = {
    "application": "playground",
    "entryPoint": "sort",
    "input": [12, 16, 1, 10, 2, 5, 0],
    "overrideObjects": [
        {
        "name": "comparator",
        "value": {
            "_type": "Function",
            "function": "function (a, b) { return a.toString() >= b.toString(); } "
        }
        }
    ]
};
    
hub.serve(request)
.then((response) => {
    console.log(response);
});

console output:

{ responseCode:0, output: [0, 1, 10, 12, 16, 2, 5] }

Features

  • Support request level dependency injection for rapid development
  • Support request template level dependency injection for A/B testing
  • Rich dependency injection capabilities: data, functions and behaviors
  • Declarative application framework
  • Flexible flow control: Entrypoint with stacked interceptors
  • Integrated with Napa.js to support computation heavy scenarios
  • Multi-tenancy with resource sharing among multiple applications
  • Built-in instrumentation and monitoring support

Overview

Winery.js was built based on the idea of dependency injection at multiple levels, thus its core is to encapsulate object creation and object retrieval behaviors with an overriding mechanism. White paper Continuous modification: a process to build constantly evolving services discussed this idea in details.

In Winery.js' implementation, Object Context serves the purpose to capture these behaviors, whose instances are owned by multiple runtime entities with different lifetime and configurability. These object context objects work collaboratively to form an overriding chain among these entities.

These runtime entities are:

  • Host: a conceptually singleton object to host applications. Live long and is configurable at deployment time.
  • Application: multi-instance object that manages resources for request execution and serve user requests. Live long and is configurable at deployment time.
  • Request Template: multi-instance object that manages different parameters and resources for A/B testing. Live long and is configurable at runtime.
  • Request: multi-instance object that describes request from user. Live short and is configurable at runtime.

Winery.js Architecture

Specification

Contribute

You can contribute to Winery.js in following ways:

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

License

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License.