@goatlab/tasks-adapter-hatchet 0.1.18 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -33
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,45 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
# @goatlab/tasks-adapter-hatchet
|
|
2
2
|
|
|
3
|
-
[
|
|
4
|
-
[![Issues][issues-shield]][issues-url]
|
|
5
|
-
[![MIT License][license-shield]][license-url]
|
|
6
|
-
[](http://commitizen.github.io/cz-cli/)
|
|
3
|
+
Hatchet adapter for Goatlab's task processing system. Provides a seamless integration with [Hatchet](https://hatchet.run/) workflow engine for distributed task processing.
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
<br />
|
|
10
|
-
<p align="center">
|
|
11
|
-
<a href="https://github.com/github_username/repo">
|
|
12
|
-
<img src="https://docs.goatlab.io/logo.png" alt="Logo" width="150" height="150">
|
|
13
|
-
</a>
|
|
5
|
+
## Installation
|
|
14
6
|
|
|
15
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install @goatlab/tasks-adapter-hatchet
|
|
9
|
+
# or
|
|
10
|
+
yarn add @goatlab/tasks-adapter-hatchet
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @goatlab/tasks-adapter-hatchet
|
|
13
|
+
```
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
Fluent - Time Saving (TS) utils
|
|
19
|
-
<br />
|
|
20
|
-
<a href="https://docs.goatlab.io/#/0.7.x/fluent/fluent"><strong>Explore the docs »</strong></a>
|
|
21
|
-
<br />
|
|
22
|
-
<br />
|
|
23
|
-
·
|
|
24
|
-
<a href="https://github.com/goat-io/fluent/issues">Report Bug</a>
|
|
25
|
-
·
|
|
26
|
-
<a href="https://github.com/goat-io/fluent/issues">Request Feature</a>
|
|
27
|
-
</p>
|
|
28
|
-
</p>
|
|
29
|
-
</p>
|
|
15
|
+
## Basic Usage
|
|
30
16
|
|
|
31
|
-
|
|
17
|
+
```typescript
|
|
18
|
+
import { HatchetConnector } from '@goatlab/tasks-adapter-hatchet'
|
|
19
|
+
import { ShouldQueue } from '@goatlab/tasks-core'
|
|
32
20
|
|
|
33
|
-
|
|
21
|
+
// Initialize Hatchet connector
|
|
22
|
+
const hatchetConnector = new HatchetConnector({
|
|
23
|
+
token: process.env.HATCHET_JWT_TOKEN,
|
|
24
|
+
hostAndPort: 'localhost:7077', // optional, defaults to localhost:7077
|
|
25
|
+
apiUrl: 'http://localhost:8888', // optional, defaults to http://localhost:8888
|
|
26
|
+
logLevel: 'INFO', // optional, defaults to INFO
|
|
27
|
+
tenantId: 'your-tenant-id' // optional
|
|
28
|
+
})
|
|
34
29
|
|
|
35
|
-
|
|
30
|
+
// Define a task
|
|
31
|
+
class MyTask extends ShouldQueue<{ message: string }> {
|
|
32
|
+
taskName = 'process_message'
|
|
33
|
+
|
|
34
|
+
async handle(taskBody: { message: string }): Promise<void> {
|
|
35
|
+
console.log('Processing:', taskBody.message)
|
|
36
|
+
// Your task logic here
|
|
37
|
+
}
|
|
38
|
+
}
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
// Create task instance
|
|
41
|
+
const myTask = new MyTask({ connector: hatchetConnector })
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
// Start worker to process tasks
|
|
44
|
+
await hatchetConnector.startWorker({
|
|
45
|
+
workerName: 'my-worker',
|
|
46
|
+
tasks: [myTask],
|
|
47
|
+
slots: 100 // concurrent task capacity
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// Queue a task
|
|
51
|
+
const status = await myTask.queue({ message: 'Hello Hatchet!' })
|
|
52
|
+
console.log('Task queued:', status.id)
|
|
53
|
+
|
|
54
|
+
// Check task status
|
|
55
|
+
const taskStatus = await myTask.getStatus(status.id)
|
|
56
|
+
console.log('Task status:', taskStatus.status)
|
|
41
57
|
```
|
|
42
58
|
|
|
43
|
-
|
|
59
|
+
## Key Features
|
|
60
|
+
|
|
61
|
+
- **Seamless Integration**: Works with Goatlab's task system using Hatchet as the backend
|
|
62
|
+
- **Worker Management**: Easy worker creation with configurable concurrency slots
|
|
63
|
+
- **Task Status Tracking**: Monitor task execution status and results
|
|
64
|
+
- **Retry Support**: Built-in retry mechanism for failed tasks
|
|
65
|
+
- **Type Safety**: Full TypeScript support with strongly-typed task payloads
|
|
66
|
+
|
|
67
|
+
## Configuration Options
|
|
44
68
|
|
|
45
|
-
|
|
69
|
+
- `token` (required): Hatchet JWT authentication token
|
|
70
|
+
- `hostAndPort`: Hatchet server address (default: `localhost:7077`)
|
|
71
|
+
- `apiUrl`: Hatchet API URL (default: `http://localhost:8888`)
|
|
72
|
+
- `logLevel`: Logging verbosity (`INFO`, `OFF`, `DEBUG`, `WARN`, `ERROR`)
|
|
73
|
+
- `tenantId`: Hatchet tenant identifier for multi-tenant setups
|