mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-18 02:08:16 +00:00
Compare commits
8 Commits
40493cf1df
...
0dcc361d6c
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0dcc361d6c | ||
![]() |
74fc4dbacf | ||
![]() |
84fb6869e2 | ||
![]() |
07370ab5cf | ||
![]() |
7436398308 | ||
![]() |
05626a0ded | ||
![]() |
20e7d98192 | ||
![]() |
abdd738c1a |
2
Gemfile
2
Gemfile
|
@ -88,7 +88,7 @@ gem 'sidekiq-scheduler', '~> 5.0'
|
||||||
gem 'sidekiq-unique-jobs', '> 8'
|
gem 'sidekiq-unique-jobs', '> 8'
|
||||||
gem 'simple_form', '~> 5.2'
|
gem 'simple_form', '~> 5.2'
|
||||||
gem 'simple-navigation', '~> 4.4'
|
gem 'simple-navigation', '~> 4.4'
|
||||||
gem 'stoplight', '~> 4.1'
|
gem 'stoplight'
|
||||||
gem 'strong_migrations'
|
gem 'strong_migrations'
|
||||||
gem 'tty-prompt', '~> 0.23', require: false
|
gem 'tty-prompt', '~> 0.23', require: false
|
||||||
gem 'twitter-text', '~> 3.1.0'
|
gem 'twitter-text', '~> 3.1.0'
|
||||||
|
|
|
@ -715,8 +715,6 @@ GEM
|
||||||
redis (4.8.1)
|
redis (4.8.1)
|
||||||
redis-client (0.24.0)
|
redis-client (0.24.0)
|
||||||
connection_pool
|
connection_pool
|
||||||
redlock (1.3.2)
|
|
||||||
redis (>= 3.0.0, < 6.0)
|
|
||||||
regexp_parser (2.10.0)
|
regexp_parser (2.10.0)
|
||||||
reline (0.6.1)
|
reline (0.6.1)
|
||||||
io-console (~> 0.5)
|
io-console (~> 0.5)
|
||||||
|
@ -852,8 +850,8 @@ GEM
|
||||||
stackprof (0.2.27)
|
stackprof (0.2.27)
|
||||||
starry (0.2.0)
|
starry (0.2.0)
|
||||||
base64
|
base64
|
||||||
stoplight (4.1.1)
|
stoplight (5.2.0)
|
||||||
redlock (~> 1.0)
|
zeitwerk
|
||||||
stringio (3.1.7)
|
stringio (3.1.7)
|
||||||
strong_migrations (2.4.0)
|
strong_migrations (2.4.0)
|
||||||
activerecord (>= 7.1)
|
activerecord (>= 7.1)
|
||||||
|
@ -1085,7 +1083,7 @@ DEPENDENCIES
|
||||||
simplecov (~> 0.22)
|
simplecov (~> 0.22)
|
||||||
simplecov-lcov (~> 0.8)
|
simplecov-lcov (~> 0.8)
|
||||||
stackprof
|
stackprof
|
||||||
stoplight (~> 4.1)
|
stoplight
|
||||||
strong_migrations
|
strong_migrations
|
||||||
test-prof
|
test-prof
|
||||||
thor (~> 1.2)
|
thor (~> 1.2)
|
||||||
|
|
|
@ -9,6 +9,8 @@ module SignatureVerification
|
||||||
|
|
||||||
EXPIRATION_WINDOW_LIMIT = 12.hours
|
EXPIRATION_WINDOW_LIMIT = 12.hours
|
||||||
CLOCK_SKEW_MARGIN = 1.hour
|
CLOCK_SKEW_MARGIN = 1.hour
|
||||||
|
STOPLIGHT_COOL_OFF_TIME = 5.minutes.seconds
|
||||||
|
STOPLIGHT_THRESHOLD = 1
|
||||||
|
|
||||||
def require_account_signature!
|
def require_account_signature!
|
||||||
render json: signature_verification_failure_reason, status: signature_verification_failure_code unless signed_request_account
|
render json: signature_verification_failure_reason, status: signature_verification_failure_code unless signed_request_account
|
||||||
|
@ -107,10 +109,12 @@ module SignatureVerification
|
||||||
end
|
end
|
||||||
|
|
||||||
def stoplight_wrapper
|
def stoplight_wrapper
|
||||||
Stoplight("source:#{request.remote_ip}")
|
Stoplight(
|
||||||
.with_threshold(1)
|
"source:#{request.remote_ip}",
|
||||||
.with_cool_off_time(5.minutes.seconds)
|
cool_off_time: STOPLIGHT_COOL_OFF_TIME,
|
||||||
.with_error_handler { |error, handle| error.is_a?(HTTP::Error) || error.is_a?(OpenSSL::SSL::SSLError) ? handle.call(error) : raise(error) }
|
threshold: STOPLIGHT_THRESHOLD,
|
||||||
|
tracked_errors: [HTTP::Error, OpenSSL::SSL::SSLError]
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def actor_refresh_key!(actor)
|
def actor_refresh_key!(actor)
|
||||||
|
|
|
@ -2848,7 +2848,6 @@ a.account__display-name {
|
||||||
&__pane {
|
&__pane {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
pointer-events: none;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
min-width: 285px;
|
min-width: 285px;
|
||||||
|
@ -2860,7 +2859,6 @@ a.account__display-name {
|
||||||
&__inner {
|
&__inner {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
width: 285px;
|
width: 285px;
|
||||||
pointer-events: auto;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class BulkImportRowService
|
class BulkImportRowService
|
||||||
|
STOPLIGHT_COOL_OFF_TIME = 5.minutes.seconds
|
||||||
|
STOPLIGHT_THRESHOLD = 1
|
||||||
|
|
||||||
def call(row)
|
def call(row)
|
||||||
@account = row.bulk_import.account
|
@account = row.bulk_import.account
|
||||||
@data = row.data
|
@data = row.data
|
||||||
|
@ -10,7 +13,7 @@ class BulkImportRowService
|
||||||
when :following, :blocking, :muting, :lists
|
when :following, :blocking, :muting, :lists
|
||||||
target_acct = @data['acct']
|
target_acct = @data['acct']
|
||||||
target_domain = domain(target_acct)
|
target_domain = domain(target_acct)
|
||||||
@target_account = stoplight_wrapper(target_domain).run { ResolveAccountService.new.call(target_acct, { check_delivery_availability: true }) }
|
@target_account = stoplight_wrapper(target_domain).run(stoplight_fallback) { ResolveAccountService.new.call(target_acct, { check_delivery_availability: true }) }
|
||||||
return false if @target_account.nil?
|
return false if @target_account.nil?
|
||||||
when :bookmarks
|
when :bookmarks
|
||||||
target_uri = @data['uri']
|
target_uri = @data['uri']
|
||||||
|
@ -18,7 +21,7 @@ class BulkImportRowService
|
||||||
@target_status = ActivityPub::TagManager.instance.uri_to_resource(target_uri, Status)
|
@target_status = ActivityPub::TagManager.instance.uri_to_resource(target_uri, Status)
|
||||||
return false if @target_status.nil? && ActivityPub::TagManager.instance.local_uri?(target_uri)
|
return false if @target_status.nil? && ActivityPub::TagManager.instance.local_uri?(target_uri)
|
||||||
|
|
||||||
@target_status ||= stoplight_wrapper(target_domain).run { ActivityPub::FetchRemoteStatusService.new.call(target_uri) }
|
@target_status ||= stoplight_wrapper(target_domain).run(stoplight_fallback) { ActivityPub::FetchRemoteStatusService.new.call(target_uri) }
|
||||||
return false if @target_status.nil?
|
return false if @target_status.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,13 +54,18 @@ class BulkImportRowService
|
||||||
TagManager.instance.local_domain?(domain) ? nil : TagManager.instance.normalize_domain(domain)
|
TagManager.instance.local_domain?(domain) ? nil : TagManager.instance.normalize_domain(domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def stoplight_fallback
|
||||||
|
->(error) {}
|
||||||
|
end
|
||||||
|
|
||||||
def stoplight_wrapper(domain)
|
def stoplight_wrapper(domain)
|
||||||
if domain.present?
|
if domain.present?
|
||||||
Stoplight("source:#{domain}")
|
Stoplight(
|
||||||
.with_fallback { nil }
|
"source:#{domain}",
|
||||||
.with_threshold(1)
|
cool_off_time: STOPLIGHT_COOL_OFF_TIME,
|
||||||
.with_cool_off_time(5.minutes.seconds)
|
threshold: STOPLIGHT_THRESHOLD,
|
||||||
.with_error_handler { |error, handle| error.is_a?(HTTP::Error) || error.is_a?(OpenSSL::SSL::SSLError) ? handle.call(error) : raise(error) }
|
tracked_errors: [HTTP::Error, OpenSSL::SSL::SSLError]
|
||||||
|
)
|
||||||
else
|
else
|
||||||
Stoplight('domain-blank')
|
Stoplight('domain-blank')
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,8 +5,8 @@ class ActivityPub::DeliveryWorker
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
include JsonLdHelper
|
include JsonLdHelper
|
||||||
|
|
||||||
|
STOPLIGHT_COOL_OFF_TIME = 60
|
||||||
STOPLIGHT_FAILURE_THRESHOLD = 10
|
STOPLIGHT_FAILURE_THRESHOLD = 10
|
||||||
STOPLIGHT_COOLDOWN = 60
|
|
||||||
|
|
||||||
sidekiq_options queue: 'push', retry: 16, dead: false
|
sidekiq_options queue: 'push', retry: 16, dead: false
|
||||||
|
|
||||||
|
@ -75,9 +75,11 @@ class ActivityPub::DeliveryWorker
|
||||||
end
|
end
|
||||||
|
|
||||||
def stoplight_wrapper
|
def stoplight_wrapper
|
||||||
Stoplight(@inbox_url)
|
Stoplight(
|
||||||
.with_threshold(STOPLIGHT_FAILURE_THRESHOLD)
|
@inbox_url,
|
||||||
.with_cool_off_time(STOPLIGHT_COOLDOWN)
|
cool_off_time: STOPLIGHT_COOL_OFF_TIME,
|
||||||
|
threshold: STOPLIGHT_FAILURE_THRESHOLD
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def failure_tracker
|
def failure_tracker
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
require 'stoplight'
|
require 'stoplight'
|
||||||
|
|
||||||
Rails.application.reloader.to_prepare do
|
Rails.application.reloader.to_prepare do
|
||||||
Stoplight.default_data_store = Stoplight::DataStore::Redis.new(RedisConnection.new.connection)
|
Stoplight.configure do |config|
|
||||||
Stoplight.default_notifiers = [Stoplight::Notifier::Logger.new(Rails.logger)]
|
config.data_store = Stoplight::DataStore::Redis.new(RedisConnection.new.connection)
|
||||||
|
config.notifiers = [Stoplight::Notifier::Logger.new(Rails.logger)]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,8 +73,8 @@ module Paperclip
|
||||||
@url_generator.for_as_default(style_name)
|
@url_generator.for_as_default(style_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
STOPLIGHT_COOL_OFF_TIME = 30
|
||||||
STOPLIGHT_THRESHOLD = 10
|
STOPLIGHT_THRESHOLD = 10
|
||||||
STOPLIGHT_COOLDOWN = 30
|
|
||||||
|
|
||||||
# We overwrite this method to put a circuit breaker around
|
# We overwrite this method to put a circuit breaker around
|
||||||
# calls to object storage, to stop hitting APIs that are slow
|
# calls to object storage, to stop hitting APIs that are slow
|
||||||
|
@ -84,11 +84,12 @@ module Paperclip
|
||||||
# Don't go through Stoplight if we don't have anything object-storage-oriented to do
|
# Don't go through Stoplight if we don't have anything object-storage-oriented to do
|
||||||
return super if @queued_for_delete.empty? && @queued_for_write.empty? && !dirty?
|
return super if @queued_for_delete.empty? && @queued_for_write.empty? && !dirty?
|
||||||
|
|
||||||
Stoplight('object-storage')
|
Stoplight(
|
||||||
.with_threshold(STOPLIGHT_THRESHOLD)
|
'object-storage',
|
||||||
.with_cool_off_time(STOPLIGHT_COOLDOWN)
|
cool_off_time: STOPLIGHT_COOL_OFF_TIME,
|
||||||
.with_error_handler { |error, handle| error.is_a?(Seahorse::Client::NetworkingError) ? handle.call(error) : raise(error) }
|
threshold: STOPLIGHT_THRESHOLD,
|
||||||
.run { super }
|
tracked_errors: [Seahorse::Client::NetworkingError]
|
||||||
|
).run { super }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user