-
Notifications
You must be signed in to change notification settings - Fork 29
Add .activate
, .deactivate
, .offload
helpers to collection.tenants
#311
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
tsmith023
wants to merge
1
commit into
main
Choose a base branch
from
tenants/add-helpers-for-updating-statuses
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+65
−9
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,16 @@ const tenants = ( | |
}); | ||
return result; | ||
}); | ||
const update = async (tenants: TenantBC | TenantUpdate | (TenantBC | TenantUpdate)[]) => { | ||
const out: Tenant[] = []; | ||
for await (const res of Serialize.tenants(parseValueOrValueArray(tenants), Serialize.tenantUpdate).map( | ||
(tenants) => | ||
new TenantsUpdater(connection, collection, tenants).do().then((res) => res.map(parseTenantREST)) | ||
)) { | ||
out.push(...res); | ||
} | ||
return out; | ||
}; | ||
return { | ||
create: (tenants: TenantBC | TenantCreate | (TenantBC | TenantCreate)[]) => | ||
new TenantsCreator(connection, collection, parseValueOrValueArray(tenants).map(Serialize.tenantCreate)) | ||
|
@@ -72,15 +82,24 @@ const tenants = ( | |
collection, | ||
parseValueOrValueArray(tenants).map(parseStringOrTenant) | ||
).do(), | ||
update: async (tenants: TenantBC | TenantUpdate | (TenantBC | TenantUpdate)[]) => { | ||
const out: Tenant[] = []; | ||
for await (const res of Serialize.tenants(parseValueOrValueArray(tenants), Serialize.tenantUpdate).map( | ||
(tenants) => | ||
new TenantsUpdater(connection, collection, tenants).do().then((res) => res.map(parseTenantREST)) | ||
)) { | ||
out.push(...res); | ||
} | ||
return out; | ||
update, | ||
activate: (tenant: string | TenantBase) => { | ||
return update({ | ||
name: parseStringOrTenant(tenant), | ||
activityStatus: 'ACTIVE', | ||
}); | ||
}, | ||
deactivate: (tenant: string | TenantBase) => { | ||
return update({ | ||
name: parseStringOrTenant(tenant), | ||
activityStatus: 'INACTIVE', | ||
}); | ||
}, | ||
offload: (tenant: string | TenantBase) => { | ||
return update({ | ||
name: parseStringOrTenant(tenant), | ||
activityStatus: 'OFFLOADED', | ||
}); | ||
}, | ||
}; | ||
}; | ||
|
@@ -169,4 +188,28 @@ export interface Tenants { | |
* @returns {Promise<Tenant[]>} The updated tenant(s) as a list of Tenant. | ||
*/ | ||
update: (tenants: TenantBC | TenantUpdate | (TenantBC | TenantUpdate)[]) => Promise<Tenant[]>; | ||
/** | ||
* Activate the specified tenant for a collection in Weaviate. | ||
* The collection must have been created with multi-tenancy enabled. | ||
* | ||
* @param {TenantBase | string} tenant The tenant to activate. | ||
* @returns {Promise<Tenant[]>} The activated tenant as a list of Tenant. | ||
*/ | ||
activate: (tenant: string | TenantBase) => Promise<Tenant[]>; | ||
Comment on lines
+196
to
+198
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. note: the I'd have these methods accept a |
||
/** | ||
* Deactivate the specified tenant for a collection in Weaviate. | ||
* The collection must have been created with multi-tenancy enabled. | ||
* | ||
* @param {TenantBase | string} tenant The tenant to deactivate. | ||
* @returns {Promise<Tenant[]>} The deactivated tenant as a list of Tenant | ||
*/ | ||
deactivate: (tenant: string | TenantBase) => Promise<Tenant[]>; | ||
/** | ||
* Offload the specified tenant for a collection in Weaviate. | ||
* The collection must have been created with multi-tenancy enabled. | ||
* | ||
* @param {TenantBase | string} tenant The tenant to offload. | ||
* @returns {Promise<Tenant[]>} The offloaded tenant as a list of Tenant | ||
*/ | ||
offload: (tenant: string | TenantBase) => Promise<Tenant[]>; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do you think it'll make sense to accept
(string | TenantBC)[]
to match update signature?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.
By having it be
TenantBase
, any of theTenantX
types are acceptable in this method since theactivityStatus
is ignored by the methods; all that is relevant is thename
which is the only field ofTenantBase
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.
Should've made it clearer in the original comment: I think these helper methods can accept an array of tenant names, so as to make it possible to, e.g., activate multiple tenants at once.
Just like it's possible to batch-
update
them.