Last active
January 10, 2020 11:06
-
-
Save brachi-wernick/b16797c2381e1812c21ca03a664488de to your computer and use it in GitHub Desktop.
FieldsConfigurationProvider
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
private void watch() { | |
new Thread(() -> { | |
Storage storage = StorageOptions.getDefaultInstance().getService(); | |
Bucket bucket = storage.get(bucketName); | |
while(true) { | |
try { | |
Blob blob = bucket.get(filePath); | |
long currentTime = blob.getUpdateTime(); | |
if (currentTime > lastUpdateTime) { | |
FieldsConfiguration newConfig = loadConfig(filePath); | |
Map<String, ChangeStatus> mutateResult = bqSchemaMutator.addFields(newConfig); | |
config = newConfig; | |
} | |
} | |
Thread.sleep(fieldsConfigLoadInterval); | |
} catch (Exception e) { | |
throw new RuntimeException(e); | |
} | |
} | |
}).start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment