Giter Club home page Giter Club logo

Comments (3)

oysterpack avatar oysterpack commented on August 31, 2024 1

No - it should not. If the connection is broken, an error occurs writing/reading to/from the connection this future will be resolved with an error. You need to use catchError

connection.done.catchError((_) {
      print('Redis disconnected.');
      _client = null;
    });

from dartis.

jcmellado avatar jcmellado commented on August 31, 2024

Take a look to the Connection class:
https://github.com/jcmellado/dartis/blob/master/lib/src/client/connection.dart

Extract:

  /// Future that is resolved when the connection is closed.
  ///
  /// If the connection closes gracefully this future will be completed and
  /// future attempts to use the connection will throw a
  /// [RedisConnectionClosedException].
  ///
  /// If the connection is broken, an error occurs writing/reading to/from the
  /// connection this future will be resolved with error. If unhandled this
  /// will propagate to the encapsulating [Zone] where it may be handled.
  /// If using the default root [Zone] this will cause the isolate to crash.
  ///
  /// If not implementing custom reconnection logic it might be desirable to
  /// simply restart the process when it crashes.
  ///
  /// If implementing custom reconnection logic, consumers should stop using a
  /// connection once [done] have been resolved, as all future commands will
  /// will throw an error. If an error occurs reading or writing all outstanding
  /// commands will be resolved with an exception.
  Future<void> get done => _done.future;

There some tests about that too:
https://github.com/jcmellado/dartis/blob/master/test/client/connection_test.dart

from dartis.

jodinathan avatar jodinathan commented on August 31, 2024
final connection = await dartis.Connection.connect(
        'redis://${host ?? 'localhost'}:${port}');

    unawaited(connection.done.then((err) {
      print('Redis disconnected.');

      _client = null;
    }));

    _client = await dartis.Client(connection);

The above snippet is not printing the message when I start the app and after stop the local redis service to break the connection.
It shoud, right?

from dartis.

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.