| 18 | const KeySubscribeService = "subscription_service" |
| 19 | |
| 20 | func (s *SubscribeClient) Online(ctx context.Context, resources ...*gateway.SubscribeRelease) error { |
| 21 | s.client.Begin(ctx) |
| 22 | var err error |
| 23 | for _, r := range resources { |
| 24 | err = s.client.HSet(ctx, fmt.Sprintf("%s:%s", KeySubscribeService, r.Application), r.Service, r.Expired) |
| 25 | if err != nil { |
| 26 | s.client.Rollback(ctx) |
| 27 | return err |
| 28 | } |
| 29 | } |
| 30 | return s.client.Commit(ctx) |
| 31 | } |
| 32 | |
| 33 | func (s *SubscribeClient) Offline(ctx context.Context, resources ...*gateway.SubscribeRelease) error { |
| 34 | s.client.Begin(ctx) |