Kinesis stream processing
To handle Kinesis events , extend the KinesisHandler class:
use Bref\Context\Context;
use Bref\Event\Kinesis\KinesisEvent;
use Bref\Event\Kinesis\KinesisHandler;
class MyHandler extends KinesisHandler
{
public function handleKinesis(KinesisEvent $event, Context $context): void
{
foreach ($event->getRecords() as $record) {
$data = $record->getData();
// do something
}
}
}getData() decodes the record data as JSON and throws a JsonException if the data is not JSON. For other formats, use base64_decode($record->getRawData()).
Then, create a Lambda function that listens to the Kinesis stream with the handler you created:
Laravel
serverless.yml
functions:
# ...
worker:
handler: App\MyHandler
runtime: php-84
events:
- stream:
type: kinesis
arn: arn:aws:kinesis:eu-west-1:111111111111:stream/my-streamThe App\MyHandler class will be instantiated by Laravel’s service container.
The stream event does not create the Kinesis stream. Learn more about using Kinesis in serverless.yml in the Serverless Framework documentation .
Last updated on