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

com.fluxtion.server.config.EventSinkConfig Maven / Gradle / Ivy

Go to download

A runtime server to load and run Fluxtion event processors, connecting event streams to and from processors

There is a newer version: 0.1.55
Show newest version
/*
 * SPDX-FileCopyrightText: © 2024 Gregory Higgins 
 * SPDX-License-Identifier: AGPL-3.0-only
 */

package com.fluxtion.server.config;

import com.fluxtion.agrona.concurrent.Agent;
import com.fluxtion.agrona.concurrent.IdleStrategy;
import com.fluxtion.runtime.annotations.feature.Experimental;
import com.fluxtion.runtime.output.MessageSink;
import com.fluxtion.runtime.service.Service;
import com.fluxtion.server.dutycycle.ServiceAgent;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;

import java.util.function.Function;

@Experimental
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EventSinkConfig> {

    private T instance;
    private String name;
    private Function valueMapper = Function.identity();
    //optional agent configuration
    private String agentName;
    private IdleStrategy idleStrategy;

    public boolean isAgent() {
        return agentName != null;
    }

    @SneakyThrows
    @SuppressWarnings({"unchecked", "all"})
    public Service toService() {
        instance.setValueMapper(valueMapper);
        Service svc = new Service(instance, MessageSink.class, name);
        return svc;
    }

    @SneakyThrows
    @SuppressWarnings({"unchecked", "all"})
    public  ServiceAgent toServiceAgent() {
        Service svc = toService();
        return new ServiceAgent<>(agentName, idleStrategy, svc, (A) instance);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy