Skip to content

Commit

Permalink
Rename EventStoreDBClientSettings to KurrentDBClientSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
w1am committed Dec 16, 2024
1 parent fbd5f2d commit f5ea2d7
Show file tree
Hide file tree
Showing 27 changed files with 49 additions and 56 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class AccountCreated {
```
```java
import com.eventstore.dbclient.EventStoreDBClient;
import com.eventstore.dbclient.EventStoreDBClientSettings;
import com.eventstore.dbclient.KurrentDBClientSettings;
import com.eventstore.dbclient.EventStoreDBConnectionString;
import com.eventstore.dbclient.EventData;
import com.eventstore.dbclient.ReadStreamOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private static SpanContext tryExtractTracingContext(byte[] userMetadataBytes) {
static CompletableFuture<WriteResult> traceAppend(
BiFunction<ManagedChannel, List<EventData>, CompletableFuture<WriteResult>> appendOperation,
ManagedChannel channel,
List<EventData> events, String streamId, EventStoreDBClientSettings settings,
List<EventData> events, String streamId, KurrentDBClientSettings settings,
UserCredentials optionalCallCredentials) {
Span span = createSpan(
ClientTelemetryConstants.Operations.APPEND,
Expand Down Expand Up @@ -120,7 +120,7 @@ static CompletableFuture<WriteResult> traceAppend(
}

static void traceSubscribe(Runnable tracedOperation, String subscriptionId, ManagedChannel channel,
EventStoreDBClientSettings settings,
KurrentDBClientSettings settings,
UserCredentials optionalCallCredentials, RecordedEvent event) {
if (event == null) {
tracedOperation.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Builder withServerTagsFromGrpcChannel(ManagedChannel channel) {
return withServerTags(authorityParts[0], authorityParts[1]);
}

Builder withServerTagsFromClientSettings(EventStoreDBClientSettings settings) {
Builder withServerTagsFromClientSettings(KurrentDBClientSettings settings) {
if (settings == null || !settings.isDnsDiscover()) return this;

InetSocketAddress dns = settings.getHosts()[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ClusterDiscovery implements Discovery {
private final NodeSelector nodeSelector;
private final NodeResolution resolution;

ClusterDiscovery(EventStoreDBClientSettings settings) {
ClusterDiscovery(KurrentDBClientSettings settings) {
this.nodeSelector = new NodeSelector(settings.getNodePreference());

if (settings.isDnsDiscover()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class ConnectionService implements Runnable {
private final AtomicBoolean closed;
private final LinkedBlockingQueue<Msg> queue;
private final Discovery discovery;
private final EventStoreDBClientSettings settings;
private final KurrentDBClientSettings settings;
private final ConnectionState connection;
private UUID channelId = UUID.randomUUID();
private ServerInfo serverInfo = null;

ConnectionService(EventStoreDBClientSettings settings, Discovery discovery) {
ConnectionService(KurrentDBClientSettings settings, Discovery discovery) {
this.settings = settings;
this.discovery = discovery;
this.connection = new ConnectionState(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public class ConnectionSettingsBuilder {

/**
* Returns configured connection settings.
* @see EventStoreDBClientSettings
* @see KurrentDBClientSettings
* @return configured settings.
*/
public EventStoreDBClientSettings buildConnectionSettings() {
return new EventStoreDBClientSettings(_dnsDiscover,
public KurrentDBClientSettings buildConnectionSettings() {
return new KurrentDBClientSettings(_dnsDiscover,
_maxDiscoverAttempts,
_discoveryInterval,
_gossipTimeout,
Expand Down Expand Up @@ -256,7 +256,7 @@ void parseGossipSeed(String host) {
}
}

static EventStoreDBClientSettings parseFromUrl(ConnectionSettingsBuilder builder, URL url) {
static KurrentDBClientSettings parseFromUrl(ConnectionSettingsBuilder builder, URL url) {
if (!url.getProtocol().equals("esdb") && !url.getProtocol().equals("esdb+discover"))
throw new RuntimeException(String.format("Unknown URL scheme: %s", url.getProtocol()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class ConnectionState {
private final static Logger logger = LoggerFactory.getLogger(ConnectionState.class);
private final static int MAX_INBOUND_MESSAGE_LENGTH = 17 * 1_024 * 1_024; // 17MiB
private final EventStoreDBClientSettings settings;
private final KurrentDBClientSettings settings;
private final SslContext sslContext;
private InetSocketAddress previous;
private ManagedChannel currentChannel;
Expand All @@ -28,7 +28,7 @@ class ConnectionState {
// * If we managed to read the server features (if not, it was a not found error then it's not fatal, just old node version)
private boolean confirmedChannel;

ConnectionState(EventStoreDBClientSettings settings) {
ConnectionState(KurrentDBClientSettings settings) {
this.settings = settings;

if (settings.isTls()) {
Expand Down Expand Up @@ -68,7 +68,7 @@ ManagedChannel getCurrentChannel() {
return this.currentChannel;
}

EventStoreDBClientSettings getSettings() {
KurrentDBClientSettings getSettings() {
return this.settings;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
* Many threads can use the EventStoreDB client simultaneously, or a single thread can make many asynchronous requests.
*/
public class EventStoreDBClient extends EventStoreDBClientBase {
private EventStoreDBClient(EventStoreDBClientSettings settings) {
private EventStoreDBClient(KurrentDBClientSettings settings) {
super(settings);
}

/**
* Creates a gRPC client to EventStoreDB database.
*/
public static EventStoreDBClient create(EventStoreDBClientSettings settings) {
public static EventStoreDBClient create(KurrentDBClientSettings settings) {
return new EventStoreDBClient(settings);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class EventStoreDBClientBase {
final Logger logger = LoggerFactory.getLogger(EventStoreDBClientBase.class);
final private GrpcClient client;

EventStoreDBClientBase(EventStoreDBClientSettings settings) {
EventStoreDBClientBase(KurrentDBClientSettings settings) {
Discovery discovery;

if (settings.getHosts().length == 1 && !settings.isDnsDiscover()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public final class EventStoreDBConnectionString {
* malformed.
* @return a client settings.
*/
public static EventStoreDBClientSettings parseOrThrow(String connectionString) {
ConnectionSettingsBuilder builder = EventStoreDBClientSettings.builder();
public static KurrentDBClientSettings parseOrThrow(String connectionString) {
ConnectionSettingsBuilder builder = KurrentDBClientSettings.builder();

try {
URL url = new URL(null, connectionString, new EsdbUrlHandler());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class EventStoreDBPersistentSubscriptionsClient {
private final EventStoreDBClientBase inner;

private EventStoreDBPersistentSubscriptionsClient(EventStoreDBClientSettings settings) {
private EventStoreDBPersistentSubscriptionsClient(KurrentDBClientSettings settings) {
inner = new EventStoreDBClientBase(settings);
}

Expand All @@ -24,7 +24,7 @@ private EventStoreDBPersistentSubscriptionsClient(EventStoreDBClientBase inner)
/**
* Creates a persistent subscription client instance.
*/
public static EventStoreDBPersistentSubscriptionsClient create(EventStoreDBClientSettings settings) {
public static EventStoreDBPersistentSubscriptionsClient create(KurrentDBClientSettings settings) {
return new EventStoreDBPersistentSubscriptionsClient(settings);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public class EventStoreDBProjectionManagementClient {
final EventStoreDBClientBase inner;
private EventStoreDBProjectionManagementClient(EventStoreDBClientSettings settings) {
private EventStoreDBProjectionManagementClient(KurrentDBClientSettings settings) {
inner = new EventStoreDBClientBase(settings);
}

Expand All @@ -25,7 +25,7 @@ private EventStoreDBProjectionManagementClient(EventStoreDBClientBase inner) {
* Returns the Projection Management client based on the settings.
* @param settings The settings to use for constructing the client.
*/
public static EventStoreDBProjectionManagementClient create(EventStoreDBClientSettings settings) {
public static EventStoreDBProjectionManagementClient create(KurrentDBClientSettings settings) {
return new EventStoreDBProjectionManagementClient(settings);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class GossipClient {
private final ManagedChannel _channel;
private final GossipGrpc.GossipStub _stub;

public GossipClient(EventStoreDBClientSettings settings, ManagedChannel channel) {
public GossipClient(KurrentDBClientSettings settings, ManagedChannel channel) {
_channel = channel;
_stub = GrpcUtils.configureStub(GossipGrpc.newStub(_channel), settings, new GossipOption(), (long)settings.getGossipTimeout());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class GrpcClient {
private static final Logger logger = LoggerFactory.getLogger(GrpcClient.class);
private final AtomicBoolean closed;
private final LinkedBlockingQueue<Msg> queue;
private final EventStoreDBClientSettings settings;
private final KurrentDBClientSettings settings;

GrpcClient(EventStoreDBClientSettings settings, AtomicBoolean closed, LinkedBlockingQueue<Msg> queue) {
GrpcClient(KurrentDBClientSettings settings, AtomicBoolean closed, LinkedBlockingQueue<Msg> queue) {
this.settings = settings;
this.closed = closed;
this.queue = queue;
Expand Down Expand Up @@ -112,7 +112,7 @@ public CompletableFuture<Void> shutdown() {
return this.push(new Shutdown(completion::complete)).thenComposeAsync(x -> completion);
}

public EventStoreDBClientSettings getSettings() {
public KurrentDBClientSettings getSettings() {
return this.settings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ static public StreamsOuterClass.ReadReq.Options.StreamOptions toStreamOptions(St
.build();
}

static public <S extends AbstractAsyncStub<S>, O> S configureStub(S stub, EventStoreDBClientSettings settings, OptionsBase<O> options) {
static public <S extends AbstractAsyncStub<S>, O> S configureStub(S stub, KurrentDBClientSettings settings, OptionsBase<O> options) {
return configureStub(stub, settings, options, null);
}

static public <S extends AbstractAsyncStub<S>, O> S configureStub(S stub, EventStoreDBClientSettings settings, OptionsBase<O> options, Long forceDeadlineInMs) {
static public <S extends AbstractAsyncStub<S>, O> S configureStub(S stub, KurrentDBClientSettings settings, OptionsBase<O> options, Long forceDeadlineInMs) {
S finalStub = stub;
ConnectionMetadata metadata = new ConnectionMetadata();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* <li>keepAliveInterval: 10000</li>
* </ul>
*/
public class EventStoreDBClientSettings {
public class KurrentDBClientSettings {
private final boolean dnsDiscover;
private final int maxDiscoverAttempts;
private final int discoveryInterval;
Expand Down Expand Up @@ -167,7 +167,7 @@ public String getTlsCaFile() {
*/
public Set<String> getFeatures() { return features; }

EventStoreDBClientSettings(
KurrentDBClientSettings(
boolean dnsDiscover,
int maxDiscoverAttempts,
int discoveryInterval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.function.Function;

class ServerFeatures {
public static Optional<ServerInfo> getSupportedFeatures(EventStoreDBClientSettings settings, ManagedChannel channel) {
public static Optional<ServerInfo> getSupportedFeatures(KurrentDBClientSettings settings, ManagedChannel channel) {
final ServerFeaturesGrpc.ServerFeaturesStub stub = ServerFeaturesGrpc.newStub(channel);
try {
return Optional.ofNullable(getSupportedFeaturesInternal(stub).get(settings.getGossipTimeout(), TimeUnit.MILLISECONDS));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.eventstore.dbclient;

import com.eventstore.dbclient.EventStoreDBClientSettings;
import com.eventstore.dbclient.OptionsBase;
import com.eventstore.dbclient.ServerInfo;
import io.grpc.ManagedChannel;

import java.io.IOException;
Expand Down Expand Up @@ -46,7 +43,7 @@ public boolean supportFeature(int feature) {
return info != null && info.supportFeature(feature);
}

public <A> HttpURLConnection getHttpConnection(OptionsBase<A> options, EventStoreDBClientSettings settings, String path) {
public <A> HttpURLConnection getHttpConnection(OptionsBase<A> options, KurrentDBClientSettings settings, String path) {
try {
HttpURLConnection conn = (HttpURLConnection) getURL(settings.isTls(), this.endpoint, path).openConnection();
conn.setRequestProperty("Accept", ContentType.JSON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public class ClientTracker {
private ArrayList<EventStoreDBClientBase> otherClients = new ArrayList<>();
private EventStoreDBClient defaultClient = null;

public synchronized EventStoreDBClient createClient(EventStoreDBClientSettings settings) {
public synchronized EventStoreDBClient createClient(KurrentDBClientSettings settings) {
EventStoreDBClient client = EventStoreDBClient.create(settings);
otherClients.add(client);
return client;
}

public synchronized EventStoreDBClient getDefaultClient(Database database) {
if (defaultClient == null) {
EventStoreDBClientSettings settings = database.defaultSettingsBuilder().buildConnectionSettings();
KurrentDBClientSettings settings = database.defaultSettingsBuilder().buildConnectionSettings();
defaultClient = EventStoreDBClient.create(settings);

if (settings.isTls() && settings.getDefaultCredentials() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.function.Function;

public interface Database {
Expand All @@ -29,7 +27,7 @@ default EventStoreDBClient defaultClient() {
return getClientTracker().getDefaultClient(this);
}

default EventStoreDBClient createClient(EventStoreDBClientSettings settings) {
default EventStoreDBClient createClient(KurrentDBClientSettings settings) {
return getClientTracker().createClient(settings);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public DockerContainerDatabase(Builder builder) {

@Override
public ConnectionSettingsBuilder defaultSettingsBuilder() {
ConnectionSettingsBuilder settingsBuilder = EventStoreDBClientSettings.builder().addHost(getHost(), getMappedPort(2113));
ConnectionSettingsBuilder settingsBuilder = KurrentDBClientSettings.builder().addHost(getHost(), getMappedPort(2113));

if (!builder.anonymous)
settingsBuilder.defaultCredentials("admin", "changeit");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public ExternallyCreatedCluster(boolean secure) {

@Override
public ConnectionSettingsBuilder defaultSettingsBuilder() {
return EventStoreDBClientSettings
return KurrentDBClientSettings
.builder()
.dnsDiscover(true)
.defaultCredentials("admin", "changeit")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static Stream<Arguments> validConnectionStrings() {
);
}

public void assertEquals(EventStoreDBClientSettings settings, EventStoreDBClientSettings other) {
public void assertEquals(KurrentDBClientSettings settings, KurrentDBClientSettings other) {
Assertions.assertEquals(settings.isDnsDiscover(), other.isDnsDiscover());
Assertions.assertEquals(settings.getMaxDiscoverAttempts(), other.getMaxDiscoverAttempts());
Assertions.assertEquals(settings.getDiscoveryInterval(), other.getDiscoveryInterval());
Expand All @@ -147,14 +147,14 @@ public void assertEquals(EventStoreDBClientSettings settings, EventStoreDBClient
@MethodSource("validConnectionStrings")
public void test(String connectionString, String json) throws ConnectionStringParsingException, JsonProcessingException {

EventStoreDBClientSettings expectedSettings = this.parseJson(json);
EventStoreDBClientSettings parsedSettings = EventStoreDBConnectionString.parseOrThrow(connectionString);
KurrentDBClientSettings expectedSettings = this.parseJson(json);
KurrentDBClientSettings parsedSettings = EventStoreDBConnectionString.parseOrThrow(connectionString);

this.assertEquals(expectedSettings, parsedSettings);
}

private EventStoreDBClientSettings parseJson(String input) throws JsonProcessingException {
ConnectionSettingsBuilder builder = EventStoreDBClientSettings.builder();
private KurrentDBClientSettings parseJson(String input) throws JsonProcessingException {
ConnectionSettingsBuilder builder = KurrentDBClientSettings.builder();
JsonNode tree = mapper.readTree(input);

if (tree.get("dnsDiscover") != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.eventstore.dbclient.samples.authentication;

import com.eventstore.dbclient.EventStoreDBClient;
import com.eventstore.dbclient.EventStoreDBClientSettings;
import com.eventstore.dbclient.KurrentDBClientSettings;
import com.eventstore.dbclient.EventStoreDBConnectionString;

public class UserCertificate {
private static void tracing() {
// region client-with-user-certificates
EventStoreDBClientSettings settings = EventStoreDBConnectionString
KurrentDBClientSettings settings = EventStoreDBConnectionString
.parseOrThrow("esdb://admin:changeit@{endpoint}?tls=true&userCertFile={pathToCaFile}&userKeyFile={pathToKeyFile}");
EventStoreDBClient client = EventStoreDBClient.create(settings);
// endregion client-with-user-certificates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void testProjectionManagementSamples() throws Throwable {

private static EventStoreDBProjectionManagementClient createClient(String connection) {
// region createClient
EventStoreDBClientSettings settings = EventStoreDBConnectionString.parseOrThrow(connection);
KurrentDBClientSettings settings = EventStoreDBConnectionString.parseOrThrow(connection);
EventStoreDBProjectionManagementClient client = EventStoreDBProjectionManagementClient.create(settings);
// endregion createClient

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.json.JsonMapper;

import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;

public class QuickStart {
public static void Run() throws ConnectionStringParsingException, ExecutionException, InterruptedException, JsonProcessingException {
// region createClient
EventStoreDBClientSettings settings = EventStoreDBConnectionString.parseOrThrow("{connectionString}");
KurrentDBClientSettings settings = EventStoreDBConnectionString.parseOrThrow("{connectionString}");
EventStoreDBClient client = EventStoreDBClient.create(settings);
// endregion createClient

Expand Down
Loading

0 comments on commit f5ea2d7

Please # to comment.