Skip to content

Latest commit

 

History

History
60 lines (40 loc) · 2.36 KB

Ref_AffixAdapter_class.md

File metadata and controls

60 lines (40 loc) · 2.36 KB

AffixAdapter Wrapper Class

Declaration: interface mle86\WQ\WorkServerAdapter\AffixAdapter implements WorkServerAdapter
Source file: src/WQ/WorkServerAdapter/WorkServerAdapter.php

This adapter serves to manipulate the work queue names used by another WorkServerAdapter.

It might be useful if your application prefixes all of its work queues with the app name or appends the environment name to all work queue names.

In such a case, you can use the setPrefix/setSuffix methods to specify the site-wide prefix/suffix. All other methods of this class are just proxy methods to the "real" instance's methods which prepend/append something to the work queue name(s).

Example

Instead of $workServer->getNextQueueEntry("myapp-email-PROD"),

you could wrap the existing WorkServerAdapter instance in an AffixAdapter...
$workServer = (new AffixAdapter($workServer))->withPrefix("myapp-")->withSuffix("-" . ENVIRONMENT);,

then use it with a simpler call:
$workServer->getNextQueueEntry("email").

Methods

  • public function __construct (WorkServerAdapter $server)
    Instantiates a new AffixAdapter.

    • $server: The actual WorkServerAdapter to wrap.
  • public function withPrefix (?string $prefix): self
    Sets the prefix to prepend to all work queue names.
    (The empty string has the same effect as null.)

  • public function withSuffix (?string $suffix): self
    Sets the suffix to append to all work queue names.
    (The empty string has the same effect as null.)

Proxy Methods

  • public function getNextQueueEntry ($workQueue, int $timeout = DEFAULT_TIMEOUT): ?QueueEntry
  • public function storeJob (string $workQueue, Job $job, int $delay = 0)
  • public function buryEntry (QueueEntry $entry)
  • public function requeueEntry (QueueEntry $entry, int $delay, string $workQueue = null)
  • public function deleteEntry (QueueEntry $entry)

These proxy methods for the wrapped instance's methods modify any work queue names according to the withPrefix/withSuffix settings.