zf-fr / zfr-eb-worker

ZfrEbWorker is a thin layer to simplify the usage of SQS queues and Elastic Beanstalk environments
MIT License
8 stars 2 forks source link

Separating the routing mechanism into a separate middleware #59

Closed benomite closed 6 years ago

benomite commented 6 years ago

Separating the routing mechanism into a separate middleware, so that you can pipe middlewares in between that handles these edge cases:

// Validates worker request and extracts message attributes
$pipeline->pipe(WorkerMiddleware::class); 

// Here you can optionally pipe additional middlewares in between, for instance:
$pipeline->pipe(IdentifyAwsInternalEventsMiddleware::class);

// Routes to a specific handler based on message name
$pipeline->pipe(MessageRouterMiddleware::class);
benomite commented 6 years ago

I haven't thought about back compatibility -__-' I'll work on your suggestions, it's a good idea.

benomite commented 6 years ago

I'm struggling here. Do you have an idea on how to properly pipe the 2 new middlewares (WorkerMessageAttributesMiddleware and MessageRouterMiddleware) within the call of WorkerMiddleware ?

danizord commented 6 years ago

@benomite you can require https://github.com/zendframework/zend-stratigility and use it internally for now. In next major release (probably when PSR-15 gets approved) we'll drop it :)

benomite commented 6 years ago

@danizord zend-stratigility require a version of http-interop/http-middleware to be required in composer.json. I've drop this, user may choose the version they are compatible with (0.5.0 or 0.4.3). This may be a bad practice, what do you think?

benomite commented 6 years ago

Hi! Any updates on this? Thanks!

danizord commented 6 years ago

Thanks @benomite and @wysow! I'm gonna prepare a new release this week :)