mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
fix(cluster): improve error handling on failed machine subscription in cluster store
This commit is contained in:
@@ -208,6 +208,8 @@ func (s *Store) DeleteContainers(ctx context.Context, opts DeleteOptions) error
|
||||
// SubscribeContainers returns a list of containers and a channel that signals changes to the list. The channel doesn't
|
||||
// receive any values, it just signals when a container(s) has been added, updated, or deleted in the database.
|
||||
// The result excludes orphan containers whose machine is no longer in the cluster.
|
||||
// The channel is closed when the containers are no longer subscribable: either the provided context is cancelled or
|
||||
// the underlying subscription fails.
|
||||
func (s *Store) SubscribeContainers(ctx context.Context) ([]ContainerRecord, <-chan struct{}, error) {
|
||||
// TODO: figure out whether we need sync_status at all (not used at the moment).
|
||||
q := sq.Select("c.id", "c.container", "c.machine_id", "c.sync_status", "c.updated_at").
|
||||
|
||||
@@ -265,6 +265,8 @@ func (s *Store) DeleteMachine(ctx context.Context, id string) error {
|
||||
|
||||
// SubscribeMachines returns a list of machines and a channel that signals changes to the list. The channel doesn't
|
||||
// receive any values, it just signals when a machine has been added, updated, or deleted in the database.
|
||||
// The channel is closed when the machines are no longer subscribable: either the provided context is cancelled or
|
||||
// the underlying subscription fails.
|
||||
func (s *Store) SubscribeMachines(ctx context.Context) ([]*pb.MachineInfo, <-chan struct{}, error) {
|
||||
sub, err := s.corro.SubscribeContext(ctx, "SELECT id, info FROM machines ORDER BY name", nil, false)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user