Module: Arango::Database::Tasks

Included in:
Arango::Database
Defined in:
lib/arango/database/tasks.rb

Overview

Arango Database Tasks

Instance Method Summary collapse

Instance Method Details

#all_tasksArray<Arango::Task>

Get all tasks.

Returns:



8
9
10
# File 'lib/arango/database/tasks.rb', line 8

def all_tasks
  Arango::Task.all(database: self)
end

#create_task(id: nil, command:, name: nil, offset: nil, params: nil, period: nil) ⇒ Arango::Task

Create a new task with given id, task is saved to the database. TODO Ruby block

Parameters:

  • id (String) (defaults to: nil)
  • command (String)

    The javascript code to execute.

  • name (String) (defaults to: nil)

    The task name, optional.

  • offset (Integer) (defaults to: nil)

    The number of seconds initial delay, optional.

  • params (Hash) (defaults to: nil)

    Hash of params to pass to the command, optional.

  • period (Integer) (defaults to: nil)

    Number of seconds between executions, optional.

Returns:



21
22
23
# File 'lib/arango/database/tasks.rb', line 21

def create_task(id: nil, command:, name: nil, offset: nil, params: nil, period: nil)
  Arango::Task.new(id: id, command: command, name: name, offset: offset, params: params, period: period, database: self).create
end

#drop_task(id:) ⇒ Boolean Also known as: delete_task, destroy_task

Delete task with given id.

Parameters:

  • id (String)

Returns:

  • (Boolean)

    Returns true if task has been deleted.



55
56
57
# File 'lib/arango/database/tasks.rb', line 55

def drop_task(id:)
  Arango::Task.delete(id: id, database: self)
end

#get_task(id:) ⇒ Arango::Task Also known as: fetch_task, retrieve_task

Get a task from the database.

Parameters:

  • id (String)

Returns:



28
29
30
# File 'lib/arango/database/tasks.rb', line 28

def get_task(id:)
  Arango::Task.get(id: id, database: self)
end

#list_tasksArray<String>

Get a list of all task ids.

Returns:

  • (Array<String>)


48
49
50
# File 'lib/arango/database/tasks.rb', line 48

def list_tasks
  Arango::Task.list(database: self)
end

#new_task(id: nil, command: nil, name: nil, offset: nil, params: nil, period: nil) ⇒ Arango::Task

Instantiate a new task with given id, task is not saved to the database.

Parameters:

  • id (String) (defaults to: nil)
  • command (String) (defaults to: nil)

    The javascript code to execute, optional.

  • name (String) (defaults to: nil)

    The task name, optional.

  • offset (Integer) (defaults to: nil)

    The number of seconds initial delay, optional.

  • params (Hash) (defaults to: nil)

    Hash of params to pass to the command, optional.

  • period (Integer) (defaults to: nil)

    Number of seconds between executions, optional.

Returns:



42
43
44
# File 'lib/arango/database/tasks.rb', line 42

def new_task(id: nil, command: nil, name: nil, offset: nil, params: nil, period: nil)
  Arango::Task.new(id: id, command: command, name: name, offset: offset, params: params, period: period, database: self)
end

#task_exists?(id:) ⇒ Boolean

Checks existence of a task.

Parameters:

  • id (String)

Returns:

  • (Boolean)

    Returns true if the task exists, otherwise false.



64
65
66
# File 'lib/arango/database/tasks.rb', line 64

def task_exists?(id:)
  Arango::Task.exists?(id: id, database: self)
end