-
-
Notifications
You must be signed in to change notification settings - Fork 294
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
Is type hint of push method inappropriate? It seems to conflict with handleMessage #252
Comments
As far as I see there is no point in passing anything else than a |
This is for interoperability - I can push job in Yii and consume it with second script written in Python. Obviously I cannot rely on PHP types then, so I can push job as JSON - both Yii and Python script will be able to understand this job, in contrast to the serialized PHP object. And you can handle such Job in |
So, One of the correct ways to use it may be these steps:
step 1: Writing a Job implement JobInterface, and ths job class include step 2: Writing a serializer function which extracting data from Job class and coverting data to a specified format, and this format can be understanded by other Cross-language consumer.
step 1: Usually we use step 2: When received message, use defined unserializer function to converting data to Job class. step 3: Job class will be passed to This looks like that So removing Of course, we can use anthoer design. typehint of All of above just is my opinion. |
I learned that type of
$job
inyii\queue\Queue::push($job)
can be mixed exceptJobInterface
instance. That meaings I can pass any type of parameter like string,array or object to this method.In order to coverting
$job
to$message
, I have to setyii\queue\Queue::$strictJobType
tofalse
for avoiding throwing exceptions.The problem is coming, Why can't I handle receiving message in
yii\queue\Queue::handleMessage
, this method require message deserialized to be instance of JobInterface. Is this not againstpush
method that allow passing type of non-JobInterface?Do I need to implement class extend
yii\queue\cli\Queue
and overridehandleMessage
? No need to do this, I‘m not going to develop new driver. I just use yii-queue according to the type hint ofpush
mehod.The text was updated successfully, but these errors were encountered: