(ctx context.Context, pid string, uuid string)
| 141 | } |
| 142 | |
| 143 | func (i *imlSubscribeModule) RevokeSubscription(ctx context.Context, pid string, uuid string) error { |
| 144 | _, err := i.serviceService.Get(ctx, pid) |
| 145 | if err != nil { |
| 146 | return fmt.Errorf("get service error: %w", err) |
| 147 | } |
| 148 | subscription, err := i.subscribeService.Get(ctx, uuid) |
| 149 | if err != nil { |
| 150 | return err |
| 151 | } |
| 152 | if subscription.ApplyStatus != subscribe.ApplyStatusSubscribe { |
| 153 | return fmt.Errorf("subscription can not be revoked") |
| 154 | } |
| 155 | |
| 156 | clusters, err := i.clusterService.List(ctx) |
| 157 | if err != nil { |
| 158 | return err |
| 159 | } |
| 160 | applyStatus := subscribe.ApplyStatusUnsubscribe |
| 161 | return i.transaction.Transaction(ctx, func(ctx context.Context) error { |
| 162 | err = i.subscribeService.Save(ctx, uuid, &subscribe.UpdateSubscribe{ |
| 163 | ApplyStatus: &applyStatus, |
| 164 | }) |
| 165 | if err != nil { |
| 166 | return err |
| 167 | } |
| 168 | for _, c := range clusters { |
| 169 | err = i.offlineForCluster(ctx, c.Uuid, &gateway.SubscribeRelease{ |
| 170 | Service: subscription.Service, |
| 171 | Application: subscription.Application, |
| 172 | }) |
| 173 | if err != nil { |
| 174 | return err |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | return nil |
| 179 | }) |
| 180 | |
| 181 | } |
| 182 | |
| 183 | func (i *imlSubscribeModule) DeleteSubscription(ctx context.Context, pid string, uuid string) error { |
| 184 | _, err := i.serviceService.Get(ctx, pid) |
nothing calls this directly
no test coverage detected