-
Notifications
You must be signed in to change notification settings - Fork 199
/
batch_udf_policy.go
72 lines (63 loc) · 2.84 KB
/
batch_udf_policy.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
// Copyright 2014-2022 Aerospike, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package aerospike
// BatchUDFPolicy attributes used in batch UDF execute commands.
type BatchUDFPolicy struct {
// Optional expression filter. If FilterExpression exists and evaluates to false, the specific batch key
// request is not performed and BatchRecord.ResultCode is set to types.FILTERED_OUT.
//
// Default: nil
FilterExpression *Expression
// Desired consistency guarantee when committing a transaction on the server. The default
// (COMMIT_ALL) indicates that the server should wait for master and all replica commits to
// be successful before returning success to the client.
//
// Default: CommitLevel.COMMIT_ALL
CommitLevel CommitLevel //= COMMIT_ALL
// Expiration determines record expiration in seconds. Also known as TTL (Time-To-Live).
// Seconds record will live before being removed by the server.
// Expiration values:
// TTLServerDefault (0): Default to namespace configuration variable "default-ttl" on the server.
// TTLDontExpire (MaxUint32): Never expire for Aerospike 2 server versions >= 2.7.2 and Aerospike 3+ server
// TTLDontUpdate (MaxUint32 - 1): Do not change ttl when record is written. Supported by Aerospike server versions >= 3.10.1
// > 0: Actual expiration in seconds.
Expiration uint32
// DurableDelete leaves a tombstone for the record if the transaction results in a record deletion.
// This prevents deleted records from reappearing after node failures.
// Valid for Aerospike Server Enterprise Edition 3.10+ only.
DurableDelete bool
// SendKey determines to whether send user defined key in addition to hash digest on both reads and writes.
// If true and the UDF writes a record, the key will be stored with the record on the server.
// The default is to not send the user defined key.
SendKey bool // = false
}
// NewBatchUDFPolicy returns a policy instance for Batch UDF commands.
func NewBatchUDFPolicy() *BatchUDFPolicy {
return &BatchUDFPolicy{
CommitLevel: COMMIT_ALL,
}
}
func (bup *BatchUDFPolicy) toWritePolicy(bp *BatchPolicy) *WritePolicy {
wp := bp.toWritePolicy()
if bup != nil {
if bup.FilterExpression != nil {
wp.FilterExpression = bup.FilterExpression
}
wp.CommitLevel = bup.CommitLevel
wp.Expiration = bup.Expiration
wp.DurableDelete = bup.DurableDelete
wp.SendKey = bup.SendKey
}
return wp
}