Giter VIP home page Giter VIP logo

predis-async's People

Contributors

igorw avatar nrk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

predis-async's Issues

First published message in channel after reconnect is lost

Below exampel script. Run it and than publish messages to "queue:0:cmd":
publish queue:0:cmd test
publish queue:0:cmd quit
publish queue:0:cmd test
publish queue:0:cmd quit
You will see response from monitor:
$php ./test
Connected to Redis, now listening for incoming messages cmd...
Received message test from channel queue:0:cmd [type: message].
Received message quit from channel queue:0:cmd [type: message].
Connected to Redis, now listening for incoming messages cmd...
Received message quit from channel queue:0:cmd [type: message].

As you can see second "test" message is lost. In same time "redis-cli" points that all messages were delivered:

127.0.0.1:6379> publish queue:0:cmd test
(integer) 1
127.0.0.1:6379> publish queue:0:cmd quit
(integer) 1
127.0.0.1:6379> publish queue:0:cmd test
(integer) 1
127.0.0.1:6379> publish queue:0:cmd quit
(integer) 1

"libvent" lib is used for event loop.

require __DIR__ . '/vendor/autoload.php';


$loop = \React\EventLoop\Factory::create();

$client = new Predis\Async\Client('tcp://127.0.0.1:6379', $loop);

$client->connect(function ($client) {
    echo "Connected to Redis, now listening for incoming messages cmd...\n";

    $client->pubSubLoop('queue:0:cmd', function ($event, $pubsub) {
        $message = "Received message `%s` from channel `%s` [type: %s].\n";

        $feedback = sprintf($message,
            $event->payload,
            $event->channel,
            $event->kind
        );

        echo $feedback;

        if ($event->payload === 'quit') {
            $pubsub->quit();
        }
    });
});


$loop->run();

$client->connect(function ($client) {
    echo "Connected to Redis, now listening for incoming messages cmd...\n";

    $client->pubSubLoop('queue:0:cmd', function ($event, $pubsub) {
        $message = "Received message `%s` from channel `%s` [type: %s].\n";

        $feedback = sprintf($message,
            $event->payload,
            $event->channel,
            $event->kind
        );

        echo $feedback;

        if ($event->payload === 'quit') {
            $pubsub->quit();
        }
    });
});


$loop->run();

Uncaught Error: Call to undefined method React\EventLoop\Timer\Timer::setData()

Hi Team,

I am using this plugin into my project.

I am getting the following error in my project logs...Can someone plz help on this

My s/w specification:

Php 7.0
"predis/predis": "1.1.1",
"predis/predis-async": "dev-master"

PHP Fatal error: Uncaught Error: Call to undefined method React\EventLoop\Timer\Timer::setData() in /var/www/html/vendor/predis/predis-async/src/Connection/AbstractConnection.php:179
Stack trace:
#0 /var/www/html/vendor/predis/predis-async/src/Connection/AbstractConnection.php(158): Predis\Async\Connection\AbstractConnection->armTimeoutMonitor(5, Object(Closure))
#1 /var/www/html/vendor/predis/predis-async/src/Connection/AbstractConnection.php(209): Predis\Async\Connection\AbstractConnection->createResource(Object(Closure))
#2 /var/www/html/vendor/predis/predis-async/src/Client.php(178): Predis\Async\Connection\AbstractConnection->connect(Object(Closure))
#3 /var/www/html/commands/Queue/QueueConnector.php(86): Predis\Async\Client->connect(Object(Closure))
#4 /var/www/html/commands/Queue/QueueConnector.php(43): CLI\Queue\QueueConnector->createRedisClient(Object(CLI\Configuration\Configuration), Object(CLI\Handler\s3UploadHandler))
#5 /var/www/html/commands/Jobs/S3Upload.php(13): CLI\Queue\QueueConnector->__construct(Object(CLI in /var/www/html/vendor/predis/predis-async/src/Connection/AbstractConnection.php on line 179

Thanks in advance

Call to undefined function Predis\Async\Connection\phpiredis_reader_create()

Hello, i got this error

PHP Fatal error:  Uncaught Error: Call to undefined function Predis\Async\Connection\phpiredis_reader_create() in /home/mark/test-task/room/src/backend/websocket/vendor/predis/predis-async/lib/Predis/Async/Connection/StreamConnection.php:75 

this is composer.json

  "require": {
        "cboden/ratchet": "^0.4.1",
        "react/socket": "^1.1.0",
        "predis/predis": "^0.8",
        "predis/predis-async": "^0.2.3",
        "clue/redis-react": "^2.2"
    }

PubSubLoop, stops after redis is restared

  • if I restart redis via CLI, then Predis\Async\Client::pubSubLoop() stops with listening

I'm wondering is there a way of 're-invoke pubSubLoop()', without re-runing the script

