npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

screwdriver-executor-base

v10.0.0

Published

Base class defining the interface for executor implementations

Downloads

988

Readme

Executor Base

Version Downloads Build Status Open Issues License

Base class defining the interface for executor implementations

An executor is an engine that is capable of running a set of docker containers together.

i.e. Jenkins, Kubernetes, ECS, Mesos

The intention of an executor is to run the launch script defined in the screwdriver job-tools docker container, which is mounted to a container defined by a screwdriver task

This means:

  1. Mounting the job-tools container as a volume to $MOUNT_POINT on another container
  2. Running the launch script as the entry point to the task container
SD_TOKEN=${token} $MOUNT_POINT/launch --api-uri ${api_uri} ${build_id}

Usage

npm install screwdriver-executor-base

Interface

Start

Required Parameters

| Parameter | Type | Description | | :------------- | :---- | :-------------| | config | Object | Configuration Object | | config.annotations | Object | Optional key/value object | | config.apiUri | String | Screwdriver's API | | config.buildId | String | The unique ID for a build | | config.container | String | Container for the build to run in | | config.token | String | Temporary JWT which Executor must exchange with API to get JWT which can act on behalf of the build |

Expected Outcome

The start function is expected to create a task in the execution engine.

Expected Return

A Promise that resolves if the task is created correctly, or rejects if it fails.

Stop

Required Parameters

| Parameter | Type | Description | | :------------- | :---- | :-------------| | config | Object | Configuration Object | | config.buildId | String | The unique ID for a build |

Expected Outcome

The stop function is expected to stop/cleanup a task in the execution engine.

Expected Return

A Promise that resolves if the task is cleaned up correctly, or rejects if it fails.

Verify

Required Parameters

| Parameter | Type | Description | | :------------- | :---- | :-------------| | config | Object | Configuration Object | | config.annotations | Object | Optional key/value object | | config.apiUri | String | Screwdriver's API | | config.buildId | String | The unique ID for a build | | config.container | String | Container for the build to run in | | config.token | String | Temporary JWT which Executor must exchange with API to get JWT which can act on behalf of the build |

Expected Outcome

The verify function is expected to check the pods health and status.

Expected Return

A Promise that resolves and returns the message for pod health error or success.

Status

Required Parameters

| Parameter | Type | Description | | :------------- | :---- | :-------------| | config | Object | Configuration Object | | config.buildId | String | The unique ID for a build |

Expected Outcome

The status function is expected to get a human readable status of a task in the execution engine.

Expected Return

A Promise that resolves with the current build status, or rejects if it fails.

Stats

Expected Outcome

The stats function is expected to return an object of statistics

Status

Required Parameters

| Parameter | Type | Description | | :------------- | :---- | :-------------| | config | Object | Configuration Object | | config.token | String | Temporary JWT for a build | | buildTimeout | Number | Build timeout in minutes |

Expected Outcome

The exchangeTokenForBuild function will call API to exchange temporary build JWT with actual build JWT.

Expected Return

A Promise which resolves to actual build JWT

CleanUp

Expected Outcome

The cleanUp function is expected to handle any housekeeping operations like closing connections, queues during the SIGTERM event. Default is no-op

Expected Return

A Promise that resolves or rejects.

StartTimer

Required Parameters

| Parameter | Type | Description | | :------------- | :---- | :-------------| | config | Object | Configuration Object | | config.annotations | Object | Optional key/value object | | config.buildStatus | String | The status of the build | | config.buildId | String | The unique ID for a build | | config.startTime | String | ISO start time of the build | | config.jobId | String | job id of the build |

Expected Outcome

The StartTimer function is expected to add buildId as key and timeout config value to timeout queue Default is no-op

Expected Return

A Promise that resolves or rejects.

StopTimer

Required Parameters

| Parameter | Type | Description | | :------------- | :---- | :-------------| | config | Object | Configuration Object | | config.buildId | String | The unique ID for a build |

Expected Outcome

The StopTimer function is expected to remove key/value buildId from timeout queue Default is no-op

Expected Return

A Promise that resolves or rejects.

Extending

To make use of the validation function for start and stop, you need to override the _start , _stop and _cleanUp methods.

class MyExecutor extends Executor {
    // Implement the interface
    _start(config) {
        if (config.buildId) {
            return this.exchangeTokenForBuild(config.token, buildTimeout).then(buildToken => {
                // do stuff here...
                return Promise.resolve(null);
            });
        }

        return Promise.reject(new Error('Error starting executor'));
    }
}

const executor = new MyExecutor({});
executor.start({
    buildId: '4b8d9b530d2e5e297b4f470d5b0a6e1310d29c5e',
    container: 'node:4',
    apiUri: 'http://localhost:8080',
    token: 'abcdefg'
}, (err) => {
    // do something...
});

Testing

npm test

License

Code licensed under the BSD 3-Clause license. See LICENSE file for terms.