P
// CallAsync sends a call to registered tarantool function and returns Future.
// It uses request code for tarantool 1.6, so future's result is always array of arrays
Size: a a a
P
function select_few_rec_by_primary(array)
out = {}
for i = 1, #array do
t = box.space.first_space:select{array[i]}
if #t > 0 then
t = t[1]:totable()
p = box.space.second_space:select{t[2]}
if #p > 0 then
t[#t+1] = p[1][3]
else
t[#t+1] = nil
end
out[#out+1] = t
end
fiber.yield()
end
return out
end
А это гошный кусок
func (t tar) Get(keys []int64) ([]model.ActualInfo, error) {
actualInfo := make([]model.ActualInfo, 0, len(keys))
fut := datasource.Tarantool.CallAsync("select_few_rec_by_primary", []interface{}{keys})
err := fut.GetTyped(&actualInfo)
if err != nil {
log.Println(err)
tarantoolError, ok := err.(tarantool.ClientError)
if !ok {
return nil, err
}
if tarantoolError.Code == tarantool.ErrConnectionClosed {
return nil, datasource.ReconnectTarantool(datasource.Tarantool, 1)
}
}
return actualInfo, nil
}
callTyped
использоватьAK
function select_few_rec_by_primary(array)
out = {}
for i = 1, #array do
t = box.space.first_space:select{array[i]}
if #t > 0 then
t = t[1]:totable()
p = box.space.second_space:select{t[2]}
if #p > 0 then
t[#t+1] = p[1][3]
else
t[#t+1] = nil
end
out[#out+1] = t
end
fiber.yield()
end
return out
end
А это гошный кусок
func (t tar) Get(keys []int64) ([]model.ActualInfo, error) {
actualInfo := make([]model.ActualInfo, 0, len(keys))
fut := datasource.Tarantool.CallAsync("select_few_rec_by_primary", []interface{}{keys})
err := fut.GetTyped(&actualInfo)
if err != nil {
log.Println(err)
tarantoolError, ok := err.(tarantool.ClientError)
if !ok {
return nil, err
}
if tarantoolError.Code == tarantool.ErrConnectionClosed {
return nil, datasource.ReconnectTarantool(datasource.Tarantool, 1)
}
}
return actualInfo, nil
}
AK
PL
AS
MS
MS
AS
AS
MS
MS