Giter Site home page Giter Site logo

Comments (4)

alphazero avatar alphazero commented on June 24, 2024

Hi, not sure about this. As you noted, a simple wrapper is basically what is required and its not clear what the service would 'provide' if your server is down. Should it continually try and finally get a connection? In effect, the end result is that you will get an exception when you try to ask the service to do something.

from jredis.

alphazero avatar alphazero commented on June 24, 2024

"I can not start my web application and initialize a client class for singleton usage at startup when the server is not available."

Sorry, I missed this. Let me think about it. Thanks for pointing out the issue.

/R

from jredis.

alphazero avatar alphazero commented on June 24, 2024

Alright: http://gist.github.com/480022

I don't know the ETA on this but its clearly doable and at this point I'm inclined to think it is the way to go forward.

There are two ways to play the downtime parameter. One would be in an asynch queuing architecture (which would be a pretty good fit) and the value a function of the queue size. And the other with the normal Req/Resp sync semantics -- e.g. container service - and here the macDowntime is the maximum latency you are willing to tolerate once per every redis.conf::timeout cycle.

from jredis.

nklasens avatar nklasens commented on June 24, 2024

Sounds like you are coming up with a more complicated approach then I did.
Changes like the following are already good enough for me

public class JRedisAsynchClient extends JRedisFutureSupport {

/**
 * @param connectionSpec
 */
public JRedisAsynchClient (ConnectionSpec connectionSpec, boolean connectImmediately) {
    // note: using a shared connection mod
    connectionSpec.isReliable(true);
    connection = new AsynchConnection(connectionSpec, true, connectImmediately);
}

public boolean isActive() {
    return connection.isActive();
}

}

public class AsynchConnection {

private AtomicBoolean firstConnect = new AtomicBoolean(false);

public AsynchConnection(ConnectionSpec connectionSpec, boolean isShared, boolean connectImmediately) throws ClientRuntimeException,
        ProviderException {
    super(connectionSpec, connectImmediately);
    tryFirstConnect();
}

public boolean isActive() {
    if (! firstConnect.get()) {
        tryFirstConnect();
    }

    return isConnected();
}

private void tryFirstConnect() {
    try {
        connect();
        firstConnect.set(true);
    } catch (IllegalStateException e) {
        // some other thread already connected
        firstConnect.set(true);
    } catch (ClientRuntimeException e) {
        Log.error(e.getMessage());
    }
}

}

from jredis.

Related Issues (20)

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.