GetDeviceNames retrieves the list of device names currently stored in database
(ctx context.Context)
| 308 | |
| 309 | // GetDeviceNames retrieves the list of device names currently stored in database |
| 310 | func (m *PoolMetadata) GetDeviceNames(ctx context.Context) ([]string, error) { |
| 311 | var ( |
| 312 | names []string |
| 313 | err error |
| 314 | ) |
| 315 | |
| 316 | err = m.db.View(func(tx *bolt.Tx) error { |
| 317 | bucket := tx.Bucket(devicesBucketName) |
| 318 | return bucket.ForEach(func(k, _ []byte) error { |
| 319 | names = append(names, string(k)) |
| 320 | return nil |
| 321 | }) |
| 322 | }) |
| 323 | |
| 324 | if err != nil { |
| 325 | return nil, err |
| 326 | } |
| 327 | |
| 328 | return names, nil |
| 329 | } |
| 330 | |
| 331 | // Close closes metadata store |
| 332 | func (m *PoolMetadata) Close() error { |