GithubHelp home page GithubHelp logo

kusanagi / katana-sdk-php7 Goto Github PK

View Code? Open in Web Editor NEW
5.0 8.0 2.0 341 KB

PHP7 SDK for the KATANA Framework

Home Page: https://kusanagi.io

License: MIT License

PHP 100.00%
php php7 sdk framework katana kusanagi

katana-sdk-php7's People

Contributors

fcastilloes avatar nullproxy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

katana-sdk-php7's Issues

Request::newResponse() arguments should be optional

The Request::newResponse() method currently expects arguments, but the 2 arguments should be optional, falling back to 200 and "OK" respectively.

The following error is returned:

Callback error: Language error (shutdown) (1) Uncaught TypeError: Argument 1 passed to Katana\\Sdk\\Api\\RequestApi::newResponse() must be of the type integer, none given, called in /middleware.php on line 27 and defined in /vendor/kusanagi/katana-sdk-php7/src/Api/RequestApi.php

This was using version 1.1.4 of the framework, with system info below:

Linux work 4.2.0-42-generic #49~14.04.1-Ubuntu SMP Wed Jun 29 20:22:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

HttpRequest::getUrlPath() should return a string

When a path does not exist in the URL, the HttpRequest::getUrlPath() method should return an empty string, but it currently returns NULL.

This was using version 1.1.4 of the framework, with system info below:

Linux work 4.2.0-42-generic #49~14.04.1-Ubuntu SMP Wed Jun 29 20:22:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Catch msgpack Packing Exceptions

When an object gets into the msgpack encoder library, it throws an exception that is currently unhandled, leading to a fatal error.

2017-08-09T15:29:45.446Z [ERROR] [SDK] Callback error: Language error (shutdown) (1) Uncaught MessagePack\Exception\PackingFailedException: Unsupported type. in /vagrant/origami/middleware-collector/vendor/rybakit/msgpack/src/Packer.php:141

Catch and handle the exception.

Interrupted system call error

I encountered this error during testing locally with $ katana service action via CLI:

Callback error: Language error (shutdown) (1) Uncaught ZMQSocketException: Failed to get the option ZMQ::SOCKOPT_EVENTS value: Interrupted system call in /vendor/react/zmq/src/React/ZMQ/SocketWrapper.php:35
Stack trace:
#0 /vendor/react/zmq/src/React/ZMQ/SocketWrapper.php(35): ZMQSocket->getsockopt(15)
#1 [internal function]: React\ZMQ\SocketWrapper->handleEvent(Resource id #44, Object(React\EventLoop\StreamSelectLoop))
#2 /vendor/react/event-loop/src/StreamSelectLoop.php(236): call_user_func(Array, Resource id #44, Object(React\EventLoop\StreamSelectLoop))
#3 /vendor/react/event-loop/src/StreamSelectLoop.php(205): React\EventLoop\StreamSelectLoop->waitForStreamActivity(98379)
#4 /vendor/kusanagi/katana-sdk-php7/src/Executor/ZeroMqLoopExecutor.php(146): React\EventLoop\StreamSelectLoop->ru...

This happened randomly during various calls, with no change to the configuration or source code.

This was using version 1.1.12 of the framework, with system info below:

Linux work 4.2.0-42-generic #49~14.04.1-Ubuntu SMP Wed Jun 29 20:22:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Accept objects as entities

Currently, only associative arrays are allowed as valid entities. Objects must be accepted as well. For this, public properties must be mapped as the properties of the entity.

Creating an array parameter fails

When defining a parameter as an array using Request::newParam() I got an error stating that the data type must be a string, yet I'm defining an array in PHP.

In my case, I'm defining an array where each item is an array, for example:

$param = $request->newParam('params', [['a', 'b', 'c'], ['d', 'e', 'f']], 'array');

Here is the error message received:

Callback error: Language error (shutdown) (1) Uncaught TypeError: Argument 2 passed to Katana\Sdk\Api\ServiceCall::newParam() must be of the type string, array given, called in /vendor/kusanagi/katana-sdk-php7/src/Api/RequestApi.php on line 270 and defined in /vendor/kusanagi/katana-sdk-php7/src/Api/ParamAccessorTrait.php:74
Stack trace:
#0 /vendor/kusanagi/katana-sdk-php7/src/Api/RequestApi.php(270): Katana\Sdk\Api\ServiceCall->newParam('params', Array, 'array')
#1 /middleware.php(45): Katana\Sdk\Api\RequestApi->newParam('params', Array, 'array')
#2 /vendor/kusanagi/katana-sdk-php7/src/Executor/AbstractExecutor.php(77): {closure}(Object(Katana\Sdk\Api\RequestApi))
#3 /vendor/kusanagi/katana-sdk-php7/src/Executor/ZeroMqLoopExecutor.php(138): 

The issue appears to come from here:

https://github.com/kusanagi/katana-sdk-php7/blob/master/src/Api/ParamAccessorTrait.php#L76

This was using version 1.1.4 of the framework, with system info below:

Linux work 4.2.0-42-generic #49~14.04.1-Ubuntu SMP Wed Jun 29 20:22:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Implement tags in ActionSchema

Sample action received in katana 1.2.22 (removed everything not relevant):

{
  "ac": {
    "list": {
      "t": [
        "security:anonymous"
      ]
    }
  }
}

ZeroMQ socket unbind error on stop

Stopping a component causes the following SDK error:

PHP Fatal error:  Uncaught ZMQSocketException: Failed to unbind the ZMQ socket: No such file or directory in vendor/react/zmq/src/React/ZMQ/SocketWrapper.php:114

Logs break on binary data

When a value that contains content such as binary is provided as the output for a log, these are no longer visible in stdout.

Additionally, after that log, all other logs are affected, with no further output to stdout. This was used in a Middleware processing requests, and not even on subsequent requests were logs visible.

This was using version 1.1.5 of the framework, and version 1.1.8 of the SDK, with system info below:

Linux work 4.2.0-42-generic #49~14.04.1-Ubuntu SMP Wed Jun 29 20:22:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Capture error when file comes to a service without a token

Error appear when a file comes to the service with an http path but without a token.

[31-Oct-2017 12:44:49 UTC] PHP Fatal error:  Uncaught Katana\Sdk\Exception\InvalidValueException: Missing token for File: body in .../vendor/kusanagi/katana-sdk-php7/src/Api/File.php:96

Capture pack exceptions

Operatoins related with packing and unpacking messages are executed outside of the context of the main try/catch that controls user defined code.

But certain messages can produce exceptions that would crash a component. That exceptions must be captured and controlled.

Analyse encoding of arrays in msgpack

Msgpack supports both maps and arrays for lists of data. When a packing is done from php, a map could be created both with string or integer keys. An msgpack array is created when the php array has only integer keys that are sequential and starting from 0.

Katana has strong types and map keys must be strings, so any integer key in a map will result in error.

Some solution is needed to prevent those errors.

The library could have some options. https://github.com/rybakit/msgpack.php#type-detection-mode

Revise the control string generation in action responses

Currently, to activate the control bytes to send in an action response, it was checked if any calls, transactions, files or body exists in the transport. That is not entirely correct, because the check is that any of those has been added in that action.

So the solution should be a new ControlString object to assign to the Transport. If the action adds any of those controlled items, a flag should be set in the object. When the response is being prepared, a method ControlString->get() should be called to generate the actual string.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.