Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(publisher): fix redis command usage (#184)
This pull request introduces Redis integration into the `publisher` service, refactoring the code to accommodate the new Redis client and updating the handling of Redis commands. The most important changes include adding the Redis client configuration, modifying the `Publisher` and `Service` structs, and updating Redis command methods. ### Redis Integration: * [`publisher/cmd/worker/main.go`](diffhunk://#diff-0c11d49a84dbe2803f3a531ba845598d4d2c9f4be0b64f1f2ff347d8e9afcb45R14): Added Redis client configuration and passed the Redis client to the `tiup.NewPublisher` function. [[1]](diffhunk://#diff-0c11d49a84dbe2803f3a531ba845598d4d2c9f4be0b64f1f2ff347d8e9afcb45R14) [[2]](diffhunk://#diff-0c11d49a84dbe2803f3a531ba845598d4d2c9f4be0b64f1f2ff347d8e9afcb45R52-R65) ### Struct Modifications: * [`publisher/pkg/config/config.go`](diffhunk://#diff-41ecac7d460be2b3759c4d88b60e7177542db7888ba0c8254f8eab123a17b64bR8-L20): Added a `Redis` struct to hold Redis configuration and updated the `Worker` and `Service` structs to include this new `Redis` field. ### Redis Command Updates: * [`publisher/pkg/impl/tiup/publisher.go`](diffhunk://#diff-620e3293cf87ba54e2ed9269601e334343caa82c36ecd1371d17fa71ce8393c5L22-R26): Changed the `redisClient` type from `*redis.Client` to `redis.Cmdable` and updated Redis command methods to use `SetXX` instead of `Set`. [[1]](diffhunk://#diff-620e3293cf87ba54e2ed9269601e334343caa82c36ecd1371d17fa71ce8393c5L22-R26) [[2]](diffhunk://#diff-620e3293cf87ba54e2ed9269601e334343caa82c36ecd1371d17fa71ce8393c5L45-R45) [[3]](diffhunk://#diff-620e3293cf87ba54e2ed9269601e334343caa82c36ecd1371d17fa71ce8393c5L55-R57) * [`publisher/pkg/impl/tiup/service.go`](diffhunk://#diff-df9108e5a06158c0822dfd658fdfcbf5fa1ca7bcde2884ecaa32a0d79bf515faL22-R28): Updated the `redisClient` type and changed the Redis command method from `SetXX` to `SetNX` for initial status setting. [[1]](diffhunk://#diff-df9108e5a06158c0822dfd658fdfcbf5fa1ca7bcde2884ecaa32a0d79bf515faL22-R28) [[2]](diffhunk://#diff-df9108e5a06158c0822dfd658fdfcbf5fa1ca7bcde2884ecaa32a0d79bf515faL77-R77) Signed-off-by: wuhuizuo <[email protected]> --------- Signed-off-by: wuhuizuo <[email protected]>
- Loading branch information