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

io.github.qsy7.remote.impl.plugins.file.presend.FileTransferPreSendMessageJobRunnable Maven / Gradle / Ivy

The newest version!
package io.github.qsy7.remote.impl.plugins.file.presend;

import io.github.qsy7.file.api.service.FileStorageService;
import io.github.qsy7.property.api.annotation.Property;
import io.github.qsy7.queue.api.job.AbstractRunnable;
import io.github.qsy7.queue.event.annotation.SubscribeTo;
import io.github.qsy7.queue.impl.worker.property.JobExecutionHeartbeatTimeoutUnits;
import io.github.qsy7.queue.impl.worker.property.JobExecutionHeartbeatTimeoutValue;
import io.github.qsy7.remote.impl.plugins.file.message.FileTransferMessage;
import io.github.qsy7.timeout.TimeConstrainedMethodInvocation;
import io.github.qsy7.timeout.annotation.TimeConstrained;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import jakarta.inject.Inject;

@SubscribeTo(eventClass = FileTransferMessage.class)
public class FileTransferPreSendMessageJobRunnable extends AbstractRunnable
    implements TimeConstrainedMethodInvocation {
  protected final FileStorageService fileStorageService;

  @Inject
  public FileTransferPreSendMessageJobRunnable(
      @Property(JobExecutionHeartbeatTimeoutValue.class) long heartbeatIntervalValue,
      @Property(JobExecutionHeartbeatTimeoutUnits.class) ChronoUnit heartbeatIntervalUnits,
      FileStorageService fileStorageService) {

    this.fileStorageService = fileStorageService;
  }

  @TimeConstrained
  @Override
  protected void doCall() {
    //    fileStorageService.put(entity.getFile());
  }

  /**
   * Factor in the size of the file for the timeout here ... Assumption, 1024 kB / s (1kB /
   * millisecond) / (1 MB / s)
   *
   * @return allowed execution duration
   */
  @Override
  public Duration getAllowedExecutionDuration() {
    //    final File source = new File(entity.getFile().getSource());
    //    return Duration.ofMillis(source.length() / 1024);
    return null;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy