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

Enable sending items from triggers, futures, etc. via platform events #16

Merged
merged 2 commits into from
Apr 24, 2020

Conversation

waltjones
Copy link
Contributor

@waltjones waltjones commented Apr 23, 2020

Till now, Rollbar items were always sent on a synchronous callout (HTTP request). This has several limitations:

  • Can't call during or after DML.
  • Can't call from trigger.
  • Sync callout limits apply.

This PR allows items to be sent via Platform Event, Future, or synchronous, with Platform Event being the default. Using Platform Events has numerous advantages:

  • Can call at any time during DML, and can send whether or not the DML transaction succeeds.
  • Can call from Triggers, Futures, Queuable Jobs, and from other Platform Events.
  • Some resource limits apply, but are easier to manage than the sync callout limit.

More detailed information here:
https://rollbar.quip.com/2zxYA0bELPlv/Apex-Rollbar-Callouts

When the user wants to perform the callout synchronously or from a future, this is also supported:

Rollbar.log('info', 'hello', SendMethod.SYNC);
Rollbar.log('info', 'hello', SendMethod.FUTURE);

Rollbar.log('info', 'Message from the Apex SDK', SendMethod.FUTURE);
Test.stopTest();

// Asserts valid payload in the mock.

Choose a reason for hiding this comment

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

This looks like a no-opp unit test.. I don't fully understand the logic here, but I would at least confirm the data payload is correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because of the way future methods execute, the asserts have to be in the mock. That's why the comment is there.

Rollbar.log('info', 'Message from the Apex SDK', SendMethod.EVENT);
Test.stopTest();

// Asserts valid payload in the mock.

Choose a reason for hiding this comment

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

This looks like a no-opp unit test.. I don't fully understand the logic here, but I would at least confirm the data payload is correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because of the way future methods execute, the asserts have to be in the mock. That's why the comment is there.

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.

2 participants