-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Add Lineage Enablement Cache #42
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
Merged
KonstantinMi
merged 12 commits into
GoogleCloudPlatform:main
from
utkarsh-goel-google:feat/lineage-enablement-cache
Dec 1, 2025
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
db20caa
Add Lineage enablement cache to client library
utkarsh-goel-google a8d2fa8
Refactor to use Composition for caches
utkarsh-goel-google 4792d41
use error reason instead of error message and fix caches
utkarsh-goel-google 28bab5e
fix format errors
utkarsh-goel-google c88508e
fix formatting
utkarsh-goel-google c87015e
fix checkstyle
utkarsh-goel-google c4735c0
revert gradle version upgarade
utkarsh-goel-google ce0685d
add blank lines
utkarsh-goel-google 2348112
address comments
utkarsh-goel-google 83aee33
add comment to equals function
utkarsh-goel-google 507e86d
java google format
utkarsh-goel-google 126a2ef
move Copyright year from 2024 -> 2025 for newly added classes
utkarsh-goel-google 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
Binary file not shown.
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
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
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
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
50 changes: 50 additions & 0 deletions
50
lib/src/main/java/com/google/cloud/datalineage/producerclient/LineageEnablementCache.java
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 |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Copyright 2024 Google LLC | ||
utkarsh-goel-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package com.google.cloud.datalineage.producerclient; | ||
|
|
||
| import java.time.Duration; | ||
|
|
||
| /** | ||
| * Cache used to store information about whether Lineage is disabled for a given project in | ||
utkarsh-goel-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * LineageConfigurations. | ||
| */ | ||
| public interface LineageEnablementCache { | ||
|
|
||
| /** | ||
| * Mark lineage ingestion state as disabled for a given project name. | ||
| * | ||
| * @param projectName The project for which to disable the lineage ingestion | ||
| * @see LineageEnablementCache#markLineageAsDisabled(String, Duration) | ||
| */ | ||
| void markLineageAsDisabled(String projectName); | ||
|
|
||
| /** | ||
| * Mark lineage ingestion state as disabled for a given project name and duration. | ||
| * | ||
| * @param projectName The project for which to disable the lineage ingestion | ||
| * @param duration - suggests how long the project should be marked as disabled. It is not | ||
| * guarantied that cache will indicate lineage ingestion enablement state as disabled for | ||
| * given time. Behaviour depends on implementation. | ||
| */ | ||
| void markLineageAsDisabled(String projectName, Duration duration); | ||
|
|
||
| /** | ||
| * Indicates if lineage ingestion with provided projectName is marked as disabled. | ||
| * | ||
| * @param projectName The project for which to disable the lineage ingestion | ||
| * @return `true` if the lineage ingestion is marked as disabled | ||
| */ | ||
| boolean isLineageMarkedAsDisabled(String projectName); | ||
| } | ||
45 changes: 45 additions & 0 deletions
45
.../main/java/com/google/cloud/datalineage/producerclient/LineageEnablementCacheFactory.java
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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // Copyright 2024 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package com.google.cloud.datalineage.producerclient; | ||
|
|
||
| /** A factory that returns ConnectionCache based on LineageEnablementCacheSettings. */ | ||
| public class LineageEnablementCacheFactory { | ||
| private static volatile LineageEnablementCache commonInstance; | ||
|
|
||
| /** Make the factory class non-instantiable */ | ||
| private LineageEnablementCacheFactory() {} | ||
|
|
||
| public static LineageEnablementCache get(CacheSettings settings) { | ||
| if (!settings.getEnabled()) { | ||
| return new NoOpLineageEnablementCache(); | ||
utkarsh-goel-google marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| if (!settings.getUseCommonInstance()) { | ||
| return new StandardLineageEnablementCache(settings.getOptions()); | ||
| } | ||
|
|
||
| if (commonInstance != null) { | ||
utkarsh-goel-google marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return commonInstance; | ||
| } | ||
|
|
||
| synchronized (LineageEnablementCacheFactory.class) { | ||
| if (commonInstance == null) { | ||
| commonInstance = new StandardLineageEnablementCache(settings.getOptions()); | ||
| } | ||
| } | ||
|
|
||
| return commonInstance; | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.