Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hawk.workers",
"private": true,
"version": "0.0.1",
"version": "0.1.0",
"description": "Hawk workers",
"repository": "git@github.com:codex-team/hawk.workers.git",
"license": "BUSL-1.1",
Expand Down Expand Up @@ -33,6 +33,7 @@
"test:paymaster": "jest workers/paymaster",
"test:notifier": "jest workers/notifier",
"test:js": "jest workers/javascript",
"test:task-manager": "jest workers/task-manager",
"test:clear": "jest --clearCache",
"run-default": "yarn worker hawk-worker-default",
"run-sentry": "yarn worker hawk-worker-sentry",
Expand All @@ -47,7 +48,8 @@
"run-release": "yarn worker hawk-worker-release",
"run-email": "yarn worker hawk-worker-email",
"run-telegram": "yarn worker hawk-worker-telegram",
"run-limiter": "yarn worker hawk-worker-limiter"
"run-limiter": "yarn worker hawk-worker-limiter",
"run-task-manager": "yarn worker hawk-worker-task-manager"
},
"dependencies": {
"@babel/parser": "^7.26.9",
Expand All @@ -61,7 +63,7 @@
"amqplib": "^0.8.0",
"codex-accounting-sdk": "codex-team/codex-accounting-sdk",
"debug": "^4.1.1",
"dotenv": "^8.2.0",
"dotenv": "^17.2.3",
"migrate-mongo": "^7.2.1",
"mockdate": "^3.0.2",
"mongodb": "^3.5.7",
Expand Down
10 changes: 4 additions & 6 deletions workers/grouper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,10 @@ export default class GrouperWorker extends Worker {
uniqueEventHash = similarEvent.groupHash;

existedEvent = similarEvent;
}

/**
* If we couldn't group by grouping pattern — try grouping bt hash (title)
*/
else {
} else {
/**
* If we couldn't group by grouping pattern — try grouping by hash (title)
*/
/**
* Find event by group hash.
*/
Expand Down
15 changes: 15 additions & 0 deletions workers/task-manager/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Maximum number of auto-created tasks per project per day
# Default: 10
MAX_AUTO_TASKS_PER_DAY=10

# Number of tasks handling simultaneously
# Default: 1
SIMULTANEOUS_TASKS=1

# GitHub App configuration
GITHUB_APP_ID=your_github_app_id
GITHUB_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
# Client ID of GitHub app
GITHUB_APP_CLIENT_ID=Iv23li65HEIkWZXsm6qO
# Generated in GitHub app settings
GITHUB_APP_CLIENT_SECRET=0663e20d484234e17b0871c1f070581739c14e04
32 changes: 32 additions & 0 deletions workers/task-manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Task Manager Worker

Worker for automatically creating GitHub issues for errors that meet the threshold.

## Description

This worker processes tasks to automatically create GitHub issues for events that:
- Have `totalCount >= taskThresholdTotalCount`
- Don't have a `taskManagerItem` (not yet processed)
- Occurred after `taskManager.connectedAt`

## Rate Limiting

The worker implements daily rate limiting:
- Maximum `MAX_AUTO_TASKS_PER_DAY` (default: 10) tasks per project per day
- Uses atomic increment to prevent race conditions
- Resets daily budget at the start of each UTC day

## Environment Variables

- `MAX_AUTO_TASKS_PER_DAY` - Maximum auto tasks per day (default: 10)
- `GITHUB_APP_ID` - GitHub App ID
- `GITHUB_PRIVATE_KEY` - GitHub App private key (PEM format)

## Usage

The worker is triggered by cron tasks with routing key `cron-tasks/task-manager` and payload:
```json
{
"type": "auto-task-creation"
}
```
16 changes: 16 additions & 0 deletions workers/task-manager/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "hawk-worker-task-manager",
"version": "1.0.0",
"main": "src/index.ts",
"license": "MIT",
"workerType": "cron-tasks/task-manager",
"dependencies": {
"@octokit/oauth-methods": "^4.0.0",
"@octokit/rest": "^22.0.1",
"@octokit/types": "^16.0.0",
"jsonwebtoken": "^9.0.3"
},
"devDependencies": {
"@types/jsonwebtoken": "^8.3.5"
}
}
Loading
Loading