0.2.3 • Published 6 years ago

moonner-client v0.2.3

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Moonner Client

Connect to a Moonner Server and process tasks easily.

Usage

Install the NPM package: npm install --save moonner-client

import moonnerClient from 'moonner-client';

const client = moonnerClient.getClient({
  token: 'your-registration-token',
  endpoint: 'http://api.example.com/v1/moonner',
  oauth_endpoint: 'http://api.example.com/oauth/token',
  data: { // The runner data
    max_jobs: 8,
    has_gpu: true
  }
});

class MySuperTask extends moonnerClient.Task {
    
  run() {
    this._start();
    const name = this._data.name || 'world';
    this.update({
      message: "Hello, " + name + "!"
    }).then(() => {
      this.success();
      this._end();
    }, () => {
      this.failed('Failed to update');
    });
  }
    
}

// Register your own handlers
moonnerClient.registerHandler('my-super', MySuperTask);

// Start a pooling thread
const stopPooling = moonnerClient.runPooling(client, 800);
const stopRunning = moonnerClient.runTasks(200);

// Cancel threads after 1 hour
setTimeout(stopPooling, 3600000);
setTimeout(stopRunning, 3600000);

License

This library is distributed under the X11 license (MIT):

Copyright © 2017, Moonkey SAS

Permission is hereby granted, free of charge, to any person obtaining 
a copy of this software and associated documentation files (the “Software”), 
to deal in the Software without restriction, including without limitation 
the rights to use, copy, modify, merge, publish, distribute, sublicense, 
and/or sell copies of the Software, and to permit persons to whom the 
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included 
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS 
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of the Moonkey SAS shall not 
be used in advertising or otherwise to promote the sale, use or other 
dealings in this Software without prior written authorization from the 
Moonkey SAS. 
0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago