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

DRAFT: multi step api runner. #997

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

DRAFT: multi step api runner. #997

wants to merge 4 commits into from

Conversation

shahzad31
Copy link
Contributor

@shahzad31 shahzad31 commented Feb 5, 2025

multi step api runner

can be tested with

import { apiJourney, monitor, step } from '@elastic/synthetics';

apiJourney(`My Example api journey`, ({ request }) => {
  monitor.use({
    enabled: true,
  });
  step('launch application', async () => {
    const req = await request.get('https://api.restful-api.dev/objects');
    console.log(await req.json());
  });
  step('go to url', async () => {
    const req = await request.get('https://example.badssl.com/');
    console.log(await req.json());
  });
});

args: APIHooksArgs
) {
const promises = callbacks.map(cb => cb(args));
return await Promise.all(promises);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return await Promise.all(promises);
return await Promise.allSettled(promises);

Accounting for unrelated rejections

};
export type APIJourneyCallback = (options: APIJourneyCallbackOpts) => void;

export class APIJourney {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I would like us to have a base Journey class that both BrowserJourney and APIJourney extends from and the runner should be a single entity that decides how to run each of them. I am not in favor of having multiple runners.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants