-
Notifications
You must be signed in to change notification settings - Fork 138
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
CBG-3721: [Diagnostic API] Import filter and sync function dry run endpoints #6715
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
6e87ae1
Add import filter handler and half done sync fn handler
mohammed-madi d8be4ff
Implement sync fn dry run
mohammed-madi 6e201bc
Add test and fix handlers
mohammed-madi 11aaa96
Fix comments
mohammed-madi a819e8a
Add docs
mohammed-madi 4db8eaa
Fix lint
mohammed-madi 18b7f21
Fix docs
mohammed-madi a7fdd69
Fix lint
mohammed-madi 988b291
Fix comment
mohammed-madi 44290a7
Fix test on CBS
mohammed-madi e6a0000
Address most comments, need olddoc compatibility and avoid incrementi…
mohammed-madi f641fa9
Fix oldDoc handling and stop incrementing stats on dry run
mohammed-madi dc67e79
Fix docs
mohammed-madi 03a9f95
Fix comment
mohammed-madi f16c5a2
Add missing doc page and fix lint
mohammed-madi 3717116
Fix tests
mohammed-madi 06b66c4
Address comments
mohammed-madi 32b6350
Add doc id query for import filter dry run
mohammed-madi 5f61d46
Add doc id to import filter dry run docs
mohammed-madi ad5905a
Fix lint
mohammed-madi 57ed5d0
Skip removing rev id from history
mohammed-madi b5240ec
Remove dryrun bool and refactor SyncFnDryRun
mohammed-madi f769591
Add dryrun to evaluate function for import filter
mohammed-madi 3a5f9e1
Fix crud_test.go
mohammed-madi 9826b18
Fix test
mohammed-madi 75338bd
Remove unnecessary code
mohammed-madi 0fa6ffb
Add coverage for different old/new handling
mohammed-madi 8117701
When doc is given but no body is given, doc in bucket is not used as …
mohammed-madi 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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright 2024-Present Couchbase, Inc. | ||
# | ||
# Use of this software is governed by the Business Source License included | ||
# in the file licenses/BSL-Couchbase.txt. As of the Change Date specified | ||
# in that file, in accordance with the Business Source License, use of this | ||
# software will be governed by the Apache License, Version 2.0, included in | ||
# the file licenses/APL2.txt. | ||
parameters: | ||
- $ref: ../../components/parameters.yaml#/keyspace | ||
get: | ||
summary: Run a doc body through the Import filter and return results. | ||
description: |- | ||
Run a document body through the import filter and return whether its imported or not, and any error messages. | ||
* Sync Gateway Application Read Only | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: ../../components/schemas.yaml#/Document | ||
responses: | ||
'200': | ||
description: Document Processed by import filter successfully | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
shouldImport: | ||
description: Whether this document would be imported after being processed by the import filter. | ||
type: boolean | ||
error: | ||
description: Errors thrown by the Import filter. | ||
type: string | ||
|
||
|
||
'404': | ||
$ref: ../../components/responses.yaml#/Not-found | ||
parameters: | ||
- $ref: ../../components/parameters.yaml#/doc_id | ||
tags: | ||
- Document | ||
operationId: get_keyspace-import_filter-docid |
This file contains 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2024-Present Couchbase, Inc. | ||
# | ||
# Use of this software is governed by the Business Source License included | ||
# in the file licenses/BSL-Couchbase.txt. As of the Change Date specified | ||
# in that file, in accordance with the Business Source License, use of this | ||
# software will be governed by the Apache License, Version 2.0, included in | ||
# the file licenses/APL2.txt. | ||
parameters: | ||
- $ref: ../../components/parameters.yaml#/keyspace | ||
get: | ||
summary: Run a doc body through the sync function and return sync data. | ||
description: |- | ||
Run a document body through the sync function and return document sync data. | ||
* Sync Gateway Application Read Only | ||
requestBody: | ||
adamcfraser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
content: | ||
application/json: | ||
schema: | ||
$ref: ../../components/schemas.yaml#/Document | ||
responses: | ||
'200': | ||
description: Document Processed by sync function successfully | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
channels: | ||
description: The channels the document was placed in by the sync function. | ||
type: array | ||
roles: | ||
description: An access map of roles granted by the sync function. | ||
type: object | ||
properties: | ||
username: | ||
type: object | ||
additionalProperties: | ||
x-additionalPropertiesName: role | ||
type: string | ||
access: | ||
description: An access map of dynamic channels granted by the sync function. | ||
type: object | ||
properties: | ||
username: | ||
type: object | ||
additionalProperties: | ||
x-additionalPropertiesName: channel | ||
type: string | ||
|
||
exception: | ||
description: Errors thrown by the sync function. | ||
type: string | ||
|
||
'404': | ||
$ref: ../../components/responses.yaml#/Not-found | ||
parameters: | ||
- $ref: ../../components/parameters.yaml#/doc_id | ||
tags: | ||
- Document | ||
operationId: get_keyspace-sync |
Oops, something went wrong.
Oops, something went wrong.
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.
This looks like if a body is passed in and docID is not found, we're using the body as both doc and oldDoc. I don't think this is what users will want to do - if they are only passing body, I think it should behave as an insert (oldDoc=null)
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.
Its treated as an insert if there is no docID, but olddoc is used in prepareSyncFn. If doc id is not found it returns 404
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.
If this is an insert, we need to ensure we're not populating oldDoc body in the sync function (people trying to test sync functions that have different handling for insert/update aren't going to work). If oldDoc needs to be non-nil, I expect you at least need to set oldDoc._body=nil? Or is this handled in another way that I'm overlooking?