-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(server): new projects are placed in a configurable region #3801
Changes from all commits
65c4a8b
f30f143
7aebe10
a9b73fb
b94c302
6d49b83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,13 @@ import { | |
insertCommitsFactory, | ||
insertStreamCommitsFactory | ||
} from '@/modules/core/repositories/commits' | ||
import { storeModelFactory } from '@/modules/core/repositories/models' | ||
import { | ||
deleteProjectFactory, | ||
getProjectFactory, | ||
storeProjectFactory, | ||
storeProjectRoleFactory | ||
} from '@/modules/core/repositories/projects' | ||
import { getServerInfoFactory } from '@/modules/core/repositories/server' | ||
import { | ||
getStreamFactory, | ||
|
@@ -50,6 +57,7 @@ import { | |
getUserStreamsCountFactory | ||
} from '@/modules/core/repositories/streams' | ||
import { getUserFactory, getUsersFactory } from '@/modules/core/repositories/users' | ||
import { createNewProjectFactory } from '@/modules/core/services/projects' | ||
import { | ||
getRateLimitResult, | ||
isRateLimitBreached | ||
|
@@ -69,7 +77,11 @@ import { | |
} from '@/modules/core/services/streams/management' | ||
import { createOnboardingStreamFactory } from '@/modules/core/services/streams/onboarding' | ||
import { getOnboardingBaseProjectFactory } from '@/modules/cross-server-sync/services/onboardingProject' | ||
import { getProjectDbClient } from '@/modules/multiregion/utils/dbSelector' | ||
import { | ||
getDb, | ||
getProjectDbClient, | ||
getValidDefaultProjectRegionKey | ||
} from '@/modules/multiregion/utils/dbSelector' | ||
import { | ||
deleteAllResourceInvitesFactory, | ||
findUserByTargetFactory, | ||
|
@@ -284,10 +296,23 @@ export = { | |
throw new RateLimitError(rateLimitResult) | ||
} | ||
|
||
const project = await createStreamReturnRecord({ | ||
const regionKey = await getValidDefaultProjectRegionKey() | ||
const projectDb = await getDb({ regionKey }) | ||
|
||
const createNewProject = createNewProjectFactory({ | ||
storeProject: storeProjectFactory({ db: projectDb }), | ||
getProject: getProjectFactory({ db }), | ||
deleteProject: deleteProjectFactory({ db: projectDb }), | ||
storeModel: storeModelFactory({ db: projectDb }), | ||
// THIS MUST GO TO THE MAIN DB | ||
storeProjectRole: storeProjectRoleFactory({ db }), | ||
projectsEventsEmitter: ProjectsEmitter.emit | ||
}) | ||
|
||
const project = await createNewProject({ | ||
...(args.input || {}), | ||
ownerId: context.userId!, | ||
ownerResourceAccessRules: context.resourceAccessRules | ||
regionKey | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It somehow seems like a duplication that we have to pass it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a property of the project. Given, that all functions are only implementing a domain operation, no DB clients are exposed to the business logic functions, so explicitly entering the region key is the appropriate solution on the right level. |
||
}) | ||
|
||
return project | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use this over
createStreamReturnRecord
? What's the purpose ofcreateStreamReturnRecord
and where should it be used, and can we add comments to document that? i.e. why was it being used here previously, and why is it no longer required?I think this is the bit of context I was missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createStreamReturnRecord is the old implementation, if you check how its written, its not compatible for creating multi region projects. That's why i had to write a new service for creating projects. The old one should not be used any more, but I did not have a need to replace it so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
createStreamReturnRecord
need to be replaced everywhere it's currently referenced? e.g. will we continue to have onboarding streams created in the incorrect region if it's not replaced?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we'll replace it there too, but that is not a big deal right now, so i did not want this PR to balloon.