hyrax 4.0.0.rc2 → 4.0.0.rc3

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: 24e7e9d00de4eebd2f2dfaf96bcd1a09ac9589b17e94ddcc0bf5681d3c93b0c4
4
- data.tar.gz: 92753b2fbb1271cfec93e2eddd07d11da1091eaf8b36494e754ac3400a83a6a1
3
+ metadata.gz: f7d9595ce45877e35b01b14d36cdefb89a1bb8978ab424bbe9907edcfebb693e
4
+ data.tar.gz: 516c7de64fc06ede1b8bd0843ad4ad98b01d39f7440c4723e72235880d52d34a
5
5
  SHA512:
6
- metadata.gz: 16a328b5b11d826f8149f0b260675ffe913d7e41a4b5c37035696cb32741b650a9f4bf9fa0d70ed08a1be712ddc8b452824bfb5be60a99b1a9d52ead57d8b7f3
7
- data.tar.gz: bff8a0b37d073e1014f9566472030bb2b22e16a19fc1413dec6405cf21d6c3f178b0644ecbb48ee8ed0d259fe4f1b0422e747a5f3192c63753dc76d89ba8cb33
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
- Redis.current = Redis.new(config.merge(thread_safe: true))
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
- Redis.current = Redis.new(config.merge(thread_safe: true))
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-04-11T16:25:55
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.rc2 # or desired version
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 Valkyrie::Persistence::ObjectNotFoundError, "FileSet #{file_set.id}'s #{use.fragment} is missing." if
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
- attr_reader :client
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
- @client = Redlock::Client.new([Redis.current], retry_count: retry_count, retry_delay: retry_delay)
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
- client.lock(key, @ttl) do |locked|
21
- raise UnableToAcquireLockError unless locked
22
- returned_from_block = yield
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::BootstrapBreadcrumbsBuilder %>
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::BootstrapBreadcrumbsBuilder %>
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">
@@ -104,7 +104,6 @@ services:
104
104
 
105
105
  postgres:
106
106
  image: postgres:latest
107
- restart: always
108
107
  env_file:
109
108
  - .koppie/.env
110
109
  ports:
data/docker-compose.yml CHANGED
@@ -99,7 +99,6 @@ services:
99
99
 
100
100
  postgres:
101
101
  image: postgres:latest
102
- restart: always
103
102
  environment:
104
103
  - POSTGRES_USER=hyrax_user
105
104
  - POSTGRES_PASSWORD=hyrax_password
@@ -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.rc2__. If you are looking for instructions on installing a different
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.rc2/template.rb
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
- Redis.current = Redis.new(config.merge(thread_safe: true))
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) }
@@ -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
- event_id = instance.incr("events:latest_id")
11
- instance.hmset("events:#{event_id}", "action", action, "timestamp", timestamp)
12
- event_id
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
- if Redis.current.is_a? Redis::Namespace
27
- Redis.current.namespace = namespace
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
- Redis.current = Redis::Namespace.new(namespace, redis: Redis.current)
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.lrange(@key, 0, size).map do |event_id|
48
- {
49
- action: RedisEventStore.instance.hget("events:#{event_id}", "action"),
50
- timestamp: RedisEventStore.instance.hget("events:#{event_id}", "timestamp")
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
- VERSION = '4.0.0.rc2'
3
+ VERSION = '4.0.0.rc3'
4
4
  end
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.rc2'
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.rc2
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-01 00:00:00.000000000 Z
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