Method: Cuboid::RPC::Server::Instance#progress

Defined in:
lib/cuboid/rpc/server/instance.rb

#progress(options = {}) ⇒ Hash

# Recommended usage

Please request from the method only the things you are going to actually
use, otherwise you'll just be wasting bandwidth.
In addition, ask to **not** be served data you already have, like
error messages.

To be kept completely up to date on the progress of a scan (i.e. receive
new issues and error messages asap) in an efficient manner, you will need
to keep track of the error messages you already have and explicitly tell
the method to not send the same data back to you on subsequent calls.

## Retrieving errors (‘:errors` option) without duplicate data

This is done by telling the method how many error messages you already
have and you will be served the errors from the error-log that are past
that line.
So, if you were to use a loop to get fresh progress data it would look
like so:

  error_cnt = 0
  i = 0
  while sleep 1
      # Test method, triggers an error log...
      instance.error_test "BOOM! #{i+=1}"

      # Only request errors we don't already have
      errors = instance.progress( with: { errors: error_cnt } )[:errors]
      error_cnt += errors.size

      # You will only see new errors
      puts errors.join("\n")
  end

Parameters:

  • options (Hash) (defaults to: {})

    Options about what progress data to retrieve and return.

Options Hash (options):

  • :with (Array<Symbol, Hash>)

    Specify data to include:

    • :errors – Errors and the line offset to use for #errors. Pass as a hash, like: ‘{ errors: 10 }`

  • :without (Array<Symbol, Hash>)

    Specify data to exclude:

    • :statistics – Don’t include runtime statistics.

Returns:

  • (Hash)
    • ‘statistics` – General runtime statistics (merged when part of Grid)

      (enabled by default)
      
    • ‘status` – #status

    • ‘busy` – #busy?

    • ‘errors` – #errors (disabled by default)



199
200
201
# File 'lib/cuboid/rpc/server/instance.rb', line 199

def progress( options = {} )
    progress_handler( options.merge( as_hash: true ) )
end