aerospike / aerospike-client-go

Aerospike Client Go
Apache License 2.0
429 stars 199 forks source link

GetOp is giving parameter error #388

Closed artman92 closed 1 year ago

artman92 commented 1 year ago
asKey, err := aerospike.NewKey(asNamespace, set, key)
listPolicy := aerospike.NewListPolicy(aerospike.ListOrderUnordered, aerospike.ListWriteFlagsAddUnique|aerospike.ListWriteFlagsNoFail)   
ops := []*aerospike.Operation{
        aerospike.AddOp(aerospike.NewBin(count, 1)),
        aerospike.AddOp(aerospike.NewBin(points, points)),

        aerospike.ListAppendWithPolicyOp(listPolicy, ids, id),
        aerospike.MapIncrementOp(aerospike.DefaultMapPolicy(), mapId, count, 1),
        aerospike.MapIncrementOp(aerospike.DefaultMapPolicy(), mapId, points, points),
                aerospike.GetOp()
    }
record, err := asClient.Operate(nil, asKey, ops...)
fmt.Println("result->:", record, ",", err)
// output - error is coming as **parameter error,**

Error is not coming after removing aerospike.GetOp() Can you please help with this?

khaf commented 1 year ago

Sorry your question flew under the radar. If you look in the server logs, you'll find something like the following line: WARNING (rw): (write.c:1107) {test} write_master: read-all op can't have respond-all-ops flag That means that you have to pass a policy the operate command and set it up like this:

wp := as.NewWritePolicy(0, 0)
wp.RespondPerEachOp = false
record, err := client.Operate(wp, asKey, ops...)

That will take care of this issue.

khaf commented 1 year ago

I'm closing this issue. Don't hesitate to file new tickets in case you had any further questions.