FileSponge/src/main/lombok/org/warp/filesponge/api/FileActor.java

73 lines
2.4 KiB
Java
Raw Normal View History

2020-09-23 22:45:55 +02:00
/*
* FileSponge
* Copyright (C) 2020 Andrea Cavalli
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2020-09-24 00:09:22 +02:00
package org.warp.filesponge.api;
2020-09-23 22:45:55 +02:00
2020-09-24 11:31:52 +02:00
import java.time.Duration;
2020-09-24 11:59:46 +02:00
import org.warp.filesponge.value.FileURI;
2021-01-11 01:29:53 +01:00
import reactor.core.publisher.Mono;
2020-09-24 11:31:52 +02:00
/**
* FileActor sends signals to a mirror
*/
2020-12-04 22:41:05 +01:00
public interface FileActor<FURI extends FileURI> {
2020-09-24 11:31:52 +02:00
/**
* Send a "delete file" signal
*
* @param fileURI File URI
2021-01-11 01:29:53 +01:00
* @return true if the signal can be sent. Cannot be empty.
2020-09-24 11:31:52 +02:00
*/
2021-01-11 01:29:53 +01:00
Mono<Boolean> deleteFile(FURI fileURI);
2020-09-24 11:31:52 +02:00
/**
* Send a "download file" signal
*
* @param fileURI File URI
2021-01-11 01:29:53 +01:00
* @return true if the signal can be sent. Cannot be empty.
2020-09-24 11:31:52 +02:00
*/
2021-01-11 01:29:53 +01:00
Mono<Boolean> downloadFile(FURI fileURI);
2020-09-24 11:31:52 +02:00
/**
* Check if this actor can handle signals for this file
*
* @param fileURI File URI
2021-01-11 01:29:53 +01:00
* @return true if the actor can send signals related to this file. Cannot be empty.
2020-09-24 11:31:52 +02:00
*/
2021-01-11 01:29:53 +01:00
Mono<Boolean> canHandleFile(FURI fileURI);
2020-09-24 11:31:52 +02:00
/**
* Send a "download file" signal
*
2020-12-04 17:33:29 +01:00
* @param timeout if it's 0 the method will return immediately, if it's set the method will wait until a file
2020-09-24 11:51:41 +02:00
* <b>download request</b> has been found, or the timeout time elapsed
* @return empty if no pending <b>download requests</b> has been found, true if the signal can be sent, false
* otherwise
2020-09-24 11:31:52 +02:00
*/
2021-01-11 01:29:53 +01:00
Mono<Boolean> downloadNextFile(Duration timeout);
2020-09-24 11:31:52 +02:00
/**
* Send a "delete file" signal
*
2020-12-04 17:33:29 +01:00
* @param timeout if it's 0 the method will return immediately, if it's set the method will wait until a file
2020-09-24 11:51:41 +02:00
* <b>delete request</b> has been found, or the timeout time elapsed
* @return empty if no pending <b>delete requests</b> has been found, true if the signal can be sent, false otherwise
2020-09-24 11:31:52 +02:00
*/
2021-01-11 01:29:53 +01:00
Mono<Boolean> deleteNextFile(Duration timeout);
2020-09-24 11:31:52 +02:00
}