Code Monkey home page Code Monkey logo

conductor's People

Contributors

cprussin avatar donutespresso avatar greenkeeperio-bot avatar jdarren avatar micahr avatar mridgway avatar tylerlh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

conductor's Issues

Add a "deps" to Models

Allow a Model to depend on other models by supplying an array of dependencies that will be checked at runtime. The deps list would be a set of Strings, which would just do a quick check to see if the Model is already on the request or not. If it's not, it will warn or message an error so that developers can more easily see why their model is failing.

Rename model lifecycle methods

Rename lifecycle methods to be more explicit about when they are happening. before() and after() may not be immediately obvious.

Sort order for Conductor keys is inaccurate

As the sortNumericalKeys function uses the built in Array sort, it should return -1, 0 or 1 (or anything less than or greater than 0 to indicate -1 and 1). The current implementation returns a true / false value which will not return the desired sort ordering.

The current implementation is can be found here:

conductor/lib/helpers.js

Lines 20 to 22 in eb4e05d

.sort(function(a, b) {
return a > b;
});

Handle users not returning an object from the props function

Trying to set a property in a props function, when a dependency didn't return an object causes this error which is hard to find the root cause. There should be a handler around calling the props function, which determines if this._props is undefined or not, and throws an error so users can correct the issue.

TypeError: Cannot set property 'property' of undefined
    at Object.module.exports.rc.createConductor.props [as propsFn] 
    at Conductor._mergeDeps (/restify-conductor/lib/Conductor.js:256:35)

Provide a little more friendly error for non-flattened handlers

If a set of handlers for a bucket isn't properly flattened, the error message returned is rather cryptic, provide a bit more help by warning that the handler is an array instead of a function.

TypeError: object is not a function
        at runHandlers (/Users/mransdell/src/shakti/app/node_modules/restify-conductor/lib/handlers/run.js:105:21)
        at Object.func (/Users/mransdell/src/shakti/app/node_modules/restify-conductor/node_modules/vasync/lib/vasync.js:246:12)
        at Immediate._onImmediate (/Users/mransdell/src/shakti/app/node_modules/restify-conductor/node_modules/vasync/lib/vasync.js:213:20)
        at processImmediate [as _immediateCallback] (timers.js:358:17)

https://github.com/restify/conductor/blob/master/lib/handlers/run.js#L104

Tests are leaky

Tests currently export an instance of a model, so model mutation causes persistence between test cases. These files should export factories instead, allowing new models to be used per test case.

Allow setting clients to be used per host

Currently, the only client that can be used is a restify-client and it's auto-configured per host. It would be helpful to allow developers to create their own clients (and manager their pools) and expose a setClient method, that takes in a client and the host it should be used for.

Moving conductors

Hi,

Thank you all for all the work on this.

I've been working on dynamic route definitions and would like to give conductor a try. Essentially I need to be able to add, remove routes or swap handler stacks for an existing route. I've tried doing something along the lines of:

    // Adding a dynamic route
    server['get']({
      name: 'uniqueName',
      path: '/some/route/path',
    }, [handlerA, handlerB, handlerC]);

    // Detecting, say, a delete in the db then doing...
    server.rm(endpoint.name);

    // Later perhaps another change comes in with the same path but different handlers
    server['get']({
      name: 'uniqueName', // this often is the same as before (ie: editing handlers)
      path: '/some/route/path', // this often is the same as before (ie: editing handlers)
    }, [handlerX, handlerY, handlerZ]); // note these are different handlers

In Restify (not using conductor yet) I'm inspecting server.routes and I DO see the effect of removing a route. The problem is I get the following when I try curl -is "http://localhost:8080/some/route/path":

/Users/lgomez/Projects/proxy/node_modules/restify/lib/plugins/audit.js:102
            req_id: req.getId(),
                        ^

TypeError: req.getId is not a function
    at Server.audit (/Users/lgomez/Projects/proxy/node_modules/restify/lib/plugins/audit.js:102:25)
    at emitThree (events.js:97:13)
    at Server.emit (events.js:175:7)
    at emitRouteError (/Users/lgomez/Projects/proxy/node_modules/restify/lib/server.js:202:16)
    at onRoute (/Users/lgomez/Projects/proxy/node_modules/restify/lib/server.js:762:17)
    at Router.find (/Users/lgomez/Projects/proxy/node_modules/restify/lib/router.js:419:9)
    at Server._route (/Users/lgomez/Projects/proxy/node_modules/restify/lib/server.js:747:21)
    at routeAndRun (/Users/lgomez/Projects/proxy/node_modules/restify/lib/server.js:705:14)
    at Server._handle (/Users/lgomez/Projects/proxy/node_modules/restify/lib/server.js:725:9)
    at Server.onRequest (/Users/lgomez/Projects/proxy/node_modules/restify/lib/server.js:326:14)

The only way I have been able to avoid that error is by restarting the server but that will not be an option in prod.

So, in the readme for Conductor I see one of the goals being to decouple the handler stacks from the routes themselves. If Conductor can help, how would you remove a route completely or, even better, replace it?

Thank you!

Decouple the building of Models per bucket from fetching them

It would be very helpful to provide a mechanism to gets all the models that are in a "bucket" without having them automatically fetched.

A proposal would be to change the signature of buildModelsWrapper in such a way that it will accept a function to call in the forEachParallel call and default to the current one if it's not passed in. This will allow developers to handle fetching of models or any other customizations that need to be done without re-implementing the entire process.

Metrics extraction

Since conductor is doing http client requests for the end user, need to expose metrics information more easily from the client. Maybe lifecycle hooks for the client itself?

Expose Models so they can be "inherited"

In order to inherit the methods / properties on a Model, one has to "create" one then inherit from it's prototype. This seems inefficient and unnecessary. Perhaps a separate module for models would enable inheritance as well as contribution back to the set of models.

Conductor audit log

Each time a conductor is run, keep a log of the entire run of:

  • conductors sharded to/from
  • what handlers were run, what handlers were left on the table per sharded conductor
  • the actual handlers run (which is probably replicated by restify audit log)

Add a third option to setModel, for overriding the model name

There are times when you want to alias a model when it's set in the models for a conductor. It would be great to have the ability to alias a model (i.e. context for a general model).

I propose we make the function signature:

setModel(req, model, [modelName])

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.