Git Product home page Git Product logo

gearmanode's Introduction

        ____                                 _   _           _
       / ___| ___  __ _ _ __ _ __ ___   __ _| \ | | ___   __| | ___
      | |  _ / _ \/ _` | '__| '_ ` _ \ / _` |  \| |/ _ \ / _` |/ _ \
      | |_| |  __/ (_| | |  | | | | | | (_| | |\  | (_) | (_| |  __/
       \____|\___|\__,_|_|  |_| |_| |_|\__,_|_| \_|\___/ \__,_|\___|

Node.js library for the Gearman distributed job system.

Features

  • support for multiple job servers
  • load balancing strategy TODO
  • recover time (when a server node is down due to maintenance or a crash, load balancer will use the recover-time as a delay before retrying the downed job server) TODO
  • rock solid tests
  • in depth tested with gearman clients and workers written in other languages (Ruby, PHP, Java)

Usage

See example folder.

Client

var gearmanode = require('gearmanode');
var client = gearmanode.client(); // by default expects job server on localhost:4730
client.submitJob({ name: 'reverse', payload: 'hello world!' }, function(err, job) { // by default foreground job with normal priority
    job.on('complete', function() {
        console.log(job.toString() + " >>> " + job.response);
        client.end();
    });
})

Multiple Job Servers

// two servers: foo.com:4731, bar.com:4732
client = gearmanode.client({ servers: [{host: 'foo.com', port: 4731}, {host: 'bar.com', port: 4732}] });
// two servers with default values: foo.com:4730, localhost:4731
client = gearmanode.client({ servers: [{host: 'foo.com'}, {port: 4731}] });

Client events

  • connect - when a job server connected (physical connection is lazy opened by first submit)
  • disconnect - when connection to a job server terminated (by timeout if not used or forcible by client)
  • submit - when a job has been submited to job server, has parameter 'number of jobs waiting for response CREATED'
  • done - when there's no submited job more waiting for state CREATED
  • js_error - when the Job Server encounters an error and needs to notify client
  • error - when an unrecoverable error occured (e.g. illegal client's state, malformed data, socket problem, ...), has parameter Error

Job events

  • created - when response to one of the SUBMIT_JOB* packets arrived and job handle assigned
  • status - to update status information of a submitted jobs
  • in response to a client's request for a background job
  • status update propagated from worker to client in case of a non-background job
  • complete - when the non-background job completed successfully
  • timeout - when the job has been canceled due to timeout - TODO
  • close - when Job#close() called or when the job forcible closed by shutdown of client

gearmanode's People

Contributors

veny avatar

Watchers

Václav Hoblík 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.