Skip to content

Commit

Permalink
Merge pull request #70 from fcastilloes/master
Browse files Browse the repository at this point in the history
Register runtime calls in the transport
  • Loading branch information
fcastilloes committed Sep 9, 2017
2 parents 8c166e5 + a55fb2f commit a05ae28
Show file tree
Hide file tree
Showing 15 changed files with 305 additions and 185 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
## Added
- Register runtime calls in the transport with duration
## Changed
- Refactor and test runtime-call mappers

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"react/react": "^0.4.2",
"react/zmq": "^0.3.0",
"mkraemer/react-pcntl": "^2.1",
"rybakit/msgpack": "^0.2.2"
"rybakit/msgpack": "^0.2.2",
"jandreasn/a-timer": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
Expand Down
46 changes: 45 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 19 additions & 16 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="./vendor/autoload.php"
cacheTokens="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.2/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="./vendor/autoload.php"
cacheTokens="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false">

<!-- Suites -->
<testsuites>
Expand Down
156 changes: 156 additions & 0 deletions src/Api/AbstractCall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?php
/**
* PHP 7 SDK for the KATANA(tm) Framework (http://katana.kusanagi.io)
* Copyright (c) 2016-2017 KUSANAGI S.L. All rights reserved.
*
* Distributed under the MIT license
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code
*
* @link https://github.com/kusanagi/katana-sdk-php7
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @copyright Copyright (c) 2016-2017 KUSANAGI S.L. (http://kusanagi.io)
*/

namespace Katana\Sdk\Api;

use Katana\Sdk\Api\Value\VersionString;

abstract class AbstractCall
{
/**
* @var ServiceOrigin
*/
protected $origin;

/**
* @var string
*/
protected $caller = '';

/**
* @var string
*/
protected $service = '';

/**
* @var VersionString
*/
protected $version;

/**
* @var string
*/
protected $action;

/**
* @var int
*/
protected $duration = 0;

/**
* @var Param[]
*/
protected $params = [];

/**
* @var File[]
*/
protected $files = [];

/**
* AbstractCall constructor.
* @param ServiceOrigin $origin
* @param string $caller
* @param string $service
* @param VersionString $version
* @param string $action
* @param int $duration
* @param Param[] $params
* @param File[] $files
*/
public function __construct(
ServiceOrigin $origin,
$caller,
$service,
VersionString $version,
$action,
int $duration,
array $params = [],
array $files = []
) {
$this->origin = $origin;
$this->caller = $caller;
$this->service = $service;
$this->version = $version;
$this->action = $action;
$this->duration = $duration;
$this->params = $params;
$this->files = $files;
}

/**
* @return ServiceOrigin
*/
public function getOrigin()
{
return $this->origin;
}

/**
* @return string
*/
public function getCaller()
{
return $this->caller;
}

/**
* @return string
*/
public function getService()
{
return $this->service;
}

/**
* @return string
*/
public function getVersion()
{
return $this->version->getVersion();
}

/**
* @return string
*/
public function getAction()
{
return $this->action;
}

/**
* @return int
*/
public function getDuration(): int
{
return $this->duration;
}

/**
* @return Param[]
*/
public function getParams()
{
return $this->params;
}

/**
* @return File[]
*/
public function getFiles()
{
return $this->files;
}
}
2 changes: 2 additions & 0 deletions src/Api/ActionApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ public function call(
);

return $this->caller->call(
$this->name,
$this->version,
$this->actionName,
new ActionTarget($service, new VersionString($version), $action),
$this->transportCopy,
Expand Down
Loading

0 comments on commit a05ae28

Please sign in to comment.