(entity params.ForgeEntity, operation common.OperationType)
| 51 | } |
| 52 | |
| 53 | func (r *basePoolManager) handleEntityUpdate(entity params.ForgeEntity, operation common.OperationType) { |
| 54 | slog.DebugContext(r.ctx, "received entity operation", "entity", entity.ID, "operation", operation) |
| 55 | if r.entity.ID != entity.ID { |
| 56 | slog.WarnContext(r.ctx, "entity ID mismatch; stale event? refusing to update", "entity", entity.ID) |
| 57 | return |
| 58 | } |
| 59 | |
| 60 | if operation == common.DeleteOperation { |
| 61 | slog.InfoContext(r.ctx, "entity deleted; closing db consumer", "entity", entity.ID) |
| 62 | r.consumer.Close() |
| 63 | return |
| 64 | } |
| 65 | |
| 66 | if operation != common.UpdateOperation { |
| 67 | slog.DebugContext(r.ctx, "operation not update; ignoring", "entity", entity.ID, "operation", operation) |
| 68 | return |
| 69 | } |
| 70 | |
| 71 | credentialsUpdate := r.entity.Credentials.GetID() != entity.Credentials.GetID() |
| 72 | defer func() { |
| 73 | slog.DebugContext(r.ctx, "deferred tools update", "credentials_update", credentialsUpdate) |
| 74 | if !credentialsUpdate { |
| 75 | return |
| 76 | } |
| 77 | slog.DebugContext(r.ctx, "updating tools", "entity", entity.ID) |
| 78 | if err := r.updateTools(); err != nil { |
| 79 | slog.ErrorContext(r.ctx, "failed to update tools", "error", err) |
| 80 | } |
| 81 | }() |
| 82 | |
| 83 | slog.DebugContext(r.ctx, "updating entity", "entity", entity.ID) |
| 84 | r.mux.Lock() |
| 85 | slog.DebugContext(r.ctx, "lock acquired", "entity", entity.ID) |
| 86 | |
| 87 | r.entity = entity |
| 88 | if credentialsUpdate { |
| 89 | if r.consumer != nil { |
| 90 | filters := composeWatcherFilters(r.entity) |
| 91 | r.consumer.SetFilters(filters) |
| 92 | } |
| 93 | slog.DebugContext(r.ctx, "credentials update", "entity", entity.ID) |
| 94 | r.ghcli = r.getClientOrStub() |
| 95 | } |
| 96 | r.mux.Unlock() |
| 97 | slog.DebugContext(r.ctx, "lock released", "entity", entity.ID) |
| 98 | } |
| 99 | |
| 100 | func (r *basePoolManager) handleCredentialsUpdate(credentials params.ForgeCredentials) { |
| 101 | // when we switch credentials on an entity (like from one app to another or from an app |
no test coverage detected