summaryrefslogtreecommitdiff
path: root/lib/api/api.rb
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-05-10 20:14:40 +0000
committerRobert Speicher <robert@gitlab.com>2016-05-10 20:14:40 +0000
commit971662e6a4039af98ac02f3f5f25804ba3d5da8f (patch)
treedb5aa8e724e975d66f6d7c322788861858905555 /lib/api/api.rb
parent634f02b0950048ee97c1d92c4f3051aedd121dc5 (diff)
parent5589dcf8db0daf2235158724f6b18115a9abfa42 (diff)
downloadgitlab-ce-971662e6a4039af98ac02f3f5f25804ba3d5da8f.tar.gz
Merge branch 'stanhu/gitlab-ce-add-eager-load-lib' into 'master'
Add eager load paths to help prevent dependency load issues with Sidekiq workers _Originally opened at !3545 by @stanhu._ - - - Relevant resources: - https://github.com/mperham/sidekiq/wiki/FAQ#why-doesnt-sidekiq-autoload-my-rails-application-code - https://github.com/mperham/sidekiq/issues/1281#issuecomment-27129904 - http://blog.arkency.com/2014/11/dont-forget-about-eager-load-when-extending-autoload - https://github.com/rails/rails/blob/52ce6ece8c8f74064bb64e0a0b1ddd83092718e1/railties/lib/rails/engine.rb#L472-L479 - https://github.com/rails/rails/blob/v4.2.6/railties/lib/rails/paths.rb Attempts to address #3661, #11896, #12769, #13521, #14131, #14589, #14759, #14825. See merge request !3724
Diffstat (limited to 'lib/api/api.rb')
-rw-r--r--lib/api/api.rb69
1 files changed, 34 insertions, 35 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb
index cc1004f8005..5fd9c30cb42 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -1,5 +1,3 @@
-Dir["#{Rails.root}/lib/api/*.rb"].each {|file| require file}
-
module API
class API < Grape::API
include APIGuard
@@ -25,38 +23,39 @@ module API
format :json
content_type :txt, "text/plain"
- helpers Helpers
-
- mount Groups
- mount GroupMembers
- mount Users
- mount Projects
- mount Repositories
- mount Issues
- mount Milestones
- mount Session
- mount MergeRequests
- mount Notes
- mount Internal
- mount SystemHooks
- mount ProjectSnippets
- mount ProjectMembers
- mount DeployKeys
- mount ProjectHooks
- mount Services
- mount Files
- mount Commits
- mount CommitStatus
- mount Namespaces
- mount Branches
- mount Labels
- mount Settings
- mount Keys
- mount Tags
- mount Triggers
- mount Builds
- mount Variables
- mount Runners
- mount Licenses
+ # Ensure the namespace is right, otherwise we might load Grape::API::Helpers
+ helpers ::API::Helpers
+
+ mount ::API::Groups
+ mount ::API::GroupMembers
+ mount ::API::Users
+ mount ::API::Projects
+ mount ::API::Repositories
+ mount ::API::Issues
+ mount ::API::Milestones
+ mount ::API::Session
+ mount ::API::MergeRequests
+ mount ::API::Notes
+ mount ::API::Internal
+ mount ::API::SystemHooks
+ mount ::API::ProjectSnippets
+ mount ::API::ProjectMembers
+ mount ::API::DeployKeys
+ mount ::API::ProjectHooks
+ mount ::API::Services
+ mount ::API::Files
+ mount ::API::Commits
+ mount ::API::CommitStatuses
+ mount ::API::Namespaces
+ mount ::API::Branches
+ mount ::API::Labels
+ mount ::API::Settings
+ mount ::API::Keys
+ mount ::API::Tags
+ mount ::API::Triggers
+ mount ::API::Builds
+ mount ::API::Variables
+ mount ::API::Runners
+ mount ::API::Licenses
end
end