Skip to content

Commit 9459d4e

Browse files
committed
wip
1 parent 9e3f458 commit 9459d4e

27 files changed

+1510
-9
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: java-server-sdk-redis
2+
3+
on:
4+
push:
5+
branches: [main, 'feat/**']
6+
paths-ignore:
7+
- '**.md' #Do not need to run CI for markdown changes.
8+
pull_request:
9+
branches: [main, 'feat/**']
10+
paths-ignore:
11+
- '**.md'
12+
13+
jobs:
14+
# build-test-java-server-sdk-redis:
15+
# strategy:
16+
# matrix:
17+
# jedis-version: [2.9.0, 3.0.0]
18+
# runs-on: ubuntu-latest
19+
# steps:
20+
# - uses: actions/checkout@v3
21+
22+
# - run: |
23+
# sudo apt-get update -y
24+
# sudo apt-get install redis-server -y
25+
# sudo service redis-server start
26+
27+
# - name: Edit build.gradle to change Jedis version
28+
# shell: bash
29+
# run: |
30+
# cd lib/java-server-sdk-redis
31+
# sed -i.bak 's#"jedis":.*"[0-9.]*"#"jedis":"${{ matrix.jedis-version }}"#' build.gradle
32+
33+
# - name: Shared CI Steps
34+
# uses: ./.github/actions/ci
35+
# with:
36+
# workspace_path: 'lib/java-server-sdk-redis'
37+
# java_version: 8
38+
39+
build-test-java-server-sdk-windows:
40+
strategy:
41+
matrix:
42+
jedis-version: [2.9.0, 3.0.0]
43+
runs-on: windows-latest
44+
steps:
45+
- uses: actions/checkout@v3
46+
47+
- run: |
48+
$ProgressPreference = "SilentlyContinue"
49+
iwr -outf redis.zip https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.zip
50+
mkdir redis
51+
Expand-Archive -Path redis.zip -DestinationPath redis
52+
cd redis
53+
.\redis-server --service-install
54+
.\redis-server --service-start
55+
Start-Sleep -s 5
56+
.\redis-cli ping
57+
58+
- name: Edit build.gradle to change Jedis version
59+
shell: bash
60+
run: |
61+
cd lib/java-server-sdk-redis
62+
sed -i.bak 's#"jedis":.*"[0-9.]*"#"jedis":"${{ matrix.jedis-version }}"#' build.gradle
63+
64+
- name: Shared CI Steps
65+
uses: ./.github/actions/ci
66+
with:
67+
workspace_path: 'lib/java-server-sdk-redis'
68+
java_version: 8

.release-please-manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"lib/java-server-sdk-otel": "0.1.0",
3+
"lib/java-server-sdk-redis": "3.0.0",
34
"lib/shared/common": "2.1.1",
45
"lib/shared/internal": "1.3.0",
56
"lib/sdk/server": "7.7.0"

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ This includes shared libraries, used by SDKs and other tools, as well as SDKs.
1414
| [@launchdarkly/java-sdk-internal](lib/shared/internal/README.md) | [![Documentation][sdk-internal-docs-badge]][sdk-internal-docs-link] | [![maven][sdk-internal-maven-badge]][sdk-internal-maven-link] | [Issues][sdk-internal-issues] | [![Actions Status][sdk-internal-ci-badge]][sdk-internal-ci-link] |
1515
| [@launchdarkly/java-sdk-common](lib/shared/common/README.md) | [![Documentation][sdk-common-docs-badge]][sdk-common-docs-link] | [![maven][sdk-common-maven-badge]][sdk-common-maven-link] | [Issues][sdk-common-issues] | [![Actions Status][sdk-common-ci-badge]][sdk-common-ci-link] |
1616

17-
| Telemetry Packages | API Docs | maven | issues | tests |
17+
| Other Packages | API Docs | maven | issues | tests |
1818
| ---------------------------------------------------------------------------- |--------------------------------------------------------------| ---------------------------------------------------------- | ------------------------------------- | ------------------------------------------------------------- |
1919
| [@launchdarkly/java-server-sdk-otel](lib/java-server-sdk-otel/README.md) | [![Documentation][server-otel-docs-badge]][server-otel-docs-link] | [![maven][server-otel-maven-badge]][server-otel-maven-link] | [Issues][server-otel-issues] | [![Actions Status][server-otel-ci-badge]][server-otel-ci-link] |
20+
| [@launchdarkly/java-server-sdk-redis](lib/java-server-sdk-redis/README.md) | [![Documentation][server-redis-docs-badge]][server-redis-docs-link] | [![maven][server-redis-maven-badge]][server-redis-maven-link] | [Issues][server-redis-issues] | [![Actions Status][server-redis-ci-badge]][server-redis-ci-link] |
2021

