Skip to content

Commit 6916930

Browse files
Merge pull request #58 from MatheusRich/main
Support configuring replica region and endpoint
2 parents 305269a + b3ae955 commit 6916930

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
:config_path
3838
mattr_accessor :base_controller_class, default: "::ApplicationController"
3939

@@ -79,6 +79,14 @@ def replica_bucket
7979
@@replica_bucket || configuration.replica_bucket
8080
end
8181

82+
def replica_region
83+
@@replica_region
84+
end
85+
86+
def replica_endpoint
87+
@@replica_endpoint
88+
end
89+
8290
def replica_key_id
8391
@@replica_key_id || configuration.replica_key_id
8492
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)