167
ctx context.Context,
168
filter *sqlplugin.ClusterMembershipFilter,
170
>
var queryString strings.Builder
171
>
var operands []any
172
>
queryString.WriteString(templateGetClusterMembership)
173
>
operands = append(operands, constMembershipPartition)
174
>
175
>
if filter.HostIDEquals != nil {
176
queryString.WriteString(templateWithHostIDSuffix)
177
operands = append(operands, filter.HostIDEquals)
178
}
179
181
queryString.WriteString(templateWithRPCAddressSuffix)
182
operands = append(operands, filter.RPCAddressEquals)
183
}
184
186
queryString.WriteString(templateWithRoleSuffix)
187
operands = append(operands, filter.RoleEquals)
188
}
189
191
>
queryString.WriteString(templateWithHeartbeatSinceSuffix)
192
>
operands = append(operands, filter.LastHeartbeatAfter)
193
>
}
194
196
>
queryString.WriteString(templateWithRecordExpirySuffix)
197
>
operands = append(operands, filter.RecordExpiryAfter)
198
>
}
199
201
queryString.WriteString(templateWithSessionStartSuffix)
202
operands = append(operands, filter.SessionStartedAfter)
203
}
204
206
queryString.WriteString(templateWithHostIDGreaterSuffix)
207
operands = append(operands, filter.HostIDGreaterThan)
208
}
209
211
>
212
>
if filter.MaxRecordCount > 0 {
213
queryString.WriteString(templateWithLimitSuffix)
214
operands = append(operands, filter.MaxRecordCount)
215
}
216
218
>
219
>
var rows []sqlplugin.ClusterMembershipRow
220
>
if err := mdb.conn.SelectContext(ctx,
221
>
&rows,
222
>
compiledQryString,
223
>
operands...,
224
>
); err != nil {
225
return nil, err
226
}
228
rows[i].SessionStart = mdb.converter.FromSQLiteDateTime(rows[i].SessionStart)
229
rows[i].LastHeartbeat = mdb.converter.FromSQLiteDateTime(rows[i].LastHeartbeat)
230
rows[i].RecordExpiry = mdb.converter.FromSQLiteDateTime(rows[i].RecordExpiry)
231
}
233
}
234