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

ca.vanzyl.concord.k8s.K8sEventManager Maven / Gradle / Ivy

The newest version!
package ca.vanzyl.concord.k8s;

import ca.vanzyl.concord.k8s.model.events.K8sEvent;
import com.google.common.collect.ImmutableList;
import com.walmartlabs.concord.server.process.event.NewProcessEvent;
import com.walmartlabs.concord.server.process.event.ProcessEventManager;
import com.walmartlabs.concord.server.sdk.ProcessKey;
import java.util.UUID;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

@Named
@Singleton
public class K8sEventManager {

  private final ProcessEventManager processEventManager;

  @Inject
  public K8sEventManager(ProcessEventManager processEventManager) {
    this.processEventManager = processEventManager;
  }

  public void publishEvent(ProcessKey processKey, UUID orgId, String clusterId, K8sEvent.Type type) {
    K8sEvent event = K8sEvent.builder()
        .processId(processKey.getInstanceId())
        .organizationId(orgId)
        .clusterId(clusterId)
        .type(type)
        .build();

    publishEvent(processKey, event);
  }

  private void publishEvent(ProcessKey processKey, K8sEvent event) {
    NewProcessEvent processEvent = NewProcessEvent.builder()
        .processKey(processKey)
        .eventType(K8sEvent.EVENT_TYPE_ID)
        .data(event.asMap())
        .build();

    processEventManager.event(ImmutableList.of(processEvent));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy