Skip to content

Instantly share code, notes, and snippets.

@brachi-wernick
Last active January 10, 2020 11:06
Show Gist options
  • Save brachi-wernick/b16797c2381e1812c21ca03a664488de to your computer and use it in GitHub Desktop.
Save brachi-wernick/b16797c2381e1812c21ca03a664488de to your computer and use it in GitHub Desktop.
FieldsConfigurationProvider
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