-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more configuration properties. Closes #70
Showing
17 changed files
with
1,217 additions
and
271 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 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
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,7 @@ | ||
services: | ||
openfga: | ||
image: openfga/openfga:latest | ||
command: run | ||
ports: | ||
- "4000:8080" | ||
|
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
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
16 changes: 16 additions & 0 deletions
16
src/main/java/dev/openfga/autoconfigure/HttpClientBuilderCustomizer.java
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,16 @@ | ||
package dev.openfga.autoconfigure; | ||
|
||
import java.net.http.HttpClient; | ||
|
||
/** | ||
* Callback interface that can be used to customize the configuration of an {@link HttpClient.Builder}. | ||
*/ | ||
@FunctionalInterface | ||
public interface HttpClientBuilderCustomizer { | ||
|
||
/** | ||
* Callback to customize a {@link HttpClient.Builder} instance. | ||
* @param builder HTTP builder to customize | ||
*/ | ||
void customize(HttpClient.Builder builder); | ||
} |
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,33 @@ | ||
package dev.openfga.autoconfigure; | ||
|
||
import java.net.http.HttpClient; | ||
|
||
/** | ||
* The HTTP protocol version to use for the client connection to the server when making requests to OpenFGA. | ||
*/ | ||
public enum HttpVersion { | ||
|
||
/** | ||
* HTTP version 1.1 | ||
* <p> | ||
* This version is widely supported and used for most HTTP communications. | ||
*/ | ||
HTTP_1_1(HttpClient.Version.HTTP_1_1), | ||
|
||
/** | ||
* HTTP version 2 | ||
* <p> | ||
* This version offers improved performance and efficiency over HTTP/1.1. | ||
*/ | ||
HTTP_2(HttpClient.Version.HTTP_2); | ||
|
||
private final HttpClient.Version version; | ||
|
||
HttpVersion(HttpClient.Version version) { | ||
this.version = version; | ||
} | ||
|
||
HttpClient.Version getVersion() { | ||
return version; | ||
} | ||
} |
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
376 changes: 357 additions & 19 deletions
376
src/main/java/dev/openfga/autoconfigure/OpenFgaProperties.java
Large diffs are not rendered by default.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
src/main/java/dev/openfga/autoconfigure/TelemetryAttribute.java
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,71 @@ | ||
package dev.openfga.autoconfigure; | ||
|
||
import dev.openfga.sdk.telemetry.Attribute; | ||
import dev.openfga.sdk.telemetry.Attributes; | ||
import java.util.Objects; | ||
|
||
/** | ||
* The telemetry attributes that can be used to log telemetry data. | ||
* | ||
* See <a href="https://openfga.dev/docs/getting-started/configure-telemetry">OpenFGA Telemetry</a> for more information. | ||
*/ | ||
public enum TelemetryAttribute { | ||
/** | ||
* The client ID used in the request, if applicable. | ||
*/ | ||
FGA_CLIENT_REQUEST_CLIENT_ID(Attributes.FGA_CLIENT_REQUEST_CLIENT_ID), | ||
/** | ||
* The FGA method / action of the request. | ||
*/ | ||
FGA_CLIENT_REQUEST_METHOD(Attributes.FGA_CLIENT_REQUEST_METHOD), | ||
/** | ||
* The authorization model ID used in the request, if applicable. | ||
*/ | ||
FGA_CLIENT_REQUEST_MODEL_ID(Attributes.FGA_CLIENT_REQUEST_MODEL_ID), | ||
/** | ||
* The store ID used in the request, if applicable. | ||
*/ | ||
FGA_CLIENT_REQUEST_STORE_ID(Attributes.FGA_CLIENT_REQUEST_STORE_ID), | ||
/** | ||
* The authorization model ID used by the server when evaluating the request, if applicable. | ||
*/ | ||
FGA_CLIENT_RESPONSE_MODEL_ID(Attributes.FGA_CLIENT_RESPONSE_MODEL_ID), | ||
/** | ||
* The HTTP host used in the request, e.g. "example.com". | ||
*/ | ||
HTTP_HOST(Attributes.HTTP_HOST), | ||
/** | ||
* The HTTP method used in the request, e.g. "GET". | ||
*/ | ||
HTTP_REQUEST_METHOD(Attributes.HTTP_REQUEST_METHOD), | ||
/** | ||
* The number of times the request was retried | ||
*/ | ||
HTTP_REQUEST_RESEND_COUNT(Attributes.HTTP_REQUEST_RESEND_COUNT), | ||
/** | ||
* The HTTP status code returned by the server for the request, e.g. 200. | ||
*/ | ||
HTTP_RESPONSE_STATUS_CODE(Attributes.HTTP_RESPONSE_STATUS_CODE), | ||
/** | ||
* The complete URL used in the request, e.g. "https://example.com/path". | ||
*/ | ||
URL_FULL(Attributes.URL_FULL), | ||
/** | ||
* The scheme used in the request, e.g. "https". | ||
*/ | ||
URL_SCHEME(Attributes.URL_SCHEME), | ||
/** | ||
* The user agent used in the request, e.g. "Mozilla/5.0". | ||
*/ | ||
USER_AGENT(Attributes.USER_AGENT); | ||
|
||
private final Attribute attribute; | ||
|
||
TelemetryAttribute(Attribute attribute) { | ||
this.attribute = Objects.requireNonNull(attribute); | ||
} | ||
|
||
Attribute getAttribute() { | ||
return attribute; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/dev/openfga/autoconfigure/TelemetryMetric.java
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,36 @@ | ||
package dev.openfga.autoconfigure; | ||
|
||
import dev.openfga.sdk.telemetry.Counters; | ||
import dev.openfga.sdk.telemetry.Histograms; | ||
import dev.openfga.sdk.telemetry.Metric; | ||
import java.util.Objects; | ||
|
||
/** | ||
* The telemetry metrics that can be used to log telemetry data. | ||
* | ||
* See <a href="https://openfga.dev/docs/getting-started/configure-telemetry">OpenFGA Telemetry</a> for more information. | ||
*/ | ||
public enum TelemetryMetric { | ||
/** | ||
* The CREDENTIALS_REQUEST counter represents the number of times an access token is requested. | ||
*/ | ||
CREDENTIALS_REQUEST(Counters.CREDENTIALS_REQUEST), | ||
/** | ||
* A histogram for measuring the total time it took (in milliseconds) for the FGA server to process and evaluate the request. | ||
*/ | ||
QUERY_DURATION(Histograms.QUERY_DURATION), | ||
/** | ||
* A histogram for measuring the total time (in milliseconds) it took for the request to complete, including the time it took to send the request and receive the response. | ||
*/ | ||
REQUEST_DURATION(Histograms.REQUEST_DURATION); | ||
|
||
private final Metric metric; | ||
|
||
TelemetryMetric(Metric metric) { | ||
this.metric = Objects.requireNonNull(metric); | ||
} | ||
|
||
Metric getMetric() { | ||
return metric; | ||
} | ||
} |
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
194 changes: 0 additions & 194 deletions
194
src/test/java/dev/openfga/autoconfigure/FgaAutoConfigurationTests.java
This file was deleted.
Oops, something went wrong.
290 changes: 290 additions & 0 deletions
290
src/test/java/dev/openfga/autoconfigure/OpenFgaAutoConfigurationTests.java
Large diffs are not rendered by default.
Oops, something went wrong.