litestream 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd8ac42dbc299e313516510e87cfbfb30b8e2eb488e87aeaf3bbf38640986136
4
- data.tar.gz: f004891377faa981fc43054ba75ed07cca4c8d42fd82644e23cc071a1eacbb1a
3
+ metadata.gz: e2240365f5c9159bef7b50e35fc6816aff14d1cbb726edd51306019456050e3d
4
+ data.tar.gz: 80c9e2d72ed8d9a08633a5b1a3084af8737006f223b206bdff86af076fa500bf
5
5
  SHA512:
6
- metadata.gz: f7bc45ae7b85ea95bf18a64fab17a60647a7645536a7b63c06ba034c9da9cb3d39947f868b08f210c1f637bbbc5becefb7ce350c27fc4b73f7e6494dabecc98e
7
- data.tar.gz: 3e8e2415fa628cd23aaf19c5881f79b4e288c232ec8ccc3cbafb16ed93bf6d1076969c429949735b77f49d48acbda38d141e3357f9dee147bb890b07c107a2cf
6
+ metadata.gz: 8dc6e9209a9f654037d7f214d2e825dfcc8e4a3c196f705cdb8701e0256db9e3d802ce42b02bd6b650cc76b70bae9c7127dd53ec90bc999c6f0cc95b3da590af
7
+ data.tar.gz: cb91236646f2850586cf540f7bf0278c28186e7c11ede6bd32e81fd4846a0a117290b9df8d683aa62832af9831482f8b3c68d4beec6f74bb9124fd67d5ed2eae
data/README.md CHANGED
@@ -82,6 +82,37 @@ Again, however, you can take full manual control over the replication process an
82
82
 
83
83
  The full set of commands available to the `litestream` executable are covered in Litestream's [command reference](https://litestream.io/reference/). Currently, only the `replicate` command is provided as a rake task by the gem.
84
84
 
