@@ -3,22 +3,69 @@ package zio.sqs
3
3
import zio .aws .sqs .model ._
4
4
import zio ._
5
5
6
- case class SqsStreamSettings (
7
- attributeNames : List [QueueAttributeName ] = Nil ,
8
- maxNumberOfMessages : Int = 1 ,
9
- messageAttributeNames : List [String ] = Nil ,
10
- visibilityTimeout : Option [Int ] = Some (30 ),
11
- waitTimeSeconds : Option [Int ] = Some (20 ),
12
- autoDelete : Boolean = true ,
13
- stopWhenQueueEmpty : Boolean = false
14
- )
6
+ final case class SqsStreamSettings (
7
+ attributeNames : List [QueueAttributeName ],
8
+ maxNumberOfMessages : Option [Int ],
9
+ messageAttributeNames : List [String ],
10
+ visibilityTimeout : Option [Int ],
11
+ waitTimeSeconds : Option [Int ],
12
+ autoDelete : Boolean ,
13
+ stopWhenQueueEmpty : Boolean
14
+ ) {
15
+ def withAttributeName (attributeName : QueueAttributeName ): SqsStreamSettings =
16
+ copy(attributeNames = attributeName :: attributeNames)
17
+
18
+ def withAttributeNames (attributeNames : List [QueueAttributeName ]): SqsStreamSettings =
19
+ copy(attributeNames = attributeNames)
20
+
21
+ def withMaxNumberOfMessages (maxNumberOfMessages : Int ): SqsStreamSettings =
22
+ copy(maxNumberOfMessages = Some (maxNumberOfMessages))
23
+
24
+ def withMessageAttributeName (name : String ): SqsStreamSettings =
25
+ copy(messageAttributeNames = name :: messageAttributeNames)
26
+
27
+ def withMessageAttributeNames (names : List [String ]): SqsStreamSettings =
28
+ copy(messageAttributeNames = messageAttributeNames ::: names)
29
+
30
+ def withVisibilityTimeout (seconds : Int ): SqsStreamSettings =
31
+ copy(visibilityTimeout = Some (seconds))
32
+
33
+ def withWaitTimeSeconds (seconds : Int ): SqsStreamSettings =
34
+ copy(waitTimeSeconds = Some (seconds))
35
+
36
+ def withAutoDelete (autoDelete : Boolean ): SqsStreamSettings =
37
+ copy(autoDelete = autoDelete)
38
+
39
+ def withStopWhenQueueEmpty (stopWhenQueueEmpty : Boolean ): SqsStreamSettings =
40
+ copy(stopWhenQueueEmpty = stopWhenQueueEmpty)
41
+ }
42
+ object SqsStreamSettings {
43
+ val default = SqsStreamSettings (
44
+ attributeNames = Nil ,
45
+ maxNumberOfMessages = None ,
46
+ messageAttributeNames = Nil ,
47
+ visibilityTimeout = None ,
48
+ waitTimeSeconds = None ,
49
+ autoDelete = false ,
50
+ stopWhenQueueEmpty = false
51
+ )
52
+ }
15
53
16
54
final case class SqsMessageLifetimeExtensionSettings (
17
55
automaticExtension : Boolean ,
18
56
maximumRetries : Int ,
19
57
overrideInitialDelay : Option [Duration ],
20
58
overrideRepeatSchedule : Option [Schedule [Any , Any , Any ]]
21
59
) {
60
+ def withAutomaticExtension (automaticExtension : Boolean ): SqsMessageLifetimeExtensionSettings =
61
+ copy(automaticExtension = automaticExtension)
62
+
63
+ def withMaximumRetries (maximumRetries : Int ): SqsMessageLifetimeExtensionSettings =
64
+ copy(maximumRetries = maximumRetries)
65
+
66
+ def withOverrideInitialDelay (overrideInitialDelay : Duration ): SqsMessageLifetimeExtensionSettings =
67
+ copy(overrideInitialDelay = Some (overrideInitialDelay))
68
+
22
69
def schedule (settings : SqsStreamSettings ): Schedule [Any , Any , Any ] =
23
70
overrideRepeatSchedule.getOrElse(
24
71
Schedule .spaced(
0 commit comments