DeleteHook removes a webhook from Redis. It retrieves the hook to determine its type, then deletes it from both the main registry and the type-specific set using a transaction. Parameters: - ctx: The context for the operation. - hookID: The ID of the hook to delete. Returns: - error: An error if t
(ctx context.Context, hookID string)
| 161 | // Returns: |
| 162 | // - error: An error if the deletion fails. |
| 163 | func (m *redisHookManager) DeleteHook(ctx context.Context, hookID string) error { |
| 164 | hook, err := m.GetHook(ctx, hookID) |
| 165 | if err != nil { |
| 166 | return err |
| 167 | } |
| 168 | |
| 169 | key := fmt.Sprintf("%s:%s", hookKeyPrefix, hookID) |
| 170 | typeKey := getTypeKey(hook.Type) |
| 171 | |
| 172 | // Use pipeline for atomic operations |
| 173 | pipe := m.client.Pipeline() |
| 174 | pipe.Del(ctx, key) |
| 175 | pipe.SRem(ctx, typeKey, hookID) |
| 176 | _, err = pipe.Exec(ctx) |
| 177 | return err |
| 178 | } |
| 179 | |
| 180 | // GetHook retrieves a webhook by its ID. |
| 181 | // It fetches the hook data from Redis and unmarshals it into a Hook struct. |
nothing calls this directly
no test coverage detected