Async Beanstalk
    Preparing search index...

    Class Client

    The Client connects to the Beanstalk server and allows you to send commands and receive responses.

    Index
    • Create the client.

      The optional readTimeoutMs parameter allows you to specify how long the client will wait for data from the Beanstalk server before timing out.

      This should be greater than the maximum time spent waiting for a job with "reserve()" or "reserveWithTimeout()".

      Parameters

      • readTimeoutMs: number = 600000

        The maximum number of milliseconds to wait when reading from the server.

      Returns Client

    • Put a job into the "buried" state.

      The job will remain in this state until released with the "kick" command.

      Parameters

      • jobId: number

        The ID of the job to bury.

      • priority: number = 1

        The job's priority within the buried queue.

      Returns Promise<void>

      Returns a promise that resolves when the command is complete.

      kick

    • Close the connection to the server.

      Returns Promise<void>

      Returns a promise that resolves when the connection is closed.

    • Connect to the Beanstalk server.

      Parameters

      • host: string

        The server's hostname or IP address.

      • port: number = 11300

        The TCP/IP port number.

      Returns Promise<void>

      Returns a promise that resolves when the connection is ready or rejects if connecting fails.

    • Delete a job from the queue.

      This should be called after reserving and successfully processing a job.

      Parameters

      • jobId: number

        The ID of the job to delete.

      Returns Promise<void>

      Returns a promise that resolves when the command is complete.

    • Stop watching the given tube.

      Parameters

      • tube: string

        The tube to stop watching.

      Returns Promise<number>

      Returns a promise that resolves to the number of tubes being watched.

      watch

    • Change buried or delayed jobs in the currently used queue to be ready.

      If there are any buried jobs then only buried jobs will be affected, otherwise, only delayed jobs will be affected.

      Parameters

      • max: number

        The maximum number of jobs to alter.

      Returns Promise<number>

      Returns a promise that resolves to the number of jobs set to ready.

    • Change a specific job from buried or delayed to ready.

      Parameters

      • jobId: number

        The ID of the job to modify.

      Returns Promise<void>

      Returns a promise that resolves when the job has been updated. Rejects with "NOT_FOUND" if there was no job with the given ID.

    • List all the tubes on the server.

      Returns Promise<string[]>

      Returns a promise that resolves to an array of tube names.

    • List the tubes currently being watched by this client.

      Returns Promise<string[]>

      Returns a promise that resolves to an array of tube names.

    • List the tube currently being used by this client.

      Returns Promise<string>

      Returns a promise that resolves to a tube name.

      use

    • Delay any new jobs from being reserved.

      Parameters

      • tube: string

        The tube to pause.

      • delay: number

        The number of seconds for which to pause.

      Returns Promise<void>

      Returns a promise that resolves when the command is complete.

    • Inspect a specific job.

      Parameters

      • jobId: number

        The ID of the job to inspect.

      Returns Promise<Job | null>

      Returns a promise that resolves to the job or null if there is none.

    • Inspect the first buried job.

      Returns Promise<Job | null>

      Returns a promise that resolves to the job or null if there is none.

    • Inspect the first delayed job.

      Returns Promise<Job | null>

      Returns a promise that resolves to the job or null if there is none.

    • Inspect the first ready job.

      Returns Promise<Job | null>

      Returns a promise that resolves to the job or null if there is none.

    • Add a job to the currently used queue.

      Parameters

      • job: string

        The job to enqueue.

      • priority: number = 1

        The integer job priority between 0 and 2^32-1. Jobs with lower priority values will be reserved before jobs with higher priority values.

      • ttr: number = 1000000000

        The maximum number of seconds a job may be reserved for before being returned to the queue.

      • delay: number = 0

        The number of seconds to wait between accepting the job and making it available to be reserved.

      Returns Promise<number>

      Returns a promise that resolves to the job ID.

      use

    • Instruct the Beanstalk server to close the connection.

      Note that the Beanstlk server will close the connection immediately upon receiving this command. It will not wait for the output from any previous commands to be sent. You should therefore wait for any in-progress commands to be completed before issuing the quit command.

      Returns Promise<void>

      Returns a promise that resolves when the command is complete.

    • Return the job to the "ready" state.

      This can be used to put a job back into the queue if processing fails.

      Parameters

      • jobId: number

        The ID of the job to release.

      • priority: number = 1

        The job's new priority.

      • delay: number = 0

        The number of seconds to wait before marking the job as ready.

      Returns Promise<void>

      Returns a promise that resolves when the command is complete.

    • Read a job from the queue.

      Returns Promise<Job>

      Returns a promise that resolves to the first job that was ready in any of the watched queues.

    • Read a job from the queue.

      Parameters

      • timeout: number

      Returns Promise<Job | null>

      Returns a promise that resolves to the first job that was ready in any of the watched queues, or null if there were no jobs within the timeout.

    • Fetch statistics about the server.

      Returns Promise<Yaml>

      Returns a promise that resolves to a map of data about the server.

    • Fetch statistics about a specific job.

      Parameters

      • jobId: number

        The ID of the job to query.

      Returns Promise<Yaml>

      Returns a promise that resolves to a map of data about the job.

    • Fetch statistics about a tube.

      Parameters

      • tube: string

        The name of the tube to query.

      Returns Promise<Yaml>

      Returns a promise that resolves to a map of data about the tube.

    • Request more time working on a job.

      The job's time to

      Parameters

      • jobId: number

        The ID of the job to touch.

      Returns Promise<void>

      Returns a promise that resolves when the command is complete.

    • Set the tube into which new jobs will be placed.

      Parameters

      • tube: string

        The name of the tube.

      Returns Promise<void>

      Returns a promise that resolves when the command is complete.

    • Watch a tube for incoming jobs.

      After calling watch(), call reserve() to wait for a job to be ready.

      This may be called multiple times to watch multipe tubes at once.

      Parameters

      • tube: string

        The name of the tube to watch.

      Returns Promise<number>

      Returns a promise that resolves to the number of tubes being watched.

      ignore