85
+ ### Using in development
86
+
87
+ By default, installing the gem does not update your `Procfile.dev` file, and so Litestream will not be started in development. If you would like to test that your configuration is properly setup, you can manually add the `litestream:replicate` rake task to your `Procfile.dev` file. Just copy the `litestream` definition from the production `Procfile`. Then, in order to have a replication bucket for Litestream to point to, you can use a Docker instance of [MinIO](https://min.io/). MinIO is an S3-compatible object storage server that can be run locally. You can run a MinIO server with the following command:
88
+
89
+ ```sh
90
+ docker run -p 9000:9000 -p 9001:9001 minio/minio server /data --console-address ":9001"
91
+ ```
92
+
93
+ This gets us up and running quickly but it will only persist the data for as long as the Docker container is running, which is fine for local development testing.
94
+
95
+ To simplify local development, you can add this command to your `Procfile.dev` file as well. This would allow you to start a MinIO server and a Litestream replication process in your local development environment with the single `bin/dev` command.
96
+
97
+ Once you have a MinIO server running, you can create a bucket for Litestream to use. You can do this by visiting the MinIO console at [http://localhost:9001](http://localhost:9001) and logging in with the default credentials of `minioadmin` and `minioadmin`. Once logged in, you can create a bucket named `mybkt` by clicking the `+` button in the bottom right corner of the screen. You can then use the following configuration in your `config/initializers/litestream.rb` file:
98
+
99
+ ```ruby
100
+ Litestream.configure do |config|
101
+ config.database_path = ActiveRecord::Base.connection_db_config.database
102
+ config.replica_url = "s3://mybkt.localhost:9000/"
103
+ config.replica_key_id = "minioadmin"
104
+ config.replica_access_key = "minioadmin"
105
+ end
106
+ ```
107
+
108
+ With Litestream properly configured and the MinIO server and Litestream replication process running, you should see something like the following in your terminal logs when you start the `bin/dev` process:
109
+
110
+ ```sh
111
+ time=YYYY-MM-DDTHH:MM:SS level=INFO msg=litestream version=v0.3.xx
112
+ time=YYYY-MM-DDTHH:MM:SS level=INFO msg="initialized db" path=/path/to/your/app/storage/development.sqlite3
113
+ time=YYYY-MM-DDTHH:MM:SS level=INFO msg="replicating to" name=s3 type=s3 sync-interval=1s bucket=mybkt path="" region=us-east-1 endpoint=http://localhost:9000
114
+ ```
115
+
85
116
  ## Development
86
117
 
87
118
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -73,12 +73,12 @@ module Litestream
73
73
  end
74
74
 
75
75
  def self.replicate
76
- return if Litestream.configuration.nil?
77
-
78
- ENV["LITESTREAM_DATABASE_PATH"] = Litestream.configuration.database_path
79
- ENV["LITESTREAM_REPLICA_URL"] = Litestream.configuration.replica_url
80
- ENV["LITESTREAM_ACCESS_KEY_ID"] = Litestream.configuration.replica_key_id
81
- ENV["LITESTREAM_SECRET_ACCESS_KEY"] = Litestream.configuration.replica_access_key
76
+ if Litestream.configuration
77
+ ENV["LITESTREAM_DATABASE_PATH"] = Litestream.configuration.database_path
78
+ ENV["LITESTREAM_REPLICA_URL"] = Litestream.configuration.replica_url
79
+ ENV["LITESTREAM_ACCESS_KEY_ID"] = Litestream.configuration.replica_key_id
80
+ ENV["LITESTREAM_SECRET_ACCESS_KEY"] = Litestream.configuration.replica_access_key
81
+ end
82
82
 
83
83
  system(executable, "replicate", "--config", Rails.root.join("config", "litestream.yml").to_s)
84
84
  end
@@ -1,8 +1,38 @@
1
- litestream_credentials = Rails.application.credentials.litestream
1
+ # Use this hook to configure the litestream-ruby gem.
2
+ # All configuration options will be available as environment variables, e.g.
3
+ # config.database_path becomes LITESTREAM_DATABASE_PATH
4
+ # This allows you to configure Litestream using Rails encrypted credentials,
5
+ # or some other mechanism where the values are only avaialble at runtime.
2
6
 
3
7
  Litestream.configure do |config|
4
- config.database_path = ActiveRecord::Base.connection_db_config.database
5
- config.replica_url = litestream_credentials.replica_url
6
- config.replica_key_id = litestream_credentials.replica_key_id
7
- config.replica_access_key = litestream_credentials.replica_access_key
8
+ # An example of using Rails encrypted credentials to configure Litestream.
9
+ # litestream_credentials = Rails.application.credentials.litestream
10
+ #
11
+ # The absolute or relative path to a SQLite database file.
12
+ # Litestream will monitor this file for changes and replicate them to the
13
+ # any of the configured replicas specified for this database in the
14
+ # `litestream.yml` configuration file.
15
+ # When using SQLite as your database engine for ActiveRecord, you should always
16
+ # set this to the path of your SQLite database file. You can do so using Rails'
17
+ # existing knowledge of the database path.
18
+ # config.database_path = ActiveRecord::Base.connection_db_config.database
19
+
20
+ # Short-hand form of specifying a replica location.
21
+ # When using S3, a value will look like "s3://mybkt.litestream.io/db"
22
+ # Litestream also supports Azure Blog Storage, Backblaze B2, DigitalOcean Spaces,
23
+ # Scaleway Object Storage, Google Cloud Storage, Linode Object Storage, and
24
+ # any SFTP server.
25
+ # In this example, we are using Rails encrypted credentials to store the URL to
26
+ # our storage provider bucket.
27
+ # config.replica_url = litestream_credentials.replica_url
28
+
29
+ # Replica-specific authentication key.
30
+ # Litestream needs authentication credentials to access your storage provider bucket.
31
+ # In this example, we are using Rails encrypted credentials to store the access key ID.
32
+ # config.replica_key_id = litestream_credentials.replica_key_id
33
+
34
+ # Replica-specific secret key.
35
+ # Litestream needs authentication credentials to access your storage provider bucket.
36
+ # In this example, we are using Rails encrypted credentials to store the secret access key.
37
+ # config.replica_access_key = litestream_credentials.replica_access_key
8
38
  end
@@ -1,3 +1,7 @@
1
+ # This is the actual configuration file for litestream.
2
+ # Edit this file as needed to configure your needs for litestream repication.
3
+ #
4
+ # For more details, see: https://litestream.io/reference/config/
1
5
  dbs:
2
6
  - path: $LITESTREAM_DATABASE_PATH
3
7
  replicas:
@@ -1,3 +1,3 @@
1
1
  module Litestream
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: litestream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-11 00:00:00.000000000 Z
11
+ date: 2023-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  requirements: []
99
- rubygems_version: 3.4.19
99
+ rubygems_version: 3.5.1
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: Integrate Litestream with the RubyGems infrastructure.