-
Notifications
You must be signed in to change notification settings - Fork 51
feat(flagd): add http connector for In-process resolver #1299
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
Draft
liran2000
wants to merge
21
commits into
open-feature:main
Choose a base branch
from
liran2000:feature/flagd-http-connector
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b4ae05c
adding http connector
liran2000 f93014e
adding http connector - cont.
liran2000 d8f6943
adding http cache
liran2000 c5d93b5
refactor for using options
liran2000 d201b1f
readme update
liran2000 4576816
Merge branch 'main' into feature/flagd-http-connector
chrfwow 2091826
move to tool - draft
liran2000 bddeaeb
Merge remote-tracking branch 'origin/feature/flagd-http-connector' in…
liran2000 6038613
move to tool - draft - cont.
liran2000 8f03143
move to tool - draft - cont.
liran2000 59ffacb
move to tool - draft - cont.
liran2000 6405472
add Configuration section to readme
liran2000 512d3a2
readme update
liran2000 2eea2c1
Merge branch 'main' into feature/flagd-http-connector
liran2000 d615b0c
updates
liran2000 36f5bc9
updates
liran2000 ec5f158
updates
liran2000 17d5d0b
updates
liran2000 1a48989
updates
liran2000 273f2fc
updates
liran2000 8fac595
updates
liran2000 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
org.org.slf4j.simpleLogger.defaultLogLevel=debug | ||
org.slf4j.simpleLogger.defaultLogLevel=debug | ||
|
||
io.grpc.level=trace |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
org.org.slf4j.simpleLogger.defaultLogLevel=debug | ||
org.slf4j.simpleLogger.defaultLogLevel=debug | ||
org.slf4j.simpleLogger.showDateTime= | ||
|
||
io.grpc.level=trace |
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,35 @@ | ||
# Changelog | ||
|
||
## [0.1.2](https://github.com/open-feature/java-sdk-contrib/compare/dev.openfeature.contrib.tools.junitopenfeature-v0.1.1...dev.openfeature.contrib.tools.junitopenfeature-v0.1.2) (2024-12-03) | ||
|
||
|
||
### ✨ New Features | ||
|
||
* added interception of parameterized tests to Junit OpenFeature Extension ([#1093](https://github.com/open-feature/java-sdk-contrib/issues/1093)) ([a78c906](https://github.com/open-feature/java-sdk-contrib/commit/a78c906b24b53f7d25eb01aad85ed614eb30ca05)) | ||
|
||
## [0.1.1](https://github.com/open-feature/java-sdk-contrib/compare/dev.openfeature.contrib.tools.junitopenfeature-v0.1.0...dev.openfeature.contrib.tools.junitopenfeature-v0.1.1) (2024-09-27) | ||
|
||
|
||
### 🐛 Bug Fixes | ||
|
||
* race condition causing default when multiple flags are used ([#983](https://github.com/open-feature/java-sdk-contrib/issues/983)) ([356a973](https://github.com/open-feature/java-sdk-contrib/commit/356a973cf2b6ddf82b8311ea200fa30df4f1d048)) | ||
|
||
## [0.1.0](https://github.com/open-feature/java-sdk-contrib/compare/dev.openfeature.contrib.tools.junitopenfeature-v0.0.3...dev.openfeature.contrib.tools.junitopenfeature-v0.1.0) (2024-09-25) | ||
|
||
|
||
### 🐛 Bug Fixes | ||
|
||
* **deps:** update dependency org.apache.commons:commons-lang3 to v3.17.0 ([#932](https://github.com/open-feature/java-sdk-contrib/issues/932)) ([c598d9f](https://github.com/open-feature/java-sdk-contrib/commit/c598d9f0a61f2324fb85d72fdfea34811283c575)) | ||
|
||
|
||
### 🐛 Bug Fixes | ||
|
||
* added missing dependency and installation instruction ([#895](https://github.com/open-feature/java-sdk-contrib/issues/895)) ([6748d02](https://github.com/open-feature/java-sdk-contrib/commit/6748d02403f0ceecb6cb9ecdfb2fecf98423a7db)) | ||
* **deps:** update dependency org.apache.commons:commons-lang3 to v3.16.0 ([#908](https://github.com/open-feature/java-sdk-contrib/issues/908)) ([d21cfe3](https://github.com/open-feature/java-sdk-contrib/commit/d21cfe3ac7da1ff6e1a4dc2ee4b0db5c24ed4847)) | ||
|
||
## [0.0.2](https://github.com/open-feature/java-sdk-contrib/compare/dev.openfeature.contrib.tools.junitopenfeature-v0.0.1...dev.openfeature.contrib.tools.junitopenfeature-v0.0.2) (2024-07-29) | ||
|
||
|
||
### ✨ New Features | ||
|
||
* Add JUnit5 extension for OpenFeature ([#888](https://github.com/open-feature/java-sdk-contrib/issues/888)) ([9fff9db](https://github.com/open-feature/java-sdk-contrib/commit/9fff9db4bcee3c3ae8128a1b2fb040f53df1d5ed)) |
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,103 @@ | ||
# Http Connector | ||
|
||
## Introduction | ||
Http Connector is a tool for [flagd](https://github.com/open-feature/flagd) in-process resolver. | ||
|
||
This mode performs flag evaluations locally (in-process). | ||
Flag configurations for evaluation are obtained via Http. | ||
|
||
## Http Connector functionality | ||
|
||
HttpConnector is responsible for polling data from a specified URL at regular intervals. | ||
It is leveraging Http cache mechanism with 'ETag' header, then when receiving 304 Not Modified response, | ||
reducing traffic, reducing rate limits effects and changes updates. Can be enabled via useHttpCache option. | ||
The implementation is using Java HttpClient. | ||
|
||
## Use cases and benefits | ||
* Reduce infrastructure/devops work, without additional containers needed. | ||
* Use as an additional provider for fallback / internal backup service via multi-provider. | ||
|
||
### What happens if the Http source is down when application is starting ? | ||
|
||
It supports optional fail-safe initialization via cache, such that on initial fetch error following by | ||
source downtime window, initial payload is taken from cache to avoid starting with default values until | ||
the source is back up. Therefore, the cache ttl expected to be higher than the expected source | ||
down-time to recover from during initialization. | ||
|
||
### Sample flow | ||
Sample flow can use: | ||
- Github as the flags payload source. | ||
- Redis cache as a fail-safe initialization cache. | ||
|
||
Sample flow of initialization during Github down-time window, showing that application can still use flags | ||
values as fetched from cache. | ||
```mermaid | ||
sequenceDiagram | ||
participant Provider | ||
participant Github | ||
participant Redis | ||
|
||
break source downtime | ||
Provider->>Github: initialize | ||
Github->>Provider: failure | ||
end | ||
Provider->>Redis: fetch | ||
Redis->>Provider: last payload | ||
|
||
``` | ||
|
||
## Usage | ||
|
||
### Installation | ||
<!-- x-release-please-start-version --> | ||
```xml | ||
<dependency> | ||
<groupId>dev.openfeature.contrib.tools</groupId> | ||
<artifactId>flagd-http-connector</artifactId> | ||
<version>0.0.1</version> | ||
</dependency> | ||
``` | ||
<!-- x-release-please-end-version --> | ||
|
||
### Usage example | ||
|
||
```java | ||
|
||
HttpConnectorOptions httpConnectorOptions = HttpConnectorOptions.builder() | ||
.url("http://example.com/flags") | ||
.build(); | ||
HttpConnector connector = HttpConnector.builder() | ||
.httpConnectorOptions(httpConnectorOptions) | ||
.build(); | ||
|
||
FlagdOptions options = | ||
FlagdOptions.builder() | ||
.resolverType(Config.Resolver.IN_PROCESS) | ||
.customConnector(connector) | ||
.build(); | ||
|
||
FlagdProvider flagdProvider = new FlagdProvider(options); | ||
``` | ||
|
||
### Configuration | ||
The Http Connector can be configured using the following properties in the `HttpConnectorOptions` class.: | ||
|
||
| Property Name | Type | Description | | ||
|-------------------------------------------|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| url | String | The URL to poll for updates. This is a required field. | | ||
| pollIntervalSeconds | Integer | The interval in seconds at which the connector will poll the URL for updates. Default is 60 seconds. | | ||
| connectTimeoutSeconds | Integer | The timeout in seconds for establishing a connection to the URL. Default is 10 seconds. | | ||
| requestTimeoutSeconds | Integer | The timeout in seconds for the request to complete. Default is 10 seconds. | | ||
| linkedBlockingQueueCapacity | Integer | The capacity of the linked blocking queue used for processing requests. Default is 100. | | ||
| scheduledThreadPoolSize | Integer | The size of the scheduled thread pool used for processing requests. Default is 2. | | ||
| headers | Map<String, String> | A map of headers to be included in the request. Default is an empty map. | | ||
| httpClientExecutor | ExecutorService | The executor service used for making HTTP requests. Default is a fixed thread pool with 1 thread. | | ||
| proxyHost | String | The host of the proxy server to use for requests. Default is null. | | ||
| proxyPort | Integer | The port of the proxy server to use for requests. Default is null. | | ||
| payloadCacheOptions | PayloadCacheOptions | Options for configuring the payload cache. Default is null. | | ||
| payloadCache | PayloadCache | The payload cache to use for caching responses. Default is null. | | ||
| useHttpCache | Boolean | Whether to use HTTP caching for the requests. Default is false. | | ||
| PayloadCacheOptions.updateIntervalSeconds | Integer | The interval, in seconds, at which the cache is updated. By default, this is set to 30 minutes. The goal is to avoid overloading fallback cache writes, since the cache serves only as a fallback mechanism. Typically, this value can be tuned to be shorter than the cache's TTL, balancing the need to minimize unnecessary updates while still handling edge cases effectively. | | ||
|
||
|
||
|
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,8 @@ | ||
<?xml version="1.0"?> | ||
|
||
<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "https://checkstyle.org/dtds/suppressions_1_2.dtd"> | ||
|
||
<suppressions> | ||
<!-- don't check style of generated sources (GRPC bindings) --> | ||
<suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*" /> | ||
</suppressions> |
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.
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.
both checkstyle files should not be here as part of the parent, but CI build is failing on checkstyle without them