Skip to content

Instantly share code, notes, and snippets.

@ota42y
Last active August 30, 2018 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ota42y/8beb81869f71c1045f5e684ff51a3327 to your computer and use it in GitHub Desktop.
Save ota42y/8beb81869f71c1045f5e684ff51a3327 to your computer and use it in GitHub Desktop.
def save!
post = Post.new(user: user, text: 'text')
comment = Comment.new(post: post, text: 'text')
exec = IdempotentExecutor.new(user_id: user.id, transaction_type: :post_create, signature: 'abcdefg')
exec.idempotent_transaction do
Post.transaction do
post.save!
comment.save!
end
end
sns_publisher.publish!(post)
end
def save!
post = Post.new(user: user, text: 'text')
comment = Comment.new(post: post, text: 'text')
Post.transaction do
post.save!
comment.save!
end
sns_publisher.publish!(post)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment