Skip to content

Commit

Permalink
GITBOOK-38: No subject
Browse files Browse the repository at this point in the history
  • Loading branch information
code-xhyun authored and gitbook-bot committed May 9, 2024
1 parent 1b261a5 commit e02731d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 25 deletions.
7 changes: 4 additions & 3 deletions gitbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* [Priority](docs/managing-jobs/manually-working/repeatevery-4.md)
* [Touch](docs/managing-jobs/manually-working/repeatevery-5.md)
* [SetShouldSaveResult](docs/managing-jobs/manually-working/repeatevery-6.md)
* [Run](docs/managing-jobs/manually-working/repeatevery-7.md)
* [Disable](docs/managing-jobs/manually-working/repeatevery-8.md)
* [Enable](docs/managing-jobs/manually-working/repeatevery-9.md)
* [Fail](docs/managing-jobs/manually-working/repeatevery-7.md)
* [Run](docs/managing-jobs/manually-working/repeatevery-8.md)
* [Disable](docs/managing-jobs/manually-working/repeatevery-9.md)
* [Enable](docs/managing-jobs/manually-working/repeatevery-10.md)
45 changes: 45 additions & 0 deletions gitbook/docs/managing-jobs/manually-working/repeatevery-10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Enable



## `job.enable()`

{% hint style="info" %}
The `enable` method sets a job's status to active, allowing it to be run by the job processing system. This is useful for resuming the execution of a job that was previously halted without removing it from the job queue.

\
_This does **NOT** save the job in the database. you must explicitly declare_ [_`save()`_](save.md)_if you want to save it_
{% endhint %}

### Example Usage

{% code fullWidth="false" %}
```typescript
const job = pulse.create('test', {});
job.enable();
job.save(); // If you want to save it
```
{% endcode %}

### Parameters



\


### Returns

* **`Job`**: Returns the job instance, enabling method chaining. This allows for further modifications to the job or chaining additional method calls.

\


\


\




18 changes: 8 additions & 10 deletions gitbook/docs/managing-jobs/manually-working/repeatevery-7.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
# Run
# Fail



## `job.run()`
## `job.fail()`

{% hint style="info" %}
The `run` method executes the processing logic defined for a specific job, handling lifecycle events and managing job state updates based on execution results. It's designed to be an internal method that drives the main execution flow of jobs within the system.

The `fail` method marks a job as failed and updates its attributes accordingly. It records the reason for failure, increments the failure count, and, if the job configuration permits, schedules the job for a retry based on the specified backoff strategy.\
\
**Normally you never need to call this manually.**
_This does **NOT** save the job in the database. you must explicitly declare_ [_`save()`_](save.md)_if you want to save it_
{% endhint %}

### Example Usage

{% code fullWidth="false" %}
```typescript
const job = pulse.create('test', {});
job.run()
.then(() => console.log('Job execution completed.'))
.catch(error => console.error('Job execution failed:', error));
job.fail(new Error('Unable to connect to database'));
job.save(); // If you want to save it
```
{% endcode %}

### Parameters


* **`reason`** (`string | Error`): The reason for the job's failure, which can be provided as either a string or an Error object. If an Error object is provided, its message is used as the failure reason.

\


### Returns

* **`Promise<Job>`**: A promise that resolves with the job instance after execution, whether successful or not. This method handles both successful completion and errors internally, ensuring the job's state is updated accordingly.
* **`Job`**: Returns the job instance, allowing for method chaining.

\

Expand Down
15 changes: 8 additions & 7 deletions gitbook/docs/managing-jobs/manually-working/repeatevery-8.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# Disable
# Run



## `job.disable()`
## `job.run()`

{% hint style="info" %}
The `disable` method sets a job's status to disabled, preventing it from being run by the job processing system. This is useful for temporarily halting a job's execution without permanently removing it from the job queue.
The `run` method executes the processing logic defined for a specific job, handling lifecycle events and managing job state updates based on execution results. It's designed to be an internal method that drives the main execution flow of jobs within the system.

\
_This does **NOT** save the job in the database. you must explicitly declare_ [_`save()`_](save.md)_if you want to save it_
**Normally you never need to call this manually.**
{% endhint %}

### Example Usage

{% code fullWidth="false" %}
```typescript
const job = pulse.create('test', {});
job.disable();
job.save(); // If you want to save it
job.run()
.then(() => console.log('Job execution completed.'))
.catch(error => console.error('Job execution failed:', error));
```
{% endcode %}

Expand All @@ -30,7 +31,7 @@ job.save(); // If you want to save it

### Returns

* **`Job`**: Returns the job instance, allowing for method chaining. This facilitates further modifications to the job or chaining additional method calls.
* **`Promise<Job>`**: A promise that resolves with the job instance after execution, whether successful or not. This method handles both successful completion and errors internally, ensuring the job's state is updated accordingly.

\

Expand Down
10 changes: 5 additions & 5 deletions gitbook/docs/managing-jobs/manually-working/repeatevery-9.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Enable
# Disable



## `job.enable()`
## `job.disable()`

{% hint style="info" %}
The `enable` method sets a job's status to active, allowing it to be run by the job processing system. This is useful for resuming the execution of a job that was previously halted without removing it from the job queue.
The `disable` method sets a job's status to disabled, preventing it from being run by the job processing system. This is useful for temporarily halting a job's execution without permanently removing it from the job queue.

\
_This does **NOT** save the job in the database. you must explicitly declare_ [_`save()`_](save.md)_if you want to save it_
Expand All @@ -16,7 +16,7 @@ _This does **NOT** save the job in the database. you must explicitly declare_ [
{% code fullWidth="false" %}
```typescript
const job = pulse.create('test', {});
job.enable();
job.disable();
job.save(); // If you want to save it
```
{% endcode %}
Expand All @@ -30,7 +30,7 @@ job.save(); // If you want to save it

### Returns

* **`Job`**: Returns the job instance, enabling method chaining. This allows for further modifications to the job or chaining additional method calls.
* **`Job`**: Returns the job instance, allowing for method chaining. This facilitates further modifications to the job or chaining additional method calls.

\

Expand Down

1 comment on commit e02731d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 51%
53.65% (543/1012) 38.79% (116/299) 46.79% (73/156)

Pulse Test Report

Tests Skipped Failures Errors Time
45 0 💤 0 ❌ 0 🔥 8.245s ⏱️

Please sign in to comment.