-
Notifications
You must be signed in to change notification settings - Fork 215
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
Add geoip service extension #3944
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,19 @@ | |
package org.opensearch.dataprepper.plugins.processor.extension; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.AssertTrue; | ||
import jakarta.validation.constraints.Min; | ||
import org.hibernate.validator.constraints.time.DurationMax; | ||
import org.hibernate.validator.constraints.time.DurationMin; | ||
|
||
import java.time.Duration; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MaxMindConfig { | ||
private static final String S3_PREFIX = "s3://"; | ||
|
||
//TODO: Add validations to database paths | ||
//TODO: Make default path to be a public CDN endpoint | ||
private static final List<String> DEFAULT_DATABASE_PATHS = new ArrayList<>(); | ||
|
@@ -22,21 +27,34 @@ public class MaxMindConfig { | |
|
||
@JsonProperty("database_paths") | ||
private List<String> databasePaths = DEFAULT_DATABASE_PATHS; | ||
|
||
@JsonProperty("database_refresh_interval") | ||
@DurationMin(days = 1) | ||
@DurationMax(days = 30) | ||
private Duration databaseRefreshInterval = DEFAULT_DATABASE_REFRESH_INTERVAL; | ||
|
||
@JsonProperty("cache_size") | ||
@Min(1) | ||
//TODO: Add a Max limit on cache size | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have any thoughts on the maximum cache size? How big is each entry? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have any right now, but it's something to think about as it can abused if max limit is not added |
||
private int cacheSize = DEFAULT_CACHE_SIZE; | ||
|
||
//TODO: Add a destination path to store database files | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not following this comment, are you intended for storing files in database_paths into different paths? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, right now it's stored in a temp folder. But it should be configured |
||
@JsonProperty("aws") | ||
@Valid | ||
private AwsAuthenticationOptionsConfig awsAuthenticationOptionsConfig; | ||
|
||
public MaxMindConfig() { | ||
// This default constructor is used if maxmind is not configured | ||
} | ||
|
||
@AssertTrue(message = "database_refresh_interval should be between 1 and 30 days.") | ||
public boolean isValidDatabaseRefreshInterval() { | ||
return databaseRefreshInterval.toDays() >= 1 && databaseRefreshInterval.toDays() <= 30; | ||
@AssertTrue(message = "aws should be configured if any path in database_paths is S3 bucket path.") | ||
boolean isAwsAuthenticationOptionsRequired() { | ||
for (final String databasePath : databasePaths) { | ||
if (databasePath.startsWith(S3_PREFIX)) { | ||
return awsAuthenticationOptionsConfig != null; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
/** | ||
|
@@ -68,4 +86,14 @@ public Duration getDatabaseRefreshInterval() { | |
public int getCacheSize() { | ||
return cacheSize; | ||
} | ||
|
||
/** | ||
* Gets the AWS authentication config used for reading from S3 bucket | ||
* | ||
* @return The AWS authentication options | ||
* @since 2.7 | ||
*/ | ||
public AwsAuthenticationOptionsConfig getAwsAuthenticationOptionsConfig() { | ||
return awsAuthenticationOptionsConfig; | ||
} | ||
} |
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 should be
SPDX
. See: https://github.com/opensearch-project/data-prepper/blob/main/CONTRIBUTING.md#java-gradlegroovyMaybe this was a replace-all error?
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 change was applied to a few files.
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.
It's just a typo in my Intellij copyright setup, fixed it.