public function invoke(string $functionName, $event = null): InvocationResult
    {
        $rawResult = $this->lambda->invoke([
            'FunctionName' => $functionName,
            'LogType' => 'Tail',
            'Payload' => $event ?? '',
        ]);

        /** @var StreamInterface $resultPayload */
        $resultPayload = $rawResult->get('Payload');
        $resultPayload = json_decode($resultPayload->getContents(), true);

        $invocationResult = new InvocationResult($rawResult, $resultPayload);

        $error = $rawResult->get('FunctionError');
        if ($error) {
            throw new InvocationFailed($invocationResult);
        }

        return $invocationResult;
    }