io.fluxcapacitor.javaclient.publishing.DefaultMetricsGateway 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.publishing;
import io.fluxcapacitor.common.MessageType;
import io.fluxcapacitor.common.api.Metadata;
import io.fluxcapacitor.javaclient.common.Message;
import io.fluxcapacitor.javaclient.common.serialization.MessageSerializer;
import io.fluxcapacitor.javaclient.publishing.client.GatewayClient;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@AllArgsConstructor
@Slf4j
public class DefaultMetricsGateway implements MetricsGateway {
private final GatewayClient metricsGateway;
private final MessageSerializer serializer;
@Override
public void publish(Object payload, Metadata metadata) {
try {
metricsGateway.send(serializer.serialize(new Message(payload, metadata, MessageType.METRICS)));
} catch (Exception e) {
throw new GatewayException(String.format("Failed to publish metrics %s", payload), e);
}
}
}