activestorage-multi_node_disk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +43 -0
- data/CONTRIBUTING.md +89 -0
- data/LICENSE +21 -0
- data/README.md +249 -0
- data/SECURITY.md +33 -0
- data/app/controllers/active_storage/multi_node_disk/blobs_controller.rb +166 -0
- data/config/routes.rb +10 -0
- data/lib/active_storage/multi_node_disk/audit.rb +15 -0
- data/lib/active_storage/multi_node_disk/audit_log.rb +48 -0
- data/lib/active_storage/multi_node_disk/configuration.rb +217 -0
- data/lib/active_storage/multi_node_disk/configuration_error.rb +8 -0
- data/lib/active_storage/multi_node_disk/delete_job.rb +27 -0
- data/lib/active_storage/multi_node_disk/engine.rb +24 -0
- data/lib/active_storage/multi_node_disk/fan_out.rb +76 -0
- data/lib/active_storage/multi_node_disk/file_error.rb +36 -0
- data/lib/active_storage/multi_node_disk/file_sink.rb +38 -0
- data/lib/active_storage/multi_node_disk/mismatch.rb +15 -0
- data/lib/active_storage/multi_node_disk/net_http_client.rb +31 -0
- data/lib/active_storage/multi_node_disk/node_addresses.rb +50 -0
- data/lib/active_storage/multi_node_disk/not_here.rb +15 -0
- data/lib/active_storage/multi_node_disk/requester.rb +50 -0
- data/lib/active_storage/multi_node_disk/response.rb +16 -0
- data/lib/active_storage/multi_node_disk/test_helper.rb +97 -0
- data/lib/active_storage/multi_node_disk/unavailable.rb +16 -0
- data/lib/active_storage/multi_node_disk/version.rb +7 -0
- data/lib/active_storage/multi_node_disk.rb +172 -0
- data/lib/active_storage/service/multi_node_disk_service.rb +322 -0
- data/lib/activestorage-multi_node_disk.rb +4 -0
- data/lib/generators/active_storage/multi_node_disk/install_generator.rb +47 -0
- data/lib/generators/active_storage/multi_node_disk/templates/create_audits.rb.tt +33 -0
- data/lib/generators/active_storage/multi_node_disk/templates/initializer.rb.tt +26 -0
- metadata +141 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# The :table audit sink (activestorage-multi_node_disk): one row per entry,
|
|
2
|
+
# the whole entry in payload. Runs on PostgreSQL (jsonb), MySQL 8 (json),
|
|
3
|
+
# Oracle (CLOB) and SQLite (text); the model reads it with
|
|
4
|
+
# `attribute :payload, :json`. Safe to run again; reversible.
|
|
5
|
+
class CreateActiveStorageMultiNodeDiskAudits < ActiveRecord::Migration<%= migration_version %>
|
|
6
|
+
TABLE = :<%= table_name %>
|
|
7
|
+
INDEX = "<%= index_name %>"
|
|
8
|
+
|
|
9
|
+
def up
|
|
10
|
+
return if table_exists?(TABLE)
|
|
11
|
+
|
|
12
|
+
create_table TABLE do |t|
|
|
13
|
+
t.column :payload, payload_type, null: false
|
|
14
|
+
t.datetime :created_at, null: false
|
|
15
|
+
end
|
|
16
|
+
add_index TABLE, :created_at, name: INDEX
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def down
|
|
20
|
+
drop_table TABLE if table_exists?(TABLE)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
# JSON where the database has a JSON type; a CLOB (text) elsewhere.
|
|
26
|
+
def payload_type
|
|
27
|
+
case connection.adapter_name
|
|
28
|
+
when /postg/i then :jsonb
|
|
29
|
+
when /mysql|trilogy/i then :json
|
|
30
|
+
else :text
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# activestorage-multi_node_disk. storage.yml names the service and its nodes:
|
|
4
|
+
#
|
|
5
|
+
# local:
|
|
6
|
+
# service: MultiNodeDisk
|
|
7
|
+
# root: <%%= Rails.root.join("storage") %>
|
|
8
|
+
# nodes: [app1.internal, app2.internal]
|
|
9
|
+
#
|
|
10
|
+
# and `bin/rails credentials:edit` holds the nodes' shared token:
|
|
11
|
+
#
|
|
12
|
+
# multi_node_disk:
|
|
13
|
+
# token: <the same random value on every node>
|
|
14
|
+
ActiveStorage::MultiNodeDisk.configure do |config|
|
|
15
|
+
# Who may call this node's endpoint: :token (a Bearer token, the
|
|
16
|
+
# credentials above), :ip (the nodes' addresses), [:ip, :token], or :none
|
|
17
|
+
# (the gem's default: anyone who can reach the node).
|
|
18
|
+
config.auth = :token
|
|
19
|
+
|
|
20
|
+
# Optional; the default is shown.
|
|
21
|
+
|
|
22
|
+
# Where audit entries go: :file (tmp/multi_node_disk/audit.log), :table
|
|
23
|
+
# (run `bin/rails g active_storage:multi_node_disk:install --audit` and
|
|
24
|
+
# migrate), :none, or a callable.
|
|
25
|
+
# config.audit = :file
|
|
26
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: activestorage-multi_node_disk
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ajaya Agrawalla
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: activestorage
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '8.1'
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '9'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '8.1'
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '9'
|
|
32
|
+
- !ruby/object:Gem::Dependency
|
|
33
|
+
name: actionpack
|
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '8.1'
|
|
39
|
+
- - "<"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '9'
|
|
42
|
+
type: :runtime
|
|
43
|
+
prerelease: false
|
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '8.1'
|
|
49
|
+
- - "<"
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '9'
|
|
52
|
+
- !ruby/object:Gem::Dependency
|
|
53
|
+
name: railties
|
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
- - ">="
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: '8.1'
|
|
59
|
+
- - "<"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '9'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '8.1'
|
|
69
|
+
- - "<"
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '9'
|
|
72
|
+
description: 'Stores each file on the disk of the node that received it. Any node
|
|
73
|
+
can read, check or delete it: the service looks on its own disk first, then asks
|
|
74
|
+
the other nodes. No database needed.'
|
|
75
|
+
email:
|
|
76
|
+
- ajaya@clearstack.io
|
|
77
|
+
executables: []
|
|
78
|
+
extensions: []
|
|
79
|
+
extra_rdoc_files: []
|
|
80
|
+
files:
|
|
81
|
+
- CHANGELOG.md
|
|
82
|
+
- CONTRIBUTING.md
|
|
83
|
+
- LICENSE
|
|
84
|
+
- README.md
|
|
85
|
+
- SECURITY.md
|
|
86
|
+
- app/controllers/active_storage/multi_node_disk/blobs_controller.rb
|
|
87
|
+
- config/routes.rb
|
|
88
|
+
- lib/active_storage/multi_node_disk.rb
|
|
89
|
+
- lib/active_storage/multi_node_disk/audit.rb
|
|
90
|
+
- lib/active_storage/multi_node_disk/audit_log.rb
|
|
91
|
+
- lib/active_storage/multi_node_disk/configuration.rb
|
|
92
|
+
- lib/active_storage/multi_node_disk/configuration_error.rb
|
|
93
|
+
- lib/active_storage/multi_node_disk/delete_job.rb
|
|
94
|
+
- lib/active_storage/multi_node_disk/engine.rb
|
|
95
|
+
- lib/active_storage/multi_node_disk/fan_out.rb
|
|
96
|
+
- lib/active_storage/multi_node_disk/file_error.rb
|
|
97
|
+
- lib/active_storage/multi_node_disk/file_sink.rb
|
|
98
|
+
- lib/active_storage/multi_node_disk/mismatch.rb
|
|
99
|
+
- lib/active_storage/multi_node_disk/net_http_client.rb
|
|
100
|
+
- lib/active_storage/multi_node_disk/node_addresses.rb
|
|
101
|
+
- lib/active_storage/multi_node_disk/not_here.rb
|
|
102
|
+
- lib/active_storage/multi_node_disk/requester.rb
|
|
103
|
+
- lib/active_storage/multi_node_disk/response.rb
|
|
104
|
+
- lib/active_storage/multi_node_disk/test_helper.rb
|
|
105
|
+
- lib/active_storage/multi_node_disk/unavailable.rb
|
|
106
|
+
- lib/active_storage/multi_node_disk/version.rb
|
|
107
|
+
- lib/active_storage/service/multi_node_disk_service.rb
|
|
108
|
+
- lib/activestorage-multi_node_disk.rb
|
|
109
|
+
- lib/generators/active_storage/multi_node_disk/install_generator.rb
|
|
110
|
+
- lib/generators/active_storage/multi_node_disk/templates/create_audits.rb.tt
|
|
111
|
+
- lib/generators/active_storage/multi_node_disk/templates/initializer.rb.tt
|
|
112
|
+
homepage: https://github.com/clearstackio/activestorage-multi_node_disk
|
|
113
|
+
licenses:
|
|
114
|
+
- MIT
|
|
115
|
+
metadata:
|
|
116
|
+
homepage_uri: https://github.com/clearstackio/activestorage-multi_node_disk
|
|
117
|
+
source_code_uri: https://github.com/clearstackio/activestorage-multi_node_disk/tree/master
|
|
118
|
+
changelog_uri: https://github.com/clearstackio/activestorage-multi_node_disk/blob/master/CHANGELOG.md
|
|
119
|
+
bug_tracker_uri: https://github.com/clearstackio/activestorage-multi_node_disk/issues
|
|
120
|
+
documentation_uri: https://github.com/clearstackio/activestorage-multi_node_disk#readme
|
|
121
|
+
rubygems_mfa_required: 'true'
|
|
122
|
+
allowed_push_host: https://rubygems.org
|
|
123
|
+
rdoc_options: []
|
|
124
|
+
require_paths:
|
|
125
|
+
- lib
|
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - ">="
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: '3.3'
|
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
|
+
requirements:
|
|
133
|
+
- - ">="
|
|
134
|
+
- !ruby/object:Gem::Version
|
|
135
|
+
version: '0'
|
|
136
|
+
requirements: []
|
|
137
|
+
rubygems_version: 4.0.20
|
|
138
|
+
specification_version: 4
|
|
139
|
+
summary: An Active Storage Disk service for apps on several nodes, each with its own
|
|
140
|
+
disk
|
|
141
|
+
test_files: []
|