hyrax 4.0.0.rc2 → 4.0.0.rc3
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 +4 -4
- data/.dassie/config/initializers/redis_config.rb +8 -1
- data/.koppie/config/initializers/redis_config.rb +8 -1
- data/.regen +1 -1
- data/CONTAINERS.md +1 -1
- data/README.md +2 -2
- data/app/builders/hyrax/bootstrap_breadcrumbs_builder.rb +1 -1
- data/app/services/hyrax/custom_queries/navigators/find_files.rb +1 -4
- data/app/services/hyrax/lock_manager.rb +36 -6
- data/app/views/layouts/hyrax/dashboard.html.erb +1 -1
- data/app/views/layouts/hyrax.html.erb +1 -1
- data/docker-compose-koppie.yml +0 -1
- data/docker-compose.yml +0 -1
- data/documentation/legacyREADME.md +2 -2
- data/hyrax.gemspec +1 -0
- data/lib/generators/hyrax/templates/config/initializers/redis_config.rb +8 -1
- data/lib/hyrax/configuration.rb +7 -1
- data/lib/hyrax/redis_event_store.rb +21 -13
- data/lib/hyrax/version.rb +1 -1
- data/template.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7d9595ce45877e35b01b14d36cdefb89a1bb8978ab424bbe9907edcfebb693e
|
4
|
+
data.tar.gz: 516c7de64fc06ede1b8bd0843ad4ad98b01d39f7440c4723e72235880d52d34a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a4173fac3ac9ee096966e8019d7bbb00e80715b1a7672fd830920229b6236cd31b63c3099992137d107f47ef4a863db2137607c8f86f094bcd981e90443ac38
|
7
|
+
data.tar.gz: 8fe124964ed3356cbb93bf5db4d1d491d8927020dce6226c0046a8068504ea21b427b99a25fd48b81b7b36ebc1702a23479ce4fe89189d4851551d5e703aa8c2
|
@@ -1,4 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'redis'
|
3
|
+
require 'connection_pool'
|
3
4
|
config = YAML.safe_load(ERB.new(IO.read(Rails.root.join('config', 'redis.yml'))).result)[Rails.env].with_indifferent_access
|
4
|
-
|
5
|
+
config[:thread_safe] = true
|
6
|
+
|
7
|
+
size = ENV.fetch("HYRAX_REDIS_POOL_SIZE", 5)
|
8
|
+
timeout = ENV.fetch("HYRAX_REDIS_TIMEOUT", 5)
|
9
|
+
|
10
|
+
Hyrax.config.redis_connection =
|
11
|
+
ConnectionPool::Wrapper.new(size: size, timeout: timeout) { Redis.new(config) }
|
@@ -1,4 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'redis'
|
3
|
+
require 'connection_pool'
|
3
4
|
config = YAML.safe_load(ERB.new(IO.read(Rails.root.join('config', 'redis.yml'))).result)[Rails.env].with_indifferent_access
|
4
|
-
|
5
|
+
config[:thread_safe] = true
|
6
|
+
|
7
|
+
size = ENV.fetch("HYRAX_REDIS_POOL_SIZE", 5)
|
8
|
+
timeout = ENV.fetch("HYRAX_REDIS_TIMEOUT", 5)
|
9
|
+
|
10
|
+
Hyrax.config.redis_connection =
|
11
|
+
ConnectionPool::Wrapper.new(size: size, timeout: timeout) { Redis.new(config) }
|
data/.regen
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# When updating CI regen seed, set to current date.
|
2
|
-
2023-
|
2
|
+
2023-05-15T10:04:07
|
data/CONTAINERS.md
CHANGED
@@ -191,7 +191,7 @@ We publish several Hyrax images to the [GitHub container registry][ghcr] under
|
|
191
191
|
the [Samvera organization][samvera-packages]. To build them:
|
192
192
|
|
193
193
|
```sh
|
194
|
-
export HYRAX_VERSION=v4.0.0.
|
194
|
+
export HYRAX_VERSION=v4.0.0.rc3 # or desired version
|
195
195
|
git checkout hyrax-$HYRAX_VERSION
|
196
196
|
|
197
197
|
docker build --target hyrax-base --tag ghcr.io/samvera/hyrax/hyrax-base:$(git rev-parse HEAD) .
|
data/README.md
CHANGED
@@ -42,7 +42,7 @@ Hyrax offers the ability to:
|
|
42
42
|
|
43
43
|
More detailed documentation about Hyrax is available on the [Hyrax Github Wiki](https://github.com/samvera/hyrax/wiki) but if you have questions or need help, please email the [Samvera community tech list](https://samvera.atlassian.net/wiki/spaces/samvera/pages/1171226735/Samvera+Community+Email+Lists#Samvera-Tech-(15-20-messages-per-week-on-average)) or stop by the #dev channel in the [Samvera community Slack team](https://samvera.atlassian.net/wiki/spaces/samvera/pages/405211682/Getting+Started+in+the+Samvera+Community#Join-the-Samvera-Slack-workspace). You can also get in touch with the [Hyrax Maintenance Working Group](https://samvera.atlassian.net/wiki/spaces/samvera/pages/496632295/Hyrax+Maintenance+Working+Group), including the Hyrax Product Owner and Hyrax Tech Lead.
|
44
44
|
|
45
|
-
[Reporting Issues](./.github/SUPPORT.md)
|
45
|
+
[Reporting Issues](./.github/SUPPORT.md)
|
46
46
|
|
47
47
|
## How to Run the Code
|
48
48
|
|
@@ -79,4 +79,4 @@ This software has been developed by and is brought to you by the Samvera communi
|
|
79
79
|
|
80
80
|
## License
|
81
81
|
|
82
|
-
Hyrax is available under [the Apache 2.0 license](LICENSE).
|
82
|
+
Hyrax is available under [the Apache 2.0 license](LICENSE).
|
@@ -12,7 +12,7 @@ class Hyrax::BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Buil
|
|
12
12
|
def render
|
13
13
|
return "" if @elements.blank?
|
14
14
|
|
15
|
-
@context.tag.nav(breadcrumbs_options) do
|
15
|
+
@context.tag.nav(**breadcrumbs_options) do
|
16
16
|
@context.tag.ol do
|
17
17
|
safe_join(@elements.uniq.collect { |e| render_element(e) })
|
18
18
|
end
|
@@ -80,10 +80,7 @@ module Hyrax
|
|
80
80
|
files =
|
81
81
|
query_service.custom_queries.find_many_file_metadata_by_use(resource: file_set, use: use)
|
82
82
|
|
83
|
-
raise
|
84
|
-
files.empty?
|
85
|
-
|
86
|
-
files.first
|
83
|
+
files.first || raise(Valkyrie::Persistence::ObjectNotFoundError, "FileSet #{file_set.id}'s #{use.fragment} is missing.")
|
87
84
|
end
|
88
85
|
end
|
89
86
|
end
|
@@ -4,24 +4,54 @@ module Hyrax
|
|
4
4
|
class LockManager
|
5
5
|
class UnableToAcquireLockError < StandardError; end
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
##
|
9
8
|
# @param [Fixnum] time_to_live How long to hold the lock in milliseconds
|
10
9
|
# @param [Fixnum] retry_count How many times to retry to acquire the lock before raising UnableToAcquireLockError
|
11
10
|
# @param [Fixnum] retry_delay Maximum wait time in milliseconds before retrying. Wait time is a random value between 0 and retry_delay.
|
12
11
|
def initialize(time_to_live, retry_count, retry_delay)
|
13
12
|
@ttl = time_to_live
|
14
|
-
@
|
13
|
+
@retry_count = retry_count
|
14
|
+
@retry_delay = retry_delay
|
15
15
|
end
|
16
16
|
|
17
|
+
##
|
17
18
|
# Blocks until lock is acquired or timeout.
|
18
19
|
def lock(key)
|
19
20
|
returned_from_block = nil
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
|
22
|
+
pool.then do |conn|
|
23
|
+
client(conn).lock(key, @ttl) do |locked|
|
24
|
+
raise UnableToAcquireLockError unless locked
|
25
|
+
returned_from_block = yield
|
26
|
+
end
|
23
27
|
end
|
28
|
+
|
24
29
|
returned_from_block
|
30
|
+
rescue ConnectionPool::TimeoutError => err
|
31
|
+
Hyrax.logger.error(err.message)
|
32
|
+
raise(ConnectionPool::TimeoutError,
|
33
|
+
"Failed to aquire a lock from Redlock due to a Redis connection " /
|
34
|
+
"timeout: #{err}. If you are using Redis via `ConnectionPool` " /
|
35
|
+
"you may wish to increase the pool size.")
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
##
|
41
|
+
# @api_private
|
42
|
+
def client(conn)
|
43
|
+
Redlock::Client.new([conn], retry_count: @retry_count, retry_delay: @retry_delay)
|
44
|
+
end
|
45
|
+
|
46
|
+
##
|
47
|
+
# @api private
|
48
|
+
#
|
49
|
+
# @note support both a ConnectionPool and a raw Redis client for now.
|
50
|
+
# we should drop support for `Redis.current` in 5.0.0.
|
51
|
+
# `#then` supports both options. for a ConnectionPool it will block
|
52
|
+
# until a connection is available.
|
53
|
+
def pool
|
54
|
+
Hyrax.config.redis_connection || Redis.current
|
25
55
|
end
|
26
56
|
end
|
27
57
|
end
|
@@ -16,7 +16,7 @@
|
|
16
16
|
<%= render 'hyrax/dashboard/sidebar' %>
|
17
17
|
</div>
|
18
18
|
<div class="main-content maximized<%= " admin-stats" if request.fullpath.include? '/admin/stats' %>">
|
19
|
-
<%= render_breadcrumbs builder: Hyrax
|
19
|
+
<%= render_breadcrumbs builder: Hyrax.config.breadcrumb_builder %>
|
20
20
|
<%= render '/flash_msg' %>
|
21
21
|
<% if content_for?(:page_header) %>
|
22
22
|
<div class="row">
|
@@ -15,7 +15,7 @@
|
|
15
15
|
<div id="content-wrapper" class="container" role="main">
|
16
16
|
<%= content_for(:container_header) %>
|
17
17
|
<%= render '/flash_msg' %>
|
18
|
-
<%= render_breadcrumbs builder: Hyrax
|
18
|
+
<%= render_breadcrumbs builder: Hyrax.config.breadcrumb_builder %>
|
19
19
|
<% if content_for?(:page_header) %>
|
20
20
|
<div class="row">
|
21
21
|
<div class="col-12 main-header">
|
data/docker-compose-koppie.yml
CHANGED
data/docker-compose.yml
CHANGED
@@ -50,7 +50,7 @@ The Samvera community is here to help. Please see our [support guide](../.github
|
|
50
50
|
# Getting started
|
51
51
|
|
52
52
|
This document contains instructions specific to setting up an app with __Hyrax
|
53
|
-
v4.0.0.
|
53
|
+
v4.0.0.rc3__. If you are looking for instructions on installing a different
|
54
54
|
version, be sure to select the appropriate branch or tag from the drop-down
|
55
55
|
menu above.
|
56
56
|
|
@@ -159,7 +159,7 @@ NOTE: The steps need to be done in order to create a new Hyrax based app.
|
|
159
159
|
Generate a new Rails application using the template.
|
160
160
|
|
161
161
|
```
|
162
|
-
rails _6.1.7.3_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/hyrax-v4.0.0.
|
162
|
+
rails _6.1.7.3_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/hyrax-v4.0.0.rc3/template.rb
|
163
163
|
```
|
164
164
|
|
165
165
|
Generating a new Rails application using Hyrax's template above takes cares of a number of steps for you, including:
|
data/hyrax.gemspec
CHANGED
@@ -41,6 +41,7 @@ SUMMARY
|
|
41
41
|
spec.add_dependency 'browse-everything', '>= 0.16', '< 2.0'
|
42
42
|
spec.add_dependency 'carrierwave', '~> 1.0'
|
43
43
|
spec.add_dependency 'clipboard-rails', '~> 1.5'
|
44
|
+
spec.add_dependency 'connection_pool', '~> 2.4'
|
44
45
|
spec.add_dependency 'draper', '~> 4.0'
|
45
46
|
spec.add_dependency 'dry-events', '~> 0.2.0'
|
46
47
|
spec.add_dependency 'dry-equalizer', '~> 0.2'
|
@@ -1,4 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'redis'
|
3
|
+
require 'connection_pool'
|
3
4
|
config = YAML.safe_load(ERB.new(IO.read(Rails.root.join('config', 'redis.yml'))).result)[Rails.env].with_indifferent_access
|
4
|
-
|
5
|
+
config[:thread_safe] = true
|
6
|
+
|
7
|
+
size = ENV.fetch("HYRAX_REDIS_POOL_SIZE", 5)
|
8
|
+
timeout = ENV.fetch("HYRAX_REDIS_TIMEOUT", 5)
|
9
|
+
|
10
|
+
Hyrax.config.redis_connection =
|
11
|
+
ConnectionPool::Wrapper.new(size: size, timeout: timeout) { Redis.new(config) }
|
data/lib/hyrax/configuration.rb
CHANGED
@@ -393,6 +393,11 @@ module Hyrax
|
|
393
393
|
@banner_image ||= 'https://user-images.githubusercontent.com/101482/29949206-ffa60d2c-8e67-11e7-988d-4910b8787d56.jpg'
|
394
394
|
end
|
395
395
|
|
396
|
+
attr_writer :breadcrumb_builder
|
397
|
+
def breadcrumb_builder
|
398
|
+
@breadcrumb_builder ||= Hyrax::BootstrapBreadcrumbsBuilder
|
399
|
+
end
|
400
|
+
|
396
401
|
##
|
397
402
|
# @return [Boolean]
|
398
403
|
def disable_wings
|
@@ -611,9 +616,10 @@ module Hyrax
|
|
611
616
|
@persistent_hostpath ||= "http://localhost/files/"
|
612
617
|
end
|
613
618
|
|
619
|
+
attr_accessor :redis_connection
|
614
620
|
attr_writer :redis_namespace
|
615
621
|
def redis_namespace
|
616
|
-
@redis_namespace ||= "hyrax"
|
622
|
+
@redis_namespace ||= ENV.fetch("HYRAX_REDIS_NAMESPACE", "hyrax")
|
617
623
|
end
|
618
624
|
|
619
625
|
attr_writer :libreoffice_path
|
@@ -7,9 +7,11 @@ module Hyrax
|
|
7
7
|
class << self
|
8
8
|
# @return [Fixnum, nil] the id of the event, or `nil` on failure(?!)
|
9
9
|
def create(action, timestamp)
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
instance.then do |redis|
|
11
|
+
event_id = redis.incr("events:latest_id")
|
12
|
+
redis.hmset("events:#{event_id}", "action", action, "timestamp", timestamp)
|
13
|
+
event_id
|
14
|
+
end
|
13
15
|
rescue Redis::CommandError => e
|
14
16
|
logger.error("unable to create event: #{e}")
|
15
17
|
nil
|
@@ -23,12 +25,16 @@ module Hyrax
|
|
23
25
|
#
|
24
26
|
# @return [Redis]
|
25
27
|
def instance
|
26
|
-
|
27
|
-
|
28
|
+
connection = Hyrax.config.redis_connection || Redis.current
|
29
|
+
|
30
|
+
if connection.is_a? Redis::Namespace
|
31
|
+
connection.namespace = namespace
|
32
|
+
connection
|
33
|
+
elsif connection == Redis.current
|
34
|
+
Redis.current = Redis::Namespace.new(namespace, redis: connection)
|
28
35
|
else
|
29
|
-
|
36
|
+
connection
|
30
37
|
end
|
31
|
-
Redis.current
|
32
38
|
end
|
33
39
|
|
34
40
|
##
|
@@ -44,11 +50,13 @@ module Hyrax
|
|
44
50
|
#
|
45
51
|
# @return [Enumerable<Hash<Symbol, String>>]
|
46
52
|
def fetch(size)
|
47
|
-
RedisEventStore.instance.
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
53
|
+
Hyrax::RedisEventStore.instance.then do |redis|
|
54
|
+
redis.lrange(@key, 0, size).map do |event_id|
|
55
|
+
{
|
56
|
+
action: redis.hget("events:#{event_id}", "action"),
|
57
|
+
timestamp: redis.hget("events:#{event_id}", "timestamp")
|
58
|
+
}
|
59
|
+
end
|
52
60
|
end
|
53
61
|
rescue Redis::CommandError, Redis::CannotConnectError
|
54
62
|
RedisEventStore.logger.error("unable to fetch event: #{@key}")
|
@@ -62,7 +70,7 @@ module Hyrax
|
|
62
70
|
#
|
63
71
|
# @return [Integer, nil] the value successfully pushed; or `nil` on failure(!?)
|
64
72
|
def push(value)
|
65
|
-
RedisEventStore.instance.lpush(@key, value)
|
73
|
+
Hyrax::RedisEventStore.instance.then { |r| r.lpush(@key, value) }
|
66
74
|
rescue Redis::CommandError, Redis::CannotConnectError
|
67
75
|
RedisEventStore.logger.error("unable to push event: #{@key}")
|
68
76
|
nil
|
data/lib/hyrax/version.rb
CHANGED
data/template.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# Hack for https://github.com/rails/rails/issues/35153
|
3
3
|
gsub_file 'Gemfile', /^gem ["']sqlite3["']$/, 'gem "sqlite3", "~> 1.3.0"'
|
4
|
-
gem 'hyrax', '4.0.0.
|
4
|
+
gem 'hyrax', '4.0.0.rc3'
|
5
5
|
run 'bundle install'
|
6
6
|
generate 'hyrax:install', '-f'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyrax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2023-05-
|
17
|
+
date: 2023-05-15 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: rails
|
@@ -162,6 +162,20 @@ dependencies:
|
|
162
162
|
- - "~>"
|
163
163
|
- !ruby/object:Gem::Version
|
164
164
|
version: '1.5'
|
165
|
+
- !ruby/object:Gem::Dependency
|
166
|
+
name: connection_pool
|
167
|
+
requirement: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - "~>"
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '2.4'
|
172
|
+
type: :runtime
|
173
|
+
prerelease: false
|
174
|
+
version_requirements: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - "~>"
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '2.4'
|
165
179
|
- !ruby/object:Gem::Dependency
|
166
180
|
name: draper
|
167
181
|
requirement: !ruby/object:Gem::Requirement
|