a8n: Implement cancelCampaignPlan GraphQL mutation
Created by: mrnugget
This is a follow-up to RFC 42.
Currently the previewCampaignPlan mutation can run indefinitely (when wait = false in arguments, with wait = true the request timeout cancels the context.Contexts).
We need a cancelCampaignPlan mutation that
- takes in a
CampaignPlan.ID - cancels the
CampaignPlanso that no newCampaignJobsare executed
We probably want to extend the BackgroundProcessState with a CANCELLED state so that clients know when a CampaignPlan has finished execution or when it's been cancelled.
Thoughts on implementation
- Add a
CancelledAtfield toCampaignPlan, null by default - In the
cancelCampaignPlanmutation (see the stub here) we populate the field in a transaction -
At the beginning of
(&Runner).runJobwe query the database to check whether theCampaignPlanhas been cancelled. If so, we do an early return. - (Do we need to set an
Erroron theCampaignJobif theCampaignPlanhas been cancelled? I don't think so)