serviceContext.go 430 B

123456789101112131415161718192021222324
  1. package svc
  2. import (
  3. "GtDataStore/app/cmd/events/internal/config"
  4. "github.com/go-redis/redis/v8"
  5. )
  6. type ServiceContext struct {
  7. Config config.Config
  8. Cache *redis.Client
  9. modelList
  10. }
  11. func NewServiceContext(c config.Config) *ServiceContext {
  12. svc := &ServiceContext{
  13. Config: c,
  14. Cache: redis.NewClient(&redis.Options{Addr: c.Cache[0].Host, Password: c.Cache[0].Pass, MaxRetries: 5}),
  15. }
  16. initModel(svc)
  17. return svc
  18. }