This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 278
/
retry.go
75 lines (59 loc) · 2.43 KB
/
retry.go
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Retry is the type used to represent a Retry policy.
// A Retry policy authorizes retries to failed attempts for outbound traffic
// from one service source to one or more destination services.
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type Retry struct {
// Object's type metadata
metav1.TypeMeta `json:",inline"`
// Object's metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec is the Retry policy specification
// +optional
Spec RetrySpec `json:"spec,omitempty"`
}
// RetrySpec is the type used to represent the Retry policy specification.
type RetrySpec struct {
// Source defines the source the Retry policy applies to.
Source RetrySrcDstSpec `json:"source"`
// Destinations defines the list of destinations the Retry policy applies to.
Destinations []RetrySrcDstSpec `json:"destinations"`
// RetryPolicy defines the retry policy the Retry policy applies.
RetryPolicy RetryPolicySpec `json:"retryPolicy"`
}
// RetrySrcDstSpec is the type used to represent the Destination in the list of Destinations and the Source
// specified in the Retry policy specification.
type RetrySrcDstSpec struct {
// Kind defines the kind for the Src/Dst in the Retry policy.
Kind string `json:"kind"`
// Name defines the name of the Src/Dst for the given Kind.
Name string `json:"name"`
// Namespace defines the namespace for the given Src/Dst.
Namespace string `json:"namespace"`
}
// RetryPolicySpec is the type used to represent the retry policy specified in the Retry policy specification.
type RetryPolicySpec struct {
// RetryOn defines the policies to retry on, delimited by comma.
RetryOn string `json:"retryOn"`
// PerTryTimeout defines the time allowed for a retry before it's considered a failed attempt.
// +optional
PerTryTimeout *metav1.Duration `json:"perTryTimeout"`
// NumRetries defines the max number of retries to attempt.
// +optional
NumRetries *uint32 `json:"numRetries"`
// RetryBackoffBaseInterval defines the base interval for exponential retry backoff.
// +optional
RetryBackoffBaseInterval *metav1.Duration `json:"retryBackoffBaseInterval"`
}
// RetryList defines the list of Retry objects.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type RetryList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Retry `json:"items"`
}