servicecontext.go 414 B

123456789101112131415161718192021
  1. package svc
  2. import (
  3. "github.com/zeromicro/go-zero/core/stores/redis"
  4. "ylink/apis/auth/internal/config"
  5. )
  6. type ServiceContext struct {
  7. Config config.Config
  8. RedisClient *redis.Redis
  9. }
  10. func NewServiceContext(c config.Config) *ServiceContext {
  11. return &ServiceContext{
  12. Config: c,
  13. RedisClient: redis.New(c.Redis.Host, func(r *redis.Redis) {
  14. r.Type = c.Redis.Type
  15. r.Pass = c.Redis.Pass
  16. }),
  17. }
  18. }