From 89935e217410ffc1234abdf67b2486f308a53593 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 27 Jan 2026 10:41:47 +0100 Subject: [PATCH] :sparkles: Make nitrate module loading conditional to flag This removes the flag checking on each rpc method --- backend/src/app/rpc.clj | 10 +++--- backend/src/app/rpc/management/nitrate.clj | 36 +++++++++------------- common/src/app/common/types/team.cljc | 2 +- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/backend/src/app/rpc.clj b/backend/src/app/rpc.clj index 3eeac4b409..a9cef88868 100644 --- a/backend/src/app/rpc.clj +++ b/backend/src/app/rpc.clj @@ -298,10 +298,12 @@ (defn- resolve-management-methods [cfg] - (let [cfg (assoc cfg ::type "management" ::metrics-id :rpc-management-timing)] - (->> (sv/scan-ns - 'app.rpc.management.nitrate - 'app.rpc.management.exporter) + (let [cfg (assoc cfg ::type "management" ::metrics-id :rpc-management-timing) + mods (cond->> (list 'app.rpc.management.exporter) + (contains? cf/flags :nitrate) + (cons 'app.rpc.management.nitrate))] + + (->> (apply sv/scan-ns mods) (map (partial process-method cfg "management" wrap-management)) (into {})))) diff --git a/backend/src/app/rpc/management/nitrate.clj b/backend/src/app/rpc/management/nitrate.clj index 3f1ff0c6ab..42e0e10375 100644 --- a/backend/src/app/rpc/management/nitrate.clj +++ b/backend/src/app/rpc/management/nitrate.clj @@ -12,7 +12,6 @@ [app.common.types.profile :refer [schema:profile]] [app.common.types.team :refer [schema:team]] [app.common.uuid :as uuid] - [app.config :as cf] [app.db :as db] [app.msgbus :as mbus] [app.rpc :as-alias rpc] @@ -26,6 +25,7 @@ (sv/defmethod ::authenticate "Authenticate the current user" {::doc/added "2.14" + ::sm/params [:map] ::sm/result schema:profile} [cfg {:keys [::rpc/profile-id] :as params}] (let [profile (profile/get-profile cfg profile-id)] @@ -51,12 +51,12 @@ (sv/defmethod ::get-teams "List teams for which current user is owner" {::doc/added "2.14" + ::sm/params [:map] ::sm/result schema:get-teams-result} [cfg {:keys [::rpc/profile-id]}] - (when (contains? cf/flags :nitrate) - (let [current-user-id (-> (profile/get-profile cfg profile-id) :id)] - (->> (db/exec! cfg [sql:get-teams current-user-id]) - (map #(select-keys % [:id :name])))))) + (let [current-user-id (-> (profile/get-profile cfg profile-id) :id)] + (->> (db/exec! cfg [sql:get-teams current-user-id]) + (map #(select-keys % [:id :name]))))) ;; ---- API: notify-team-change @@ -71,20 +71,12 @@ ::sm/params schema:notify-team-change ::rpc/auth false} [cfg {:keys [id organization-id organization-name]}] - (when (contains? cf/flags :nitrate) - (let [msgbus (::mbus/msgbus cfg)] - (mbus/pub! msgbus - ;;TODO There is a bug on dashboard with teams notifications. - ;;For now we send it to uuid/zero instead of team-id - :topic uuid/zero - :message {:type :team-org-change - :team-id id - :organization-id organization-id - :organization-name organization-name})))) - - - - - - - + (let [msgbus (::mbus/msgbus cfg)] + (mbus/pub! msgbus + ;;TODO There is a bug on dashboard with teams notifications. + ;;For now we send it to uuid/zero instead of team-id + :topic uuid/zero + :message {:type :team-org-change + :team-id id + :organization-id organization-id + :organization-name organization-name}))) diff --git a/common/src/app/common/types/team.cljc b/common/src/app/common/types/team.cljc index 3ff2fd0184..ad9bac999c 100644 --- a/common/src/app/common/types/team.cljc +++ b/common/src/app/common/types/team.cljc @@ -22,7 +22,7 @@ ;; FIXME: specify more fields (def schema:team - [:map + [:map {:title "Team"} [:id ::sm/uuid] [:name :string]])