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

Introduce Bulk deliveries #127

Closed
wants to merge 1 commit into from
Closed

Conversation

manojmj92
Copy link
Contributor

@manojmj92 manojmj92 commented May 31, 2021

Introduces bulk deliveries mentioned in #89

Usage

class CommentNotification < Noticed::Base
  deliver_by :database
  deliver_by :postmark
  deliver_by :postmark, bulk: { group_size: 1000 }
end
class DeliveryMethods::Postmark < Noticed::DeliveryMethods::Base
 # A custom delivery method can deliver both individually and in bulk
 # For individual delivery, use `deliver` and for bulk delivery use `bulk_deliver`

  def deliver
     # you will have access to a single`recipient` here

     post "https://api.postmarkapp.com/email/send", {
        to: recipient.email,
        subject: 'Something'
      }
  end

  def bulk_deliver
     # you will have access to one batch of `recipients` here

       post "https://api.postmarkapp.com/email/send", {
         to: recipients.map(&:email),
         subject: 'Something'
       }
  end
end
User.all.count
# => 5000

CommentNotification.deliver_later(User.all)
# => Enqueues DeliveryMethods::Database.deliver 5,000 times.
# => Enqueues DeliveryMethods::PostMark.deliver 5,000 times.
# => Enqueues DeliveryMethods::Postmark.bulk_deliver 5 times.

@manojmj92 manojmj92 force-pushed the bulk-deliveries branch 3 times, most recently from 11afc2c to dc526fe Compare May 31, 2021 06:34
@manojmj92 manojmj92 changed the title Intoduce Bulk deliveries Introduce Bulk deliveries May 31, 2021
@manojmj92 manojmj92 force-pushed the bulk-deliveries branch 13 times, most recently from 35ba755 to 43dab40 Compare June 1, 2021 15:52
@manojmj92 manojmj92 marked this pull request as ready for review June 1, 2021 16:03
@manojmj92
Copy link
Contributor Author

@excid3 this is ready for review. Documentation isn't done yet, I will add them if you are ok with the approach 🙂

@manojmj92 manojmj92 mentioned this pull request Jun 8, 2021
@madhums
Copy link

madhums commented Jun 20, 2023

@excid3 Could you review this? Seems like an essential feature!

@madhums madhums mentioned this pull request Jan 5, 2024
Merged
9 tasks
@excid3 excid3 closed this Jan 15, 2024
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