Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add setStatusMessage implementation #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"dependencies": {
"@apify/consts": "^1.10.0",
"@apify/log": "^1.2.3",
"@crawlee/types": "^3.2.2",
"better-sqlite3-with-prebuilds": "^7.4.3",
"content-type": "^1.0.4",
"fs-extra": "^10.1.0",
Expand Down
13 changes: 12 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { readdir, rm } from 'fs/promises';
import { join, resolve } from 'path';
import log from '@apify/log';
import { ENV_VARS, KEY_VALUE_STORE_KEYS, LOCAL_ENV_VARS } from '@apify/consts';
import { SetStatusMessageOptions, StorageClient } from '@crawlee/types';
import { STORAGE_NAMES, STORAGE_TYPES } from './consts';
import { DatabaseConnectionCache } from './database_connection_cache';
import { DatasetClient } from './resource_clients/dataset';
Expand Down Expand Up @@ -41,7 +42,7 @@ export interface RequestQueueOptions {
/**
* Represents local emulation of [Apify Storage](https://apify.com/storage).
*/
export class ApifyStorageLocal {
export class ApifyStorageLocal implements StorageClient {
readonly storageDir: string;

readonly requestQueueDir: string;
Expand Down Expand Up @@ -158,6 +159,16 @@ export class ApifyStorageLocal {
});
}

setStatusMessage(message: string, options: SetStatusMessageOptions = {}): Promise<void> {
ow(message, ow.string);
ow(options, ow.optional.object.exactShape({
isStatusMessageTerminal: ow.optional.boolean,
}));

log.info(`Setting${options.isStatusMessageTerminal ? ' terminal' : ''} status message: ${message}`);
return Promise.resolve();
}

/**
* Cleans up the default local storage directories before the run starts:
* - local directory containing the default dataset;
Expand Down