io.fluxcapacitor.javaclient.configuration.client.AbstractClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-client Show documentation
Show all versions of java-client Show documentation
Default Java client library for interfacing with Flux Capacitor.
package io.fluxcapacitor.javaclient.configuration.client;
import io.fluxcapacitor.common.MessageType;
import io.fluxcapacitor.javaclient.eventsourcing.client.EventStoreClient;
import io.fluxcapacitor.javaclient.keyvalue.client.KeyValueClient;
import io.fluxcapacitor.javaclient.publishing.client.GatewayClient;
import io.fluxcapacitor.javaclient.scheduling.client.SchedulingClient;
import io.fluxcapacitor.javaclient.tracking.client.TrackingClient;
import java.util.function.Function;
import static io.fluxcapacitor.common.ObjectUtils.memoize;
public abstract class AbstractClient implements Client {
private final String name;
private final String id;
private final Function gatewayClients;
private final Function trackingClients;
private final EventStoreClient eventStoreClient;
private final SchedulingClient schedulingClient;
private final KeyValueClient keyValueClient;
public AbstractClient(String name, String id, Function gatewayClients,
Function trackingClients,
EventStoreClient eventStoreClient, SchedulingClient schedulingClient,
KeyValueClient keyValueClient) {
this.name = name;
this.id = id;
this.gatewayClients = memoize(gatewayClients);
this.trackingClients = memoize(trackingClients);
this.eventStoreClient = eventStoreClient;
this.schedulingClient = schedulingClient;
this.keyValueClient = keyValueClient;
}
@Override
public String name() {
return name;
}
@Override
public String id() {
return id;
}
@Override
public GatewayClient getGatewayClient(MessageType messageType) {
return gatewayClients.apply(messageType);
}
@Override
public TrackingClient getTrackingClient(MessageType messageType) {
return trackingClients.apply(messageType);
}
@Override
public EventStoreClient getEventStoreClient() {
return eventStoreClient;
}
@Override
public SchedulingClient getSchedulingClient() {
return schedulingClient;
}
@Override
public KeyValueClient getKeyValueClient() {
return keyValueClient;
}
}