tinyrelayfile
tinyrelay/internal/daemon/tenant_delete.go/

internal/daemon/tenant_delete.go raw
1package daemon
2
3import (
4 "context"
5 "errors"
6
7 "github.com/FelineStateMachine/tinyrelay/internal/catalog"
8)
9
10// deleteTenant stops the live services before erasing the catalog row and
11// tenant directory. It removes the app map entry before waiting so a request
12// arriving concurrently cannot acquire a second reference to the tenant.
13func (a *App) deleteTenant(ctx context.Context, id string) error {
14 a.mu.Lock()
15 t := a.tenants[id]
16 if t == nil {
17 a.mu.Unlock()
18 return catalog.ErrNotFound
19 }
20 if err := a.catalog.Disable(ctx, id); err != nil && !errors.Is(err, catalog.ErrInvalidTransition) {
21 a.mu.Unlock()
22 return err
23 }
24 delete(a.tenants, id)
25 a.mu.Unlock()
26 if err := t.Close(ctx); err != nil {
27 return err
28 }
29 return a.catalog.Delete(ctx, id)
30}

About

ownerc01503e8035f
visibilitypublic
headd730679639bf

Maintainers

  • c01503e8035f owner
  • ba1b5beed5b5 agent hermes

Clone

  • https://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git

Refs