169
ctx context.Context,
170
filter *sqlplugin.ClusterMembershipFilter,
172
>
var queryString strings.Builder
173
>
var operands []any
174
>
queryString.WriteString(templateGetClusterMembership)
175
>
operands = append(operands, constMembershipPartition)
176
>
177
>
if filter.HostIDEquals != nil {
178
queryString.WriteString(templateWithHostIDSuffix)
179
operands = append(operands, filter.HostIDEquals)
180
}
181
183
queryString.WriteString(templateWithRPCAddressSuffix)
184
operands = append(operands, filter.RPCAddressEquals)
185
}
186
188
queryString.WriteString(templateWithRoleSuffix)
189
operands = append(operands, filter.RoleEquals)
190
}
191
193
>
queryString.WriteString(templateWithHeartbeatSinceSuffix)
194
>
operands = append(operands, filter.LastHeartbeatAfter)
195
>
}
196
198
>
queryString.WriteString(templateWithRecordExpirySuffix)
199
>
operands = append(operands, filter.RecordExpiryAfter)
200
>
}
201
203
queryString.WriteString(templateWithSessionStartSuffix)
204
operands = append(operands, filter.SessionStartedAfter)
205
}
206
208
queryString.WriteString(templateWithHostIDGreaterSuffix)
209
operands = append(operands, filter.HostIDGreaterThan)
210
}
211
213
>
214
>
if filter.MaxRecordCount > 0 {
215
queryString.WriteString(templateWithLimitSuffix)
216
operands = append(operands, filter.MaxRecordCount)
217
}
218
220
>
221
>
var rows []sqlplugin.ClusterMembershipRow
222
>
if err := mdb.SelectContext(ctx,
223
>
&rows,
224
>
compiledQryString,
225
>
operands...,
226
>
); err != nil {
227
return nil, err
228
}
230
rows[i].SessionStart = mdb.converter.FromMySQLDateTime(rows[i].SessionStart)
231
rows[i].LastHeartbeat = mdb.converter.FromMySQLDateTime(rows[i].LastHeartbeat)
232
rows[i].RecordExpiry = mdb.converter.FromMySQLDateTime(rows[i].RecordExpiry)
233
}
235
}
236