2122
## Organization
2223

@@ -71,6 +72,15 @@ We encourage pull requests and other contributions from the community. Check out
7172
[server-otel-docs-badge]: https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8
7273
[server-otel-docs-link]: https://launchdarkly.github.io/java-core/lib/java-server-sdk-otel/
7374

75+
[//]: # 'java-server-sdk-redis'
76+
[server-redis-issues]: https://github.com/launchdarkly/java-core/issues?q=is%3Aissue+is%3Aopen+label%3A%22package%3A+java-server-sdk-redis%22+
77+
[server-redis-maven-badge]: https://img.shields.io/maven-central/v/com.launchdarkly/launchdarkly-java-server-sdk-redis
78+
[server-redis-maven-link]: https://central.sonatype.com/artifact/com.launchdarkly/launchdarkly-java-server-sdk-redis
79+
[server-redis-ci-badge]: https://github.com/launchdarkly/java-core/actions/workflows/java-server-sdk-redis.yml/badge.svg
80+
[server-redis-ci-link]: https://github.com/launchdarkly/java-core/actions/workflows/java-server-sdk-redis.yml
81+
[server-redis-docs-badge]: https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8
82+
[server-redis-docs-link]: https://launchdarkly.github.io/java-core/lib/java-server-sdk-redis/
83+
7484
[//]: # 'java-sdk-internal'
7585
[sdk-internal-issues]: https://github.com/launchdarkly/java-core/issues?q=is%3Aissue+is%3Aopen+label%3A%22package%3A+java-sdk-internal%22+
7686
[sdk-internal-maven-badge]: https://img.shields.io/maven-central/v/com.launchdarkly/launchdarkly-java-sdk-internal
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Change log
2+
3+
All notable changes to the LaunchDarkly Java SDK Redis integration will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
4+
5+
## [3.0.0] - 2022-12-07
6+
This release corresponds to the 6.0.0 release of the LaunchDarkly Java SDK. Any application code that is being updated to use the 6.0.0 SDK, and was using a 2.x version of `launchdarkly-java-server-sdk-redis`, should now use a 3.x version instead.
7+
8+
There are no functional differences in the behavior of the Redis integration; the differences are only related to changes in the usage of interface types for configuration in the SDK.
9+
10+
### Added:
11+
- `Redis.bigSegmentStore()`, which creates a configuration builder for use with Big Segments. Previously, the `Redis.dataStore()` builder was used for both regular data stores and Big Segment stores.
12+
13+
### Changed:
14+
- The type `RedisDataStoreBuilder` has been removed, replaced by a generic type `RedisStoreBuilder`. Application code would not normally need to reference these types by name, but if necessary, use either `RedisStoreBuilder<PersistentDataStore>` or `RedisStoreBuilder<BigSegmentStore>` depending on whether you are configuring a regular data store or a Big Segment store.
15+
16+
## [2.0.0] - 2022-07-29
17+
This release updates the package to use the new logging mechanism that was introduced in version 5.10.0 of the LaunchDarkly Java SDK, so that log output from the Redis integration is handled in whatever way was specified by the SDK's logging configuration.
18+
19+
This version of the package will not work with SDK versions earlier than 5.10.0; that is the only reason for the 2.0.0 major version increment. The functionality of the package is otherwise unchanged, and there are no API changes.
20+
21+
## [1.1.0] - 2022-01-28
22+
### Added:
23+
- Added support for Big Segments. An Early Access Program for creating and syncing Big Segments from customer data platforms is available to enterprise customers.
24+
25+
## [1.0.1] - 2021-08-06
26+
### Fixed:
27+
- This integration now works with Jedis 3.x as well as Jedis 2.9.x. The default dependency is still 2.9.x, but an application can override this with a dependency on a 3.x version. (Thanks, [robotmlg](https://github.com/launchdarkly/java-server-sdk-redis/pull/3)!)
28+
29+
## [1.0.0] - 2020-06-02
30+
Initial release, corresponding to the 5.0.0 release of [`launchdarkly-java-server-sdk`](https://github.com/launchdarkly/java-server-sdk).
31+
32+
Prior to that release, the Redis integration was built into the main SDK library. For more information about changes in the SDK database integrations, see the [4.x to 5.0 migration guide](https://docs-stg.launchdarkly.com/252/sdk/server-side/java/migration-4-to-5/).
33+

lib/java-server-sdk-redis/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# LaunchDarkly SDK for Java - Redis integration
2+
3+
[![Circle CI](https://circleci.com/gh/launchdarkly/java-server-sdk-redis.svg?style=shield)](https://circleci.com/gh/launchdarkly/java-server-sdk-redis)
4+
[![Javadocs](http://javadoc.io/badge/com.launchdarkly/launchdarkly-java-server-sdk-redis-store.svg)](http://javadoc.io/doc/com.launchdarkly/launchdarkly-java-server-sdk-redis-store)
5+
6+
This library provides a Redis-backed persistence mechanism (feature store) for the [LaunchDarkly Java SDK](https://github.com/launchdarkly/java-server-sdk), replacing the default in-memory feature store. The Redis API implementation it uses is [Jedis](https://github.com/xetorthio/jedis).
7+
8+
This version of the library requires at least version 6.0.0 of the LaunchDarkly Java SDK; for versions of the library to use with earlier SDK versions, see the changelog. The minimum Java version is 8.
9+
10+
For more information, see also: [Using Redis as a persistent feature store](https://docs.launchdarkly.com/sdk/features/storing-data/redis#java).
11+
12+
## Quick setup
13+
14+
This assumes that you have already installed the LaunchDarkly Java SDK.
15+
16+
1. Add this library to your project (substitute the latest version number for `XXX`):
17+
18+
<dependency>
19+
<groupId>com.launchdarkly</groupId>
20+
<artifactId>launchdarkly-java-server-sdk-redis-store</artifactId>
21+
<version>XXX</version>
22+
</dependency>
23+
24+
2. The Redis client library (Jedis) should be pulled in automatically if you do not specify a dependency for it. If you want to use a different version, you may add your own dependency:
25+
26+
<dependency>
27+
<groupId>redis.clients</groupId>
28+
<artifactId>jedis</artifactId>
29+
<version>2.9.0</version>
30+
</dependency>
31+
32+
This library is compatible with Jedis 2.x versions greater than or equal to 2.9.0, and also with Jedis 3.x.
33+
34+
3. Import the LaunchDarkly package and the package for this library:
35+
36+
import com.launchdarkly.sdk.server.*;
37+
import com.launchdarkly.sdk.server.integrations.*;
38+
39+
4. When configuring your SDK client, add the Redis data store as a `persistentDataStore`. You may specify any custom Redis options using the methods of `RedisDataStoreBuilder`. For instance, to customize the Redis URL:
40+
41+
LDConfig config = new LDConfig.Builder()
42+
.dataStore(
43+
Components.persistentDataStore(
44+
Redis.dataStore().url("redis://my-redis-host")
45+
)
46+
)
47+
.build();
48+
49+
By default, the store will try to connect to a local Redis instance on port 6379.
50+
51+
## Caching behavior
52+
53+
The LaunchDarkly SDK has a standard caching mechanism for any persistent data store, to reduce database traffic. This is configured through the SDK's `PersistentDataStoreBuilder` class as described the SDK documentation. For instance, to specify a cache TTL of 5 minutes:
54+
55+
LDConfig config = new LDConfig.Builder()
56+
.dataStore(
57+
Components.persistentDataStore(
58+
Redis.dataStore()
59+
).cacheTime(Duration.ofMinutes(5))
60+
)
61+
.build();
62+
63+
## About LaunchDarkly
64+
65+
* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
66+
* Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
67+
* Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
68+
* Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
69+
* Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
70+
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.
71+
* Explore LaunchDarkly
72+
* [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
73+
* [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides
74+
* [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
75+
* [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
2+
buildscript {
3+
repositories {
4+
mavenCentral()
5+
mavenLocal()
6+
}
7+
}
8+
9+
plugins {
10+
id "java"
11+
id "java-library"
12+
id "checkstyle"
13+
id "signing"
14+
id "maven-publish"
15+
id "de.marcphilipp.nexus-publish" version "0.3.0"
16+
id "io.codearte.nexus-staging" version "0.30.0"
17+
id "idea"
18+
}
19+
20+
configurations.all {
21+
// check for updates every build for dependencies with: 'changing: true'
22+
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
23+
}
24+
25+
repositories {
26+
mavenLocal()
27+
// Before LaunchDarkly release artifacts get synced to Maven Central they are here along with snapshots:
28+
maven { url "https://oss.sonatype.org/content/groups/public/" }
29+
mavenCentral()
30+
}
31+
32+
allprojects {
33+
group = 'com.launchdarkly'
34+
version = "${version}"
35+
archivesBaseName = 'launchdarkly-java-server-sdk-redis-store'
36+
sourceCompatibility = 1.8
37+
targetCompatibility = 1.8
38+
}
39+
40+
ext {
41+
sdkBasePackage = "com.launchdarkly.client.redis"
42+
}
43+
44+
ext.versions = [
45+
"sdk": "6.2.1", // the *lowest* version we're compatible with
46+
"jedis": "2.9.0"
47+
]
48+
49+
ext.libraries = [:]
50+
51+
dependencies {
52+
api "com.launchdarkly:launchdarkly-java-server-sdk:${versions.sdk}"
53+
api "redis.clients:jedis:${versions.jedis}"
54+
testImplementation "org.hamcrest:hamcrest-all:1.3"
55+
testImplementation "junit:junit:4.12"
56+
testImplementation "com.launchdarkly:launchdarkly-java-server-sdk:${versions.sdk}:test" // our unit tests use helper classes from the SDK
57+
testImplementation "com.google.guava:guava:28.2-jre" // required by SDK tests, not used in this library itself
58+
testImplementation "com.google.code.gson:gson:2.7" // same as above
59+
}
60+
61+
task sourcesJar(type: Jar, dependsOn: classes) {
62+
classifier = 'sources'
63+
from sourceSets.main.allSource
64+
}
65+
66+
task javadocJar(type: Jar, dependsOn: javadoc) {
67+
classifier = 'javadoc'
68+
from javadoc.destinationDir
69+
}
70+
71+
artifacts {
72+
archives sourcesJar, javadocJar
73+
}
74+
75+
test {
76+
testLogging {
77+
events "passed", "skipped", "failed", "standardOut", "standardError"
78+
showStandardStreams = true
79+
exceptionFormat = 'full'
80+
}
81+
}
82+
83+
checkstyle {
84+
toolVersion = "9.3"
85+
configFile = file("${project.rootDir}/checkstyle.xml")
86+
}
87+
88+
idea {
89+
module {
90+
downloadJavadoc = true
91+
downloadSources = true
92+
}
93+
}
94+
95+
96+
nexusStaging {
97+
packageGroup = "com.launchdarkly"
98+
numberOfRetries = 40 // we've seen extremely long delays in closing repositories
99+
}
100+
101+
publishing {
102+
publications {
103+
mavenJava(MavenPublication) {
104+
from components.java
105+
106+
groupId = 'com.launchdarkly'
107+
artifactId = project.archivesBaseName
108+
109+
artifact sourcesJar
110+
artifact javadocJar
111+
112+
pom {
113+
name = project.archivesBaseName
114+
description = 'LaunchDarkly Java SDK Redis integration'
115+
url = 'https://github.com/launchdarkly/java-server-sdk-redis'
116+
licenses {
117+
license {
118+
name = 'The Apache License, Version 2.0'
119+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
120+
}
121+
}
122+
developers {
123+
developer {
124+
name = 'LaunchDarkly'
125+
126+
}
127+
}
128+
scm {
129+
connection = 'scm:git:git://github.com/launchdarkly/java-server-sdk-redis.git'
130+
developerConnection = 'scm:git:ssh:[email protected]:launchdarkly/java-server-sdk-redis.git'
131+
url = 'https://github.com/launchdarkly/java-server-sdk-redis'
132+
}
133+
}
134+
}
135+
}
136+
repositories {
137+
mavenLocal()
138+
}
139+
}
140+
141+
nexusPublishing {
142+
clientTimeout = java.time.Duration.ofMinutes(2) // we've seen extremely long delays in creating repositories
143+
repositories {
144+
sonatype {
145+
username = ossrhUsername
146+
password = ossrhPassword
147+
}
148+
}
149+
}
150+
151+
signing {
152+
sign publishing.publications.mavenJava
153+
}
154+
155+
tasks.withType(Sign) {
156+
onlyIf { !"1".equals(project.findProperty("LD_SKIP_SIGNING")) } // so we can build jars for testing in CI
157+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
<module name="Checker">
6+
<module name="TreeWalker">
7+
<module name="JavadocMethod">
8+
<property name="accessModifiers" value="public"/>
9+
</module>
10+
<module name="JavadocType">
11+
<property name="scope" value="public"/>
12+
</module>
13+
</module>
14+
</module>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version=3.0.0
2+
ossrhUsername=
3+
ossrhPassword=
4+
5+
# See https://github.com/gradle/gradle/issues/11308 regarding the following property
6+
systemProp.org.gradle.internal.publish.checksums.insecure=true
Binary file not shown.

0 commit comments

Comments
 (0)