-
Notifications
You must be signed in to change notification settings - Fork 13
/
DownloadBehavior.kt
49 lines (41 loc) · 1.47 KB
/
DownloadBehavior.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Copyright © 2017-2024 Kynetics, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.hara.ddiclient.api
/**
* Interface that customizes the client behaviour during the download phase
*/
interface DownloadBehavior {
/**
* Method that defines whether the client should execute a download or not.
* @param attempt index of the next download attempt for the artifact identified by [artifactId].
* Its value is in the [1, 2147483647] range, any attempt after 2147483647 will have index
* 2147483647.
* @param artifactId
* @param previousError the error that caused the failure of the previous download attempt
* @return [Try]
*/
fun onAttempt(attempt:Int, artifactId:String, previousError:Throwable? = null): Try
/**
* Class that specifies whether the client should do another download attempt
*/
sealed class Try{
/**
* The client has to stop trying to download the artifact
*/
object Stop: Try()
/**
* The client has to try downloading the artifact after [seconds] seconds
*
* @param seconds the time in seconds that the client has to wait
* before trying a download attempt
*/
data class After(val seconds:Long): Try()
}
}