EDIT: got it
if !redis-async->isConnected()
redis-async->connect(function() { redis-async->pubSubLoop(['psubscribe'=>'*'], function() {....}) })

Release predis-async on react 0.4.* as stable

Could you tag current master as next stable version? I'm working on a project using react 0.4 and predis-async and I wouldn't like to maintain dependencies on dev versions.

btw Thank you for Predis, it's a great library!

Using predis-async from within React Http Server

CPU spikes to 100% regardless of the event loop backend I use and feed to Predis\Async\Connection\StreamConnection.
Can't seem to pinpoint the issue, but it seems to have creeped up when I moved to my new server (php 5.4, new linux kernel - lots of variables in the equation).

CPU only spikes after a command is issued to redis.
I'm going to keep trying to track down exactly what is causing this in my free time, I just wanted to let you know.

To recreate:

  • Create a React\Http\Server using the example in the React repo.
  • Instantiate a redis connection using predis-async manually and feed it the same event loop instance you used to create your React\Http\Server.
  • in http->on('request') - issue a simple command to $redis via your manual connection using predis-async. The http response doesn't need to contain any redis related results, but be sure to respond/end the http request.
  • start the react HTTP server and issue a GET request via your browser to the running server. Your cpu should now be at 100% on one core.

How can I run a blPop in a continuous loop?

I've got the blocking list pop example working from the repo, however, I'm unable to get the blpop working in a continuous loop.

$connection = "tcp://localhost:6379";
$consumer = new \Predis\Async\Client( $connection )
$consumer->connect(
    function ( $consumer ) {
        echo "Connected to Redis, blpop'ing on queue:*\n";
        $consumer->blpop(
            'queue:normal',
            0,
            function ( $response ) use ( $consumer ) {
                list( $priority, $job ) = $response;

                if ( $priority ):
                    $message = "`%s` from channel `%s`.\n";
                    $feedback = sprintf( $message, $job, $priority );
                    echo $feedback;
                endif;

                return TRUE;
            });
    });
$consumer->getEventLoop()->run();

When I run this code with items in the queue, it will process the first one but then halt and hang in the terminal. Is there a way to have this blpop continuously block and then pop an item when it finds one?

Consumer unsubscribe triggers Catchable fatal error

<?php
require __DIR__ . '/vendor/autoload.php';
ini_set('display_errors', 'on');
error_reporting(E_ALL);
function pubsub($message, $client)
{
}
$loop = \React\EventLoop\Factory::create();
$client = new Predis\Async\Client('tcp://127.0.0.1:6379', $loop);
$consumer = $this->redis->pubSubLoop('test', 'pubsub');
$consumer->unsubscribe('test');

This code triggers catchable fatal error on PHP 5.6:

PHP Catchable fatal error:  Argument 2 passed to Predis\Async\Client::pubSubLoop() must be callable, null given, called in redis_test.php on line 10 and defined in /media/sf_share/nevesta.info/vendor/predis/predis-async/src/Client.php on line 307

Install via composer

I'm trying to install it via composer but i requires ext-phpiredis. Is there a way to force it without phpiredis?

predis-async with lists

Is it possible to use predis-async as a listener to a list in Redis?
When ever there is an item in a list, pop it and run a callback and if there is not an item wait for an item.
I want to use a list as buffer.

Memory leak $commands on AbstractConnection | PhpiredisStreamConnection

Hello,

i got a deamon in php who do many thousand sub/unsub redis channel.
After few hours i use 1Go ram.
I found [commands:protected] => SplQueue Object become more and more larger, maybe all sub/unsub is save inside without clean it ?

"$commands" from class Predis\Async\Connection\PhpiredisStreamConnection

Question about use of async_connect with Predis-Async

I wasn't sure where to ask this so I picked here.

I'm testing out using Redis to collect my user analytics events for realtime viewing. While it is being developed I want the transaction to have minimal impact on page load (ideally none) and to give up very quickly if the Redis server isn't responding.

At first I was (incorrectly) doing $client->connect proceeded immediately by

try{
    $client->getEventLoop()->run();
} catch

It is now my understanding that the idea of the eventLoop is to set those commands up and then run the event loop later, like via AJAX after the page loads (right?).

If you need more background information let me know.

Here's my issue. I can't figure out what, if anything, setting async_connect to true does. I'm just generally confused. Is user-facing performance/responsiveness not the goal of asynchronous PHP like it is with asynchronous javascript? What approach should I use to unobtrusively write to Redis?

Display what worker ran a scheduled job when we get a failure

When I go to this URL resource /resque/failed/list I can see some failed jobs. However my Redis has more than 1 worker and I am not sure what is the server that has managed that scheduled job, so I cannot investigate (easily) why the scheduled job has failed because I cannot see the worker that managed the job. Can you add a new column on that list please?

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.