Skip to content

Commit cdba15e

Browse files
committed
add http_proxy and create_table_enabled config options
1 parent 36425ab commit cdba15e

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,10 @@ Listed below are all configuration options.
11261126
* `http_read_timeout`:The number of seconds to wait for HTTP response
11271127
data. Default option value is `nil`. If not specified effected value
11281128
is `60`
1129+
* `http_proxy`: A proxy to send requests through. Default option value is `nil`.
1130+
* `create_table_enabled`: if `true`, Dynamoid creates table if table not exist;
1131+
if `false`, Dynamoid logs error message for not able to create table in DynamoDB.
1132+
Default is `false`
11291133

11301134

11311135
## Concurrency

lib/dynamoid/adapter_plugin/aws_sdk_v3.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class AwsSdkV3
6767
}
6868
BATCH_WRITE_ITEM_REQUESTS_LIMIT = 25
6969

70-
CONNECTION_CONFIG_OPTIONS = %i[endpoint region http_continue_timeout http_idle_timeout http_open_timeout http_read_timeout].freeze
70+
CONNECTION_CONFIG_OPTIONS = %i[endpoint region http_continue_timeout http_idle_timeout http_open_timeout http_read_timeout http_proxy].freeze
7171

7272
attr_reader :table_cache
7373

@@ -282,6 +282,11 @@ def batch_delete_item(options)
282282
# @option options [Boolean] sync Wait for table status to be ACTIVE?
283283
# @since 1.0.0
284284
def create_table(table_name, key = :id, options = {})
285+
unless Dynamoid.config.create_table_enabled
286+
Dynamoid.logger.error "Table #{table_name} is not created as create_table_enabled is disabled"
287+
return false
288+
end
289+
285290
Dynamoid.logger.info "Creating #{table_name} table. This could take a while."
286291
CreateTable.new(client, table_name, key, options).call
287292
true

lib/dynamoid/config.rb

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ module Config
5959
option :http_idle_timeout, default: nil # - default: 5
6060
option :http_open_timeout, default: nil # - default: 15
6161
option :http_read_timeout, default: nil # - default: 60
62+
option :http_proxy, default: nil
63+
option :create_table_enabled, default: true
6264

6365
# The default logger for Dynamoid: either the Rails logger or just stdout.
6466
#

spec/dynamoid/adapter_plugin/aws_sdk_v3_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1242,11 +1242,13 @@ def dynamo_request(table_name, scan_hash = {}, select_opts = {})
12421242

12431243
before do
12441244
Dynamoid.configure.http_open_timeout = 30
1245+
Dynamoid.configure.http_proxy = 'http://proxy'
12451246
end
12461247

12471248
it 'not nil options entried' do
1248-
expect(subject.keys).to contain_exactly(:endpoint, :log_formatter, :log_level, :logger, :http_open_timeout)
1249+
expect(subject.keys).to contain_exactly(:endpoint, :log_formatter, :log_level, :logger, :http_open_timeout, :http_proxy)
12491250
expect(subject[:http_open_timeout]).to eq 30
1251+
expect(subject[:http_proxy]).to eq 'http://proxy'
12501252
end
12511253
end
12521254
end

0 commit comments

Comments
 (0)