Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/ekv-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Encoded KV Main Snapshot

on:
push:
branches:
- main
paths:
- 'encoded-kv/**'

env:
GODEBUG: x509sha1=1

jobs:
build:
runs-on: ubuntu-latest
env:
BUILD_EVENT: ${{ github.event_name }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
GODEBUG: x509sha1=1
steps:
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
- name: Install Nats Server
run: |
curl -sf https://binaries.nats.dev/nats-io/nats-server/v2@main | PREFIX=. sh
sudo mv nats-server /usr/local/bin
nats-server -v
- name: Check out code
uses: actions/checkout@v3
- name: Compile and Test
run: |
pushd encoded-kv
chmod +x gradlew && ./gradlew clean test
popd
- name: Verify Javadoc
run: |
pushd encoded-kv
./gradlew javadoc
popd
- name: Publish Snapshot
run: |
pushd encoded-kv
./gradlew -i publishToSonatype
popd
45 changes: 45 additions & 0 deletions .github/workflows/ekv-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish Extensions Pull Request

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'encoded-kv/**'

env:
GODEBUG: x509sha1=1

jobs:
build:
runs-on: ubuntu-latest
env:
BUILD_EVENT: ${{ github.event_name }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
GODEBUG: x509sha1=1
steps:
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
- name: Install Nats Server
run: |
curl -sf https://binaries.nats.dev/nats-io/nats-server/v2@main | PREFIX=. sh
sudo mv nats-server /usr/local/bin
nats-server -v
- name: Check out code
uses: actions/checkout@v3
- name: Compile and Test
run: |
pushd encoded-kv
chmod +x gradlew && ./gradlew clean test
popd
- name: Verify Javadoc
run: |
pushd encoded-kv
./gradlew javadoc
popd
43 changes: 43 additions & 0 deletions .github/workflows/ekv-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish Extensions Release

on:
push:
tags: [ 'ekv/*' ]

env:
GODEBUG: x509sha1=1

jobs:
build:
runs-on: ubuntu-latest
env:
BUILD_EVENT: "release"
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
GODEBUG: x509sha1=1
steps:
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
- name: Install Nats Server
run: |
curl -sf https://binaries.nats.dev/nats-io/nats-server/v2@main | PREFIX=. sh
sudo mv nats-server /usr/local/bin
nats-server -v
- name: Check out code
uses: actions/checkout@v3
- name: Compile and Test
run: |
pushd encoded-kv
chmod +x gradlew && ./gradlew clean test
popd
- name: Verify, Sign and Publish Release
run: |
pushd encoded-kv
./gradlew -i signArchives signMavenJavaPublication publishToSonatype closeAndReleaseSonatypeStagingRepository
popd
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions kv-encoding/build.gradle → encoded-kv/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {
id 'signing'
}

def jarVersion = "0.1.0"
def jarVersion = "0.0.1"
group = 'io.synadia'

def isMerge = System.getenv("BUILD_EVENT") == "push"
Expand Down Expand Up @@ -67,7 +67,7 @@ tasks.register('bundle', Bundle) {

jar {
manifest {
attributes('Automatic-Module-Name': 'io.synadia.kv-encoding')
attributes('Automatic-Module-Name': 'io.synadia.encoded-kv')
}
bnd (['Implementation-Title': 'KV Encoding',
'Implementation-Version': jarVersion,
Expand Down Expand Up @@ -106,7 +106,7 @@ javadoc {
tasks.register('examplesJar', Jar) {
archiveClassifier.set('examples')
manifest {
attributes('Implementation-Title': 'KV Encoding',
attributes('Implementation-Title': 'Encoded KV',
'Implementation-Version': jarVersion,
'Implementation-Vendor': 'synadia.io')
}
Expand Down Expand Up @@ -165,11 +165,11 @@ publishing {
artifact examplesJar
artifact javadocJar
pom {
name = 'kv-encoding'
name = 'encoded-kv'
packaging = 'jar'
groupId = group
artifactId = archivesBaseName
description = 'Synadia Communications Inc. KV Encoding'
description = 'Synadia Communications Inc. Encoded KV'
url = 'https://github.com/synadia-io/orbit.java'
licenses {
license {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion kv-encoding/settings.gradle → encoded-kv/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* in the user manual at https://docs.gradle.org/6.3/userguide/multi_project_builds.html
*/

rootProject.name = 'kv-encoding'
rootProject.name = 'encoded-kv'
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import io.nats.client.api.KeyResult;
import io.synadia.kv.codec.Codec;

public class CodedKeyResult<KeyType, DataType> {
public class EncodedKeyResult<KeyType, DataType> {

private final KeyResult keyResult;
private final Codec<KeyType, DataType> codec;

public CodedKeyResult(KeyResult keyResult, Codec<KeyType, DataType> codec) {
public EncodedKeyResult(KeyResult keyResult, Codec<KeyType, DataType> codec) {
this.keyResult = keyResult;
this.codec = codec;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,41 @@

import static io.nats.client.support.NatsKeyValueUtil.getOperation;

public class CodedKeyValue<KeyType, DataType> {
public class EncodedKeyValue<KeyType, DataType> {
private final Connection connection;
private final NatsKeyValueAdapter adapter;
private final Codec<KeyType, DataType> codec;

public CodedKeyValue(Connection connection, String bucketName, Codec<KeyType, DataType> codec) throws IOException {
public EncodedKeyValue(Connection connection, String bucketName, Codec<KeyType, DataType> codec) throws IOException {
this(connection, bucketName, codec, null);
}

public CodedKeyValue(Connection connection, String bucketName, Codec<KeyType, DataType> codec, KeyValueOptions kvo) throws IOException {
public EncodedKeyValue(Connection connection, String bucketName, Codec<KeyType, DataType> codec, KeyValueOptions kvo) throws IOException {
this.connection = connection;
this.codec = codec;
adapter = new NatsKeyValueAdapter(connection, bucketName, kvo);
}

public CodedKeyValueEntry<KeyType, DataType> get(KeyType key) throws IOException, JetStreamApiException {
public EncodedKeyValueEntry<KeyType, DataType> get(KeyType key) throws IOException, JetStreamApiException {
return _get(adapter.get(codec.encodeKey(key)));
}

public CodedKeyValueEntry<KeyType, DataType> get(KeyType key, long revision) throws IOException, JetStreamApiException {
public EncodedKeyValueEntry<KeyType, DataType> get(KeyType key, long revision) throws IOException, JetStreamApiException {
return _get(adapter.get(codec.encodeKey(key), revision));
}

private CodedKeyValueEntry<KeyType, DataType> _get(KeyValueEntry kve) {
private EncodedKeyValueEntry<KeyType, DataType> _get(KeyValueEntry kve) {
if (kve == null) {
return null;
}
return new CodedKeyValueEntry<>(kve, codec);
return new EncodedKeyValueEntry<>(kve, codec);
}

public List<CodedKeyValueEntry<KeyType, DataType>> history(KeyType key) throws IOException, JetStreamApiException, InterruptedException {
public List<EncodedKeyValueEntry<KeyType, DataType>> history(KeyType key) throws IOException, JetStreamApiException, InterruptedException {
List<KeyValueEntry> entries = adapter.history(codec.encodeKey(key));
List<CodedKeyValueEntry<KeyType, DataType>> encodedEntries = new ArrayList<>();
List<EncodedKeyValueEntry<KeyType, DataType>> encodedEntries = new ArrayList<>();
for (KeyValueEntry kve: entries) {
encodedEntries.add(new CodedKeyValueEntry<>(kve, codec));
encodedEntries.add(new EncodedKeyValueEntry<>(kve, codec));
}
return encodedEntries;
}
Expand Down Expand Up @@ -89,48 +89,48 @@ public void purge(KeyType key, long expectedRevision) throws IOException, JetStr
adapter.purge(codec.encodeKey(key), expectedRevision);
}

public LinkedBlockingQueue<CodedKeyResult<KeyType, DataType>> consumeKeys() {
public LinkedBlockingQueue<EncodedKeyResult<KeyType, DataType>> consumeKeys() {
return _consumeKeys(Collections.singletonList(adapter.readSubject(">")));
}

public LinkedBlockingQueue<CodedKeyResult<KeyType, DataType>> consumeKeys(KeyType filter) {
public LinkedBlockingQueue<EncodedKeyResult<KeyType, DataType>> consumeKeys(KeyType filter) {
if (!codec.allowsFiltering()) {
throw new UnsupportedOperationException("Filters not supported");
}
return _consumeKeys(Collections.singletonList(adapter.readSubject(codec.encodeKey(filter))));
return _consumeKeys(Collections.singletonList(adapter.readSubject(codec.encodeFilter(filter))));
}

public LinkedBlockingQueue<CodedKeyResult<KeyType, DataType>> consumeKeys(List<KeyType> filters) {
public LinkedBlockingQueue<EncodedKeyResult<KeyType, DataType>> consumeKeys(List<KeyType> filters) {
if (!codec.allowsFiltering()) {
throw new UnsupportedOperationException("Filters not supported");
}
List<String> encodedFilters = new ArrayList<>(filters.size());
for(KeyType f : filters) {
encodedFilters.add(adapter.readSubject(codec.encodeKey(f)));
encodedFilters.add(adapter.readSubject(codec.encodeFilter(f)));
}

return this._consumeKeys(encodedFilters);
}

private LinkedBlockingQueue<CodedKeyResult<KeyType, DataType>> _consumeKeys(List<String> readSubjectFilters) {
LinkedBlockingQueue<CodedKeyResult<KeyType, DataType>> q = new LinkedBlockingQueue<>();
private LinkedBlockingQueue<EncodedKeyResult<KeyType, DataType>> _consumeKeys(List<String> readSubjectFilters) {
LinkedBlockingQueue<EncodedKeyResult<KeyType, DataType>> q = new LinkedBlockingQueue<>();
connection.getOptions().getExecutor().submit( () -> {
try {
adapter.visitSubject(readSubjectFilters, DeliverPolicy.LastPerSubject, true, false, m -> {
KeyValueOperation op = getOperation(m.getHeaders());
if (op == KeyValueOperation.PUT) {
q.offer(new CodedKeyResult<>(
q.offer(new EncodedKeyResult<>(
new KeyResult(
new NatsKeyValueUtil.BucketAndKey(m).key), codec));
}
});
q.offer(new CodedKeyResult<>(new KeyResult(), codec));
q.offer(new EncodedKeyResult<>(new KeyResult(), codec));
}
catch (IOException | JetStreamApiException e) {
q.offer(new CodedKeyResult<>(new KeyResult(e), codec));
q.offer(new EncodedKeyResult<>(new KeyResult(e), codec));
}
catch (InterruptedException e) {
q.offer(new CodedKeyResult<>(new KeyResult(e), codec));
q.offer(new EncodedKeyResult<>(new KeyResult(e), codec));
Thread.currentThread().interrupt();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

import java.time.ZonedDateTime;

public class CodedKeyValueEntry<KeyType, DataType> {
public class EncodedKeyValueEntry<KeyType, DataType> {
final KeyValueEntry kve;
final Codec<KeyType, DataType> codec;

public CodedKeyValueEntry(KeyValueEntry kve, Codec<KeyType, DataType> codec) {
public EncodedKeyValueEntry(KeyValueEntry kve, Codec<KeyType, DataType> codec) {
this.kve = kve;
this.codec = codec;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
package io.synadia.kv;

import io.nats.client.JetStreamApiException;
import io.nats.client.api.KeyResult;
import io.nats.client.api.KeyValueWatchOption;
import io.nats.client.api.KeyValueWatcher;
import io.nats.client.impl.NatsKeyValueWatchSubscription;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;

class ToDo<KeyType, DataType> {

Expand Down Expand Up @@ -51,16 +49,4 @@ public List<String> keys(String filter) throws IOException, JetStreamApiExceptio
public List<String> keys(List<String> filters) throws IOException, JetStreamApiException, InterruptedException {
return Collections.emptyList();
}

public LinkedBlockingQueue<KeyResult> consumeKeys() {
return null;
}

public LinkedBlockingQueue<KeyResult> consumeKeys(String filter) {
return null;
}

public LinkedBlockingQueue<KeyResult> consumeKeys(List<String> filters) {
return null;
}
}
Loading