Skip to content

Commit

Permalink
feat(client): Add maxCostPerRun param (#578)
Browse files Browse the repository at this point in the history
Adds `maxCostPerRun` parameter to client - currently not doing anything,
but not failing if it is received.
  • Loading branch information
stetizu1 authored Aug 19, 2024
1 parent d6c3b83 commit 854e776
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/resource_clients/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ export class ActorClient extends ResourceClient {
waitForFinish: ow.optional.number,
webhooks: ow.optional.array.ofType(ow.object),
maxItems: ow.optional.number.not.negative,
maxCostPerRun: ow.optional.number.not.negative,
}));

const { waitForFinish, timeout, memory, build, maxItems } = options;
const { waitForFinish, timeout, memory, build, maxItems, maxCostPerRun } = options;

const params = {
waitForFinish,
Expand All @@ -79,6 +80,7 @@ export class ActorClient extends ResourceClient {
build,
webhooks: stringifyWebhooksToBase64(options.webhooks),
maxItems,
maxCostPerRun,
};

const request: AxiosRequestConfig = {
Expand Down Expand Up @@ -119,6 +121,7 @@ export class ActorClient extends ResourceClient {
waitSecs: ow.optional.number.not.negative,
webhooks: ow.optional.array.ofType(ow.object),
maxItems: ow.optional.number.not.negative,
maxCostPerRun: ow.optional.number.not.negative,
}));

const { waitSecs, ...startOptions } = options;
Expand Down Expand Up @@ -346,6 +349,8 @@ export interface ActorStartOptions {
* Value can be accessed in actor run using `ACTOR_MAX_PAID_DATASET_ITEMS` environment variable.
*/
maxItems?: number;

// TODO(PPE): add maxCostPerRun after finished
}

export interface ActorCallOptions extends Omit<ActorStartOptions, 'waitForFinish'> {
Expand Down
5 changes: 4 additions & 1 deletion src/resource_clients/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ export class TaskClient extends ResourceClient {
waitForFinish: ow.optional.number,
webhooks: ow.optional.array.ofType(ow.object),
maxItems: ow.optional.number.not.negative,
maxCostPerRun: ow.optional.number.not.negative,
}));

const { waitForFinish, timeout, memory, build, maxItems } = options;
const { waitForFinish, timeout, memory, build, maxItems, maxCostPerRun } = options;

const params = {
waitForFinish,
Expand All @@ -76,6 +77,7 @@ export class TaskClient extends ResourceClient {
build,
webhooks: stringifyWebhooksToBase64(options.webhooks),
maxItems,
maxCostPerRun,
};

const request: ApifyRequestConfig = {
Expand Down Expand Up @@ -109,6 +111,7 @@ export class TaskClient extends ResourceClient {
waitSecs: ow.optional.number.not.negative,
webhooks: ow.optional.array.ofType(ow.object),
maxItems: ow.optional.number.not.negative,
maxCostPerRun: ow.optional.number.not.negative,
}));

const { waitSecs, ...startOptions } = options;
Expand Down

0 comments on commit 854e776

Please sign in to comment.