forEachDB calls fn for the defaultDB and then for every context DB in the poolCache. When there is no poolCache (single-context), only defaultDB is processed. The tenantHost passed to fn is the domain (Entry.Host), matching TenantKey's prefix.
(ctx context.Context, defaultDB *database.DB, poolCache *hostctx.PoolCache, fn func(context.Context, *database.DB, string))
| 67 | // When there is no poolCache (single-context), only defaultDB is processed. |
| 68 | // The tenantHost passed to fn is the domain (Entry.Host), matching TenantKey's prefix. |
| 69 | func forEachDB(ctx context.Context, defaultDB *database.DB, poolCache *hostctx.PoolCache, fn func(context.Context, *database.DB, string)) { |
| 70 | fn(ctx, defaultDB, "") |
| 71 | if poolCache == nil { |
| 72 | return |
| 73 | } |
| 74 | for _, host := range poolCache.ListHosts() { |
| 75 | d, err := poolCache.GetOrCreate(ctx, host) |
| 76 | if err != nil || d == nil { |
| 77 | continue |
| 78 | } |
| 79 | fn(ctx, d, host) |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // HostStatusMonitorHandler handles host-status-monitor jobs. |
| 84 | type HostStatusMonitorHandler struct { |
no test coverage detected