diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f2af3d..dbdd00c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.9.8] + +- Improve performance by reusing SNS client + ## [1.9.7] - Fix undefined method 'set_data' for nil span in Sentry integration diff --git a/lib/eventboss/sns_client.rb b/lib/eventboss/sns_client.rb index b5cbf4f..66413e1 100644 --- a/lib/eventboss/sns_client.rb +++ b/lib/eventboss/sns_client.rb @@ -39,25 +39,22 @@ def set_raw_message_delivery(subscription) end def backend - if configured? - options = { - region: configuration.eventboss_region, - } + @backend ||= + if configured? + options = { + region: configuration.eventboss_region + } - unless configuration.eventboss_use_default_credentials - options[:credentials] = credentials - end + options[:credentials] = credentials unless configuration.eventboss_use_default_credentials - if configuration.aws_sns_endpoint - options[:endpoint] = configuration.aws_sns_endpoint - end + options[:endpoint] = configuration.aws_sns_endpoint if configuration.aws_sns_endpoint - Aws::SNS::Client.new(options) - elsif configuration.raise_on_missing_configuration - raise NotConfigured, 'Eventboss is not configured.' - else - Mock.new - end + Aws::SNS::Client.new(options) + elsif configuration.raise_on_missing_configuration + raise NotConfigured, 'Eventboss is not configured.' + else + Mock.new + end end def credentials diff --git a/lib/eventboss/version.rb b/lib/eventboss/version.rb index 3ef73d1..b1c4410 100644 --- a/lib/eventboss/version.rb +++ b/lib/eventboss/version.rb @@ -1,3 +1,3 @@ module Eventboss - VERSION = "1.9.7" + VERSION = "1.9.8" end