Skip to content

Commit 086f655

Browse files
committed
Support configuring replica region and endpoint
1 parent f32a1bf commit 086f655

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

lib/litestream.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def initialize
3333
end
3434
end
3535

36-
mattr_writer :username, :password, :queue, :replica_bucket, :replica_key_id, :replica_access_key, :systemctl_command
36+
mattr_writer :username, :password, :queue, :replica_bucket, :replica_region, :replica_endpoint, :replica_key_id, :replica_access_key, :systemctl_command
3737

3838
class << self
3939
def verify!(database_path)
@@ -77,6 +77,14 @@ def replica_bucket
7777
@@replica_bucket || configuration.replica_bucket
7878
end
7979

80+
def replica_region
81+
@@replica_region
82+
end
83+
84+
def replica_endpoint
85+
@@replica_endpoint
86+
end
87+
8088
def replica_key_id
8189
@@replica_key_id || configuration.replica_key_id
8290
end

lib/litestream/commands.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ def execute(command, argv = {}, database = nil, async: false, tabled_output: fal
125125

126126
def prepare(command, argv = {}, database = nil)
127127
ENV["LITESTREAM_REPLICA_BUCKET"] ||= Litestream.replica_bucket
128+
ENV["LITESTREAM_REPLICA_REGION"] ||= Litestream.replica_region
129+
ENV["LITESTREAM_REPLICA_ENDPOINT"] ||= Litestream.replica_endpoint
128130
ENV["LITESTREAM_ACCESS_KEY_ID"] ||= Litestream.replica_key_id
129131
ENV["LITESTREAM_SECRET_ACCESS_KEY"] ||= Litestream.replica_access_key
130132

lib/tasks/litestream_tasks.rake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ namespace :litestream do
22
desc "Print the ENV variables needed for the Litestream config file"
33
task env: :environment do
44
puts "LITESTREAM_REPLICA_BUCKET=#{Litestream.replica_bucket}"
5+
puts "LITESTREAM_REPLICA_REGION=#{Litestream.replica_region}"
6+
puts "LITESTREAM_REPLICA_ENDPOINT=#{Litestream.replica_endpoint}"
57
puts "LITESTREAM_ACCESS_KEY_ID=#{Litestream.replica_key_id}"
68
puts "LITESTREAM_SECRET_ACCESS_KEY=#{Litestream.replica_access_key}"
79

test/tasks/test_litestream_tasks.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def test_env_task_when_nothing_configured_prints
2626

2727
assert_equal <<~TXT, out
2828
LITESTREAM_REPLICA_BUCKET=
29+
LITESTREAM_REPLICA_REGION=
30+
LITESTREAM_REPLICA_ENDPOINT=
2931
LITESTREAM_ACCESS_KEY_ID=
3032
LITESTREAM_SECRET_ACCESS_KEY=
3133
TXT

0 commit comments

Comments
 (0)