Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Civi::queue() - Add support for 'template' queues #23679

Merged
merged 3 commits into from
Jun 10, 2022

Conversation

totten
Copy link
Member

@totten totten commented Jun 3, 2022

Overview

Suppose you are in the habit of making separate queue-instances for different batches of work. However, you want to allow the sysadmin to configure options like type, batch_limit, and retry_interval.

Solution: Make a template

After

// Use the API to register a template, eg
\Civi\Api4\Queue::create()->setValues([
  'name' => 'my-example',
  'is_template' => TRUE,
  'type' => 'Sql',
  'error' => 'abort',
  'retry_limit' => 5,
  'retry_interval' => 60,
])->execute();

// Later, create a queue from the template
$q = Civi::queue('new-queue', ['template' => 'my-example']);
assert($q inherts the  'type', 'error', 'retry_limit', etc from the template)

Comments

I'm ambivalent about how to mark a template - eg:

  • Easier patch: Use status=>template
  • Match other entities: Use a new field is_template=>1

@civibot civibot bot added the master label Jun 3, 2022
@civibot
Copy link

civibot bot commented Jun 3, 2022

(Standard links)

@eileenmcnaughton
Copy link
Contributor

I think is_template is more correct - but there is precedent for the status method - we do that in Contribution - but in fact I think we do BOTH there because we felt that was an especially risky entity. I'm not opposed to the easy route - but suspect we might need to do another alter in which case that might tip it away from easer

totten added 2 commits June 9, 2022 16:14
Overview
--------

Suppose you are in the habit of making separate queue-instances for
different batches of work.  However, you want to allow the sysadmin to
configure options like `type`, `batch_limit`, and `retry_interval`.

Solution: Make a template

After
-----

```php
// Use the API to register a template, eg
\Civi\Api4\Queue::create()->setValues([
  'name' => 'template-name',
  'is_template' => TRUE,
  ...
])->execute();

// Later, create a queue from the template
$q = Civi::queue('new-queue', ['template' => 'template-name']);
```
@totten totten force-pushed the master-queue-tpl-inclusive branch from f284033 to b656ba0 Compare June 9, 2022 23:19
@totten
Copy link
Member Author

totten commented Jun 9, 2022

@eileenmcnaughton Converted patch from status=>template to is_template=>1. Rebased. Updated description.

Eileen requested, and it's easiest to add now, and it seems safe+consistent.
@eileenmcnaughton
Copy link
Contributor

test this please

1 similar comment
@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton
Copy link
Contributor

fail is unrelated - fix is in #23751

@eileenmcnaughton eileenmcnaughton merged commit bc38b6d into civicrm:master Jun 10, 2022
@totten totten deleted the master-queue-tpl-inclusive branch June 14, 2022 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants