All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.fluxcapacitor.javaclient.publishing.DefaultMetricsGateway Maven / Gradle / Ivy

There is a newer version: 0.1015.0
Show newest version
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);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy