Skip to content

[couchbase] Add support for scopes and collections. #4805

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

daschl
Copy link
Member

@daschl daschl commented Dec 29, 2021

This changeset allows to specify scopes and collections to be automatically
created, which is available with Couchbase Server 7.0 and later.

The BucketDefinition is expanded to take a ScopeDefinition which itself
can be configured with CollectionDefinitions. During startup, after the
bucket is created, the scopes and collections are stored on the server.

Note that as a nice "bonus", similar to a primary index being automatically
created on a bucket by default (can be turned off), this change also
automatically adds a primary index for each collection created, as long
as the query service is also enabled.

If the server does not support it, a descriptive error message is shown.

Further Reviewer notes:

 - The primary index creation and keyspace checks have been refactored
   into their own methods since they are now called from two places: once
   for the bucket only and once for bucket, scope and collection triple.
 - A test case has been added to verify using custom scopes and collections.
   To make this work, the enterprise image has been bumped to 7.0 from 6.6.
   The community image is left at 6.6 - we could bump it too, but this gives
   us a little more test coverage on server versions (pre and post collection
   support) for free.

…ion).

This changeset explicitly configures the service memory quotas to their
documented limits by default. This ensures that if a service is enabled,
it does not consume more memory than absolutely needed. This is important
because some services (like analytics) try to grab memory available which
is good for production but of limited use in a testcontainers setting.

A new API is also added which allows to customize the memory quota for
each service should the test case require more than the minimum (which
for most services is 256MB anyways).
This changeset allows to specify scopes and collections to be automatically
created, which is available with Couchbase Server 7.0 and later.

The BucketDefinition is expanded to take a ScopeDefinition which itself
can be configured with CollectionDefinitions. During startup, after the
bucket is created, the scopes and collections are stored on the server.

Note that as a nice "bonus", similar to a primary index being automatically
created on a bucket by default (can be turned off), this change also
automatically adds a primary index for each collection created, as long
as the query service is also enabled.

If the server does not support it, a descriptive error message is shown.

Further Reviewer notes:

 - The primary index creation and keyspace checks have been refactored
   into their own methods since they are now called from two places: once
   for the bucket only and once for bucket, scope and collection triple.
 - A test case has been added to verify using custom scopes and collections.
   To make this work, the enterprise image has been bumped to 7.0 from 6.6.
   The community image is left at 6.6 - we could bump it too, but this gives
   us a little more test coverage on server versions (pre and post collection
   support) for free.
@daschl
Copy link
Member Author

daschl commented Dec 29, 2021

This change needs to be rebased after the service quota change is merged, since I built it on top to avoid having to rework it quite a bit.

@kiview
Copy link
Member

kiview commented Jan 3, 2022

Since this only works since version 7.0, do you think you could make use of ComparableVersion and report incompatibility once a user tries to set scopes or collections?

@daschl
Copy link
Member Author

daschl commented Jan 5, 2022

Since this only works since version 7.0, do you think you could make use of ComparableVersion and report incompatibility once a user tries to set scopes or collections?

yes, that's doable - I'll add that

@rnorth rnorth added this to the next milestone Jan 5, 2022
@bsideup bsideup modified the milestones: 1.16.3, next Jan 18, 2022
@kiview kiview removed this from the next milestone Apr 7, 2022
@eddumelendez eddumelendez requested a review from a team as a code owner November 19, 2024 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants