Giter Club home page Giter Club logo

arangodb-php-driver's Introduction

About me

Zend Certified PHP Engineer Zend Framework 2 Certified Architect

I'm a Senior Software Developer and IT-Consultant and have more than 15 years experience in web development as Full Stack Developer. I attended three conferences as a speaker in the past and maintain several open source PHP packages. On my blog I write about topics, advices and trends of web development.

LinkedIn Twitter Xing Zend Certificates

๐Ÿ”ง Technologies & Tools

๐Ÿ“ˆ GitHub Stats

Sandro's GitHub Stats

arangodb-php-driver's People

Contributors

martin-schilling avatar sandrokeil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

arangodb-php-driver's Issues

Check transaction response with velocypack

We should find a possibility to replace the Type inspectors with working directly on velocypack data for faster checks. This is especially needed for lager transactions/responses.

Succesful response

{
    "code": 200,
    "error": false,
    "result": {
        "rId0": [
            {
                "_id": "c878c0b7e51ecaab95c511fc816ad2a70c9418208/100000000000000001",
                "_key": "100000000000000001",
                "_rev": "_WAf0iN----"
            },
            {
                "_id": "c878c0b7e51ecaab95c511fc816ad2a70c9418208/100000000000000002",
                "_key": "100000000000000002",
                "_rev": "_WAf0iN---_"
            }
        ]
    }
}

Error response single type

Attention: Root error key is false, but individual result has "error": true,.

{
    "code": 200,
    "error": false,
    "result": {
        "rId0": [
            {
                "_id": "c878c0b7e51ecaab95c511fc816ad2a70c9418208/100000000000000001",
                "_key": "100000000000000001",
                "_rev": "_WAg_9aK---"
            },
            {
                "_id": "c878c0b7e51ecaab95c511fc816ad2a70c9418208/100000000000000002",
                "_key": "100000000000000002",
                "_rev": "_WAg_9aK--_"
            },
            {
                "error": true,
                "errorMessage": "unique constraint violated - in index 0 of type primary over [\"_key\"]",
                "errorNum": 1210
            }
        ]
    }
}

Error response multiple types

Attention: Root error key is false, but individual result has "error": true,.

{
    "code": 200,
    "error": false,
    "result": {
        "rId0": [
            {
                "_id": "c878c0b7e51ecaab95c511fc816ad2a70c9418208/100000000000000001",
                "_key": "100000000000000001",
                "_rev": "_WAgC_wq---"
            },
            {
                "_id": "c878c0b7e51ecaab95c511fc816ad2a70c9418208/100000000000000002",
                "_key": "100000000000000002",
                "_rev": "_WAgC_wq--_"
            }
        ],
        "rId1": [
            {
                "error": true,
                "errorMessage": "unique constraint violated - in index 0 of type primary over [\"_key\"]",
                "errorNum": 1210
            },
            {
                "error": true,
                "errorMessage": "unique constraint violated - in index 0 of type primary over [\"_key\"]",
                "errorNum": 1210
            }
        ]
    }
}

I would suggest to only find the first error object and transform it to an exception. A method to get all errors would be nice too. The error object under result has the following structure:

{
    "error": true,
    "errorMessage": "unique constraint violated - in index 0 of type primary over [\"_key\"]",
    "errorNum": 1210
}

Would be nice if there is a faster lookup instead of iterating through each result.

[ZendEngine Driver] Fix constructor/desctructor calls

Since objects are created through PHPs ecalloc() which internally uses malloc() the constructors are not called. This can be fixed through the usage of a placement new which should be added to all objects relying on a constructor. The same applies for the desctructors which means that more custom object handlers must be implemented and the desctructor has to be called manually (eg intern->~Connection())

Cursor / Statement implementation

We need a cursor / statement API implementation to iterate over results. See also ArangoDb blog post.

Full example can be found here.

        $statement = new Statement(
            $this->connection, [
                Statement::ENTRY_QUERY => str_replace('%filter%', $filter, $aql),
                Statement::ENTRY_BINDVARS => array_merge(
                    [
                        '@collection' => $this->eventStreamsCollection,
                        'offset' => $offset,
                        'limit' => $limit,
                    ],
                    $values
                ),
                Cursor::ENTRY_FLAT => true,
            ]
        );
        $streamNames = [];
        foreach ($statement->execute() as $streamName) {
            $streamNames[] = new StreamName($streamName['real_stream_name']);
        }
        return $streamNames;

@martin-schilling We have to shape the API for these classes. Your thoughts?

Create classes to handle a connection and to send data

First, we need a connection class. The ArangoDBClient/Connection.php is a good blueprint, but we have to use the fuerte style / features.

Requirements

  • Handling of different databases, maybe one connection for every database
  • Async handling of different requests, use callable ?
  • Request / Response classes
  • Connection option class / constants

Questions

Add Travis tests

The driver should be tested for different Linux and PHP versions.

  • PHP >= 7.1
  • Debian / Ubuntu / Alpine

[ZendEngine Driver] Memory leaks

The new implementation based on the Zend engine probably contains a bunch of memory leaks. We have to find and fix them appropriately.

How to write a wrapper

We should start with a wrapper for a simple class of fuerte/veloycpack to see how things work. The Yothalot-PHP extension could be a blueprint for this.

[ZendEngine Driver] Efficient returning of variables

In some occasions it might be worth performance wise to not write classic getters like Response::get_body() and return that to PHP using RETURN_STRING but to write a return function Response::return_body(zval* return_value) instead. In this case this would save passing around a std::string (or additional changes to enable return by reference / smart_ptr). This is a little bit ugly though so smart_ptrs might actually be a better solution. One way or another we should find a good solution for this and use it constantly throughout the codebase.

Velocypack example symbol not found

In the current simple test implementation I got the error.

php: symbol lookup error: /usr/lib/php/20160303/arangodb.so: undefined symbol: _ZN8arangodb10velocypack13valueTypeNameENS0_9ValueTypeE

Velocypack example builder recompile with -fPIC

After #3 was resolved, new error occurred.

/usr/bin/ld: //usr/local/lib/libvelocypack.a(Builder.cpp.o): relocation R_X86_64_TPOFF32 against `_ZGVZN8arangodb10velocypack7Builder19sortObjectIndexLongEPhRSt6vectorImSaImEEE7entries' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: //usr/local/lib/libvelocypack.a(Slice.cpp.o): relocation R_X86_64_PC32 against symbol `_ZN8arangodb10velocypack15SliceStaticData7TypeMapE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Makefile:132: recipe for target 'arangodb.so' failed
make: *** [arangodb.so] Error 1

How to resolve this?

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.