public function __construct(Queue\Client $queue, $data) { $store = $queue->getStore()->getMessagesStore(); $this->promisesStore = $queue->getStore()->getPromisesStore(); $promise = new PromiseClient($this->promisesStore); $data = is_null($data) ? [Store::QUEUE_ID => $queue->getId(), Store::PROMISE => $promise->getId()] : is_array($data) ? array_merge($data, [Store::QUEUE_ID => $queue->getId(), Store::PROMISE => $promise->getId()]) : $data; parent::__construct($store, $data); $this->queue = $queue; }
public function interrupt($value, PromiseClient $promise, callable $callback) { $url = static::DEFAULT_URL; $promiseId = $promise->getId(); $arrayData = compact('callback', 'value', 'promiseId'); $serializedData = serialize($arrayData); $data64 = base64_encode($serializedData); return $this->async_http_post($url, $data64); }
public function interrupt($value, PromiseClient $promise, callable $callback) { if (is_null($this->script)) { $this->setScriptName(self::DEFAULT_SCRIPT_NAME); } // Files names for stdout and stderr $stdOutFilename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('stdout_', 1); $stdErrFilename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('stderr_', 1); $cmd = $this->commandPrefix . ' ' . $this->script; $promiseId = $promise->getId(); $arrayData = compact('callback', 'value', 'promiseId'); $serializedData = serialize($arrayData); $data64 = base64_encode($serializedData); $cmd .= ' ' . $data64; $cmd .= " 1>{$stdOutFilename} 2>{$stdErrFilename}"; shell_exec($cmd); return $promise; }
/** * * Location: http://www.example.com/users/4/ * http://www.restapitutorial.com/lessons/httpmethods.html * * @param ServerRequestInterface $request * @param ResponseInterface $response * @return ResponseInterface * @throws \zaboy\rest\RestException * @internal param callable|null $next */ public function methodPostWithoutId(ServerRequestInterface $request, ResponseInterface $response) { $promise = new Client($this->store); $responseBody = $promise->toArray(); $this->request = $request->withAttribute('Response-Body', $responseBody); $response = $response->withStatus(201); $insertedPrimaryKeyValue = $promise->getId(); $location = $request->getUri()->getPath(); $response = $response->withHeader('Location', rtrim($location, '/') . '/' . $insertedPrimaryKeyValue); return $response; }