@@ -8,8 +8,8 @@ import com.aerospike.client.task.ExecuteTask
8
8
import com .typesafe .config .Config
9
9
import io .github .reugn .aerospike .scala ._
10
10
import io .github .reugn .aerospike .scala .model .QueryStatement
11
- import zio .Task
12
11
import zio .stream .ZStream
12
+ import zio .{Task , ZIO }
13
13
14
14
import java .util .Calendar
15
15
import scala .collection .JavaConverters .seqAsJavaListConverter
@@ -19,49 +19,49 @@ class ZioAerospikeHandler(protected val client: IAerospikeClient)
19
19
with StreamHandler3 [ZStream ] {
20
20
21
21
override def put (key : Key , bins : Bin * )(implicit policy : WritePolicy ): Task [Key ] = {
22
- Task (client.put(policy, key, bins : _* )).map(_ => key)
22
+ ZIO .attemptBlocking (client.put(policy, key, bins : _* )).map(_ => key)
23
23
}
24
24
25
25
override def append (key : Key , bins : Bin * )(implicit policy : WritePolicy ): Task [Key ] = {
26
- Task (client.append(policy, key, bins : _* )).map(_ => key)
26
+ ZIO .attemptBlocking (client.append(policy, key, bins : _* )).map(_ => key)
27
27
}
28
28
29
29
override def prepend (key : Key , bins : Bin * )(implicit policy : WritePolicy ): Task [Key ] = {
30
- Task (client.prepend(policy, key, bins : _* )).map(_ => key)
30
+ ZIO .attemptBlocking (client.prepend(policy, key, bins : _* )).map(_ => key)
31
31
}
32
32
33
33
override def add (key : Key , bins : Bin * )(implicit policy : WritePolicy ): Task [Key ] = {
34
- Task (client.add(policy, key, bins : _* )).map(_ => key)
34
+ ZIO .attemptBlocking (client.add(policy, key, bins : _* )).map(_ => key)
35
35
}
36
36
37
37
override def delete (key : Key )(implicit policy : WritePolicy ): Task [Boolean ] = {
38
- Task (client.delete(policy, key))
38
+ ZIO .attemptBlocking (client.delete(policy, key))
39
39
}
40
40
41
41
override def deleteBatch (keys : Seq [Key ])
42
42
(implicit policy : BatchPolicy , batchDeletePolicy : BatchDeletePolicy ): Task [BatchResults ] = {
43
- Task (client.delete(policy, batchDeletePolicy, keys.toArray))
43
+ ZIO .attemptBlocking (client.delete(policy, batchDeletePolicy, keys.toArray))
44
44
}
45
45
46
46
override def truncate (ns : String , set : String , beforeLastUpdate : Option [Calendar ] = None )
47
47
(implicit policy : InfoPolicy ): Task [Unit ] = {
48
- Task (client.truncate(policy, ns, set, beforeLastUpdate.orNull))
48
+ ZIO .attemptBlocking (client.truncate(policy, ns, set, beforeLastUpdate.orNull))
49
49
}
50
50
51
51
override def touch (key : Key )(implicit policy : WritePolicy ): Task [Key ] = {
52
- Task (client.touch(policy, key)).map(_ => key)
52
+ ZIO .attemptBlocking (client.touch(policy, key)).map(_ => key)
53
53
}
54
54
55
55
override def exists (key : Key )(implicit policy : Policy ): Task [Boolean ] = {
56
- Task (client.exists(policy, key))
56
+ ZIO .attemptBlocking (client.exists(policy, key))
57
57
}
58
58
59
59
override def existsBatch (keys : Seq [Key ])(implicit policy : BatchPolicy ): Task [Seq [Boolean ]] = {
60
- Task (client.exists(policy, keys.toArray)).map(_.toIndexedSeq)
60
+ ZIO .attemptBlocking (client.exists(policy, keys.toArray)).map(_.toIndexedSeq)
61
61
}
62
62
63
63
override def get (key : Key , binNames : String * )(implicit policy : Policy ): Task [Record ] = {
64
- Task {
64
+ ZIO .attemptBlocking {
65
65
if (binNames.toArray.length > 0 )
66
66
client.get(policy, key, binNames : _* )
67
67
else
@@ -70,7 +70,7 @@ class ZioAerospikeHandler(protected val client: IAerospikeClient)
70
70
}
71
71
72
72
override def getBatch (keys : Seq [Key ], binNames : String * )(implicit policy : BatchPolicy ): Task [Seq [Record ]] = {
73
- Task {
73
+ ZIO .attemptBlocking {
74
74
if (binNames.toArray.length > 0 )
75
75
client.get(policy, keys.toArray, binNames : _* )
76
76
else
@@ -81,33 +81,33 @@ class ZioAerospikeHandler(protected val client: IAerospikeClient)
81
81
}
82
82
83
83
override def getBatchOp (keys : Seq [Key ], operations : Operation * )(implicit policy : BatchPolicy ): Task [Seq [Record ]] = {
84
- Task (client.get(policy, keys.toArray, operations : _* ))
84
+ ZIO .attemptBlocking (client.get(policy, keys.toArray, operations : _* ))
85
85
}
86
86
87
87
override def getHeader (key : Key )(implicit policy : Policy ): Task [Record ] = {
88
- Task (client.getHeader(policy, key))
88
+ ZIO .attemptBlocking (client.getHeader(policy, key))
89
89
}
90
90
91
91
override def getHeaderBatch (keys : Seq [Key ])(implicit policy : BatchPolicy ): Task [Seq [Record ]] = {
92
- Task (client.getHeader(policy, keys.toArray)).map(_.toIndexedSeq)
92
+ ZIO .attemptBlocking (client.getHeader(policy, keys.toArray)).map(_.toIndexedSeq)
93
93
}
94
94
95
95
override def operate (key : Key , operations : Operation * )(implicit policy : WritePolicy ): Task [Record ] = {
96
- Task (client.operate(policy, key, operations : _* ))
96
+ ZIO .attemptBlocking (client.operate(policy, key, operations : _* ))
97
97
}
98
98
99
99
override def operateBatch (keys : Seq [Key ], operations : Operation * )
100
100
(implicit policy : BatchPolicy , batchWritePolicy : BatchWritePolicy ): Task [BatchResults ] = {
101
- Task (client.operate(policy, batchWritePolicy, keys.toArray, operations : _* ))
101
+ ZIO .attemptBlocking (client.operate(policy, batchWritePolicy, keys.toArray, operations : _* ))
102
102
}
103
103
104
104
override def operateBatchRecord (records : Seq [BatchRecord ])(implicit policy : BatchPolicy ): Task [Boolean ] = {
105
- Task (client.operate(policy, records.asJava))
105
+ ZIO .attemptBlocking (client.operate(policy, records.asJava))
106
106
}
107
107
108
108
override def scanNodeName (nodeName : String , ns : String , set : String , binNames : String * )
109
109
(implicit policy : ScanPolicy ): Task [List [KeyRecord ]] = {
110
- Task {
110
+ ZIO .attemptBlocking {
111
111
val callback = RecordScanCallback ()
112
112
client.scanNode(policy, nodeName, ns, set, callback, binNames : _* )
113
113
callback.getRecordSet
@@ -116,7 +116,7 @@ class ZioAerospikeHandler(protected val client: IAerospikeClient)
116
116
117
117
override def scanNode (node : Node , ns : String , set : String , binNames : String * )
118
118
(implicit policy : ScanPolicy ): Task [List [KeyRecord ]] = {
119
- Task {
119
+ ZIO .attemptBlocking {
120
120
val callback = RecordScanCallback ()
121
121
client.scanNode(policy, node, ns, set, callback, binNames : _* )
122
122
callback.getRecordSet
@@ -125,11 +125,11 @@ class ZioAerospikeHandler(protected val client: IAerospikeClient)
125
125
126
126
override def execute (statement : Statement , operations : Operation * )
127
127
(implicit policy : WritePolicy ): Task [ExecuteTask ] = {
128
- Task (client.execute(policy, statement, operations : _* ))
128
+ ZIO .attemptBlocking (client.execute(policy, statement, operations : _* ))
129
129
}
130
130
131
131
override def info (node : Node , name : String ): Task [String ] = {
132
- Task (Info .request(node, name))
132
+ ZIO .attemptBlocking (Info .request(node, name))
133
133
}
134
134
135
135
override def query (statement : QueryStatement )
0 commit comments