Skip to content

Commit

Permalink
variables renaming and documentation cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lpizzinidev committed Oct 24, 2023
1 parent 97aef76 commit b8ac3e7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 42 deletions.
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-scheduler-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ const target = new targets.LambdaInvoke(fn, {
## Overriding Target Properties

If you wish to reuse the same target in multiple schedules, you can override target properties like `input`,
`maximumRetryAttempts` and `maximumEventAge` when creating a Schedule using the `targetOverrides` parameter:
`maximumRetryAttempts` and `maximumEventAgeInSeconds` when creating a Schedule using the `targetOverrides` parameter:

```ts
declare const target: targets.LambdaInvoke;
Expand All @@ -267,8 +267,8 @@ const oneTimeSchedule = new Schedule(this, 'Schedule', {
target,
targetOverrides: {
input: ScheduleTargetInput.fromText("Overriding Target Input"),
maximumEventAge: Duration.seconds(180),
maximumRetryAttempts: 5,
maxEventAge: Duration.seconds(180),
retryAttempts: 5,
},
});
```
Expand Down
32 changes: 5 additions & 27 deletions packages/@aws-cdk/aws-scheduler-alpha/lib/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,42 +43,20 @@ export interface ScheduleTargetProps {
* @default - The target's input is used.
*/
readonly input?: ScheduleTargetInput;
/**
* The maximum amount of time, in seconds, to continue to make retry attempts.
*
* @default - The target's maximumEventAgeInSeconds is used.
*/
readonly maximumEventAge?: Duration;
/**
* The maximum number of retry attempts to make before the request fails.
*
* @default - The target's maximumRetryAttempts is used.
*/
readonly maximumRetryAttempts?: number;
}

export interface ScheduleTargetProps {
/**
* The text, or well-formed JSON, passed to the target.
*
* If you are configuring a templated Lambda, AWS Step Functions, or Amazon EventBridge target,
* the input must be a well-formed JSON. For all other target types, a JSON is not required.
*
* @default - The target's input is used.
*/
readonly input?: ScheduleTargetInput;
/**
* The maximum amount of time, in seconds, to continue to make retry attempts.
*
* @default - The target's maximumEventAgeInSeconds is used.
*/
readonly maximumEventAge?: Duration;
readonly maxEventAge?: Duration;

/**
* The maximum number of retry attempts to make before the request fails.
*
* @default - The target's maximumRetryAttempts is used.
*/
readonly maximumRetryAttempts?: number;
readonly retryAttempts?: number;
}

/**
Expand Down Expand Up @@ -268,8 +246,8 @@ export class Schedule extends Resource implements ISchedule {
}

const retryPolicy = {
maximumEventAgeInSeconds: props.targetOverrides?.maximumEventAge?.toSeconds() ?? targetConfig.retryPolicy?.maximumEventAgeInSeconds,
maximumRetryAttempts: props.targetOverrides?.maximumRetryAttempts ?? targetConfig.retryPolicy?.maximumRetryAttempts,
maximumEventAgeInSeconds: props.targetOverrides?.maxEventAge?.toSeconds() ?? targetConfig.retryPolicy?.maximumEventAgeInSeconds,
maximumRetryAttempts: props.targetOverrides?.retryAttempts ?? targetConfig.retryPolicy?.maximumRetryAttempts,
};

this.validateRetryPolicy(retryPolicy.maximumEventAgeInSeconds, retryPolicy.maximumRetryAttempts);
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ new scheduler.Schedule(stack, 'TargetOverrideSchedule', {
target: target,
targetOverrides: {
input: scheduler.ScheduleTargetInput.fromText('Changed Text'),
maximumEventAge: cdk.Duration.seconds(360),
maximumRetryAttempts: 5,
maxEventAge: cdk.Duration.seconds(360),
retryAttempts: 5,
},
});

Expand Down
20 changes: 10 additions & 10 deletions packages/@aws-cdk/aws-scheduler-alpha/test/retry-policy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ describe('schedule target retry policy', () => {
schedule: expr,
target: new SomeLambdaTarget(func),
targetOverrides: {
maximumEventAge: Duration.seconds(120),
maximumRetryAttempts: 5,
maxEventAge: Duration.seconds(120),
retryAttempts: 5,
},
enabled: false,
});
Expand All @@ -86,8 +86,8 @@ describe('schedule target retry policy', () => {
schedule: expr,
target: new SomeLambdaTarget(func),
targetOverrides: {
maximumEventAge: Duration.seconds(50),
maximumRetryAttempts: 5,
maxEventAge: Duration.seconds(50),
retryAttempts: 5,
},
enabled: false,
});
Expand All @@ -100,8 +100,8 @@ describe('schedule target retry policy', () => {
schedule: expr,
target: new SomeLambdaTarget(func),
targetOverrides: {
maximumEventAge: Duration.seconds(100000),
maximumRetryAttempts: 5,
maxEventAge: Duration.seconds(100000),
retryAttempts: 5,
},
enabled: false,
});
Expand All @@ -114,8 +114,8 @@ describe('schedule target retry policy', () => {
schedule: expr,
target: new SomeLambdaTarget(func),
targetOverrides: {
maximumEventAge: Duration.seconds(120),
maximumRetryAttempts: -1,
maxEventAge: Duration.seconds(120),
retryAttempts: -1,
},
enabled: false,
});
Expand All @@ -128,8 +128,8 @@ describe('schedule target retry policy', () => {
schedule: expr,
target: new SomeLambdaTarget(func),
targetOverrides: {
maximumEventAge: Duration.seconds(120),
maximumRetryAttempts: 200,
maxEventAge: Duration.seconds(120),
retryAttempts: 200,
},
enabled: false,
});
Expand Down

0 comments on commit b8ac3e7

Please sign in to comment.