-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #280 from alphagov/refac-sync-2
Refactor sync to be less repetitive
- Loading branch information
Showing
7 changed files
with
57 additions
and
80 deletions.
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,30 @@ | ||
module DiscoveryEngine::Sync | ||
class Operation | ||
include Locking | ||
|
||
def initialize(content_id, payload_version: nil, client: nil) | ||
@content_id = content_id | ||
@payload_version = payload_version | ||
@client = client || ::Google::Cloud::DiscoveryEngine.document_service(version: :v1) | ||
end | ||
|
||
private | ||
|
||
attr_reader :content_id, :payload_version, :client | ||
|
||
def document_name | ||
"#{Rails.configuration.discovery_engine_datastore_branch}/documents/#{content_id}" | ||
end | ||
|
||
def log(level, message) | ||
combined_message = sprintf( | ||
"[%s] %s content_id:%s payload_version:%d", | ||
self.class.name, | ||
message, | ||
content_id, | ||
payload_version, | ||
) | ||
Rails.logger.add(level, combined_message) | ||
end | ||
end | ||
end |
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