Skip to content

Commit

Permalink
Revert "centralised migration orchestration - directly publishing to …
Browse files Browse the repository at this point in the history
…leader project"

This reverts commit cc552fc.
  • Loading branch information
YabMas committed Jan 17, 2024
1 parent cc552fc commit c21eafd
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,21 @@
{:status 500
:body "Unexpected error"})))

; for now migration leaders are hardcoded to be in the us region
(defn ^:private project-id->migrations-topic [project-id]
(let [[app-name environment _] (->
project-id
(str/split #"-"))
leader-project (str/join "-" [app-name environment "us"])]
(str "projects/" leader-project "/topics/dare-migrations")))
(def ^:private migrations-topic "dare-migrations")

(defn ^:private handle-migration-event [{:keys [installation migration-data tenant-ref]}]
(let [tenant (:clientKey installation)
{:keys [phase start-time end-time]} migration-data]
(condp contains? (:phase migration-data)
#{"schedule"}
(let [source-project (get-project-id)
[app-name environment _] (->
source-project
(str/split #"-"))
[app-name stage _] (->
source-project
(str/split #"-"))
destination-region-label (str/lower-case (:location migration-data))
destination-project (str/join "-" [app-name environment destination-region-label])]
destination-project (str/join "-" [app-name stage destination-region-label])]
(pubsub/publish-message!
(project-id->migrations-topic source-project)
migrations-topic
{:attributes
{:tenant tenant
:source_project source-project
Expand Down

0 comments on commit c21eafd

Please sign in to comment.