jcmellado / dartis Goto Github PK
View Code? Open in Web Editor NEWRedis client for Dart
License: MIT License
Redis client for Dart
License: MIT License
I am kinda new to Redis and surely new to RediSearch and, from what I am studying, using RediSearch is dependent on the client you are using.
As I couldn't find an example with RediSearch in the documentation, I wonder if is it possible to use RediSearch with this package?
I was digging through the pipline feature in the lib and I am wondering if it can lead to weird behavior?
It sets _pipeline
to true and then the subsequent command calls are stored and only executed when calling flush
, however, can't it also store command calls from other parts of the code?
If we have two places in the code using the same client and one is using pipeline and other isn't, if they run at same time, wouldn't the commands that aren't supposed to be in pipeline also be executed in the pipeline because of the pipeline call?
Is this expected?
Should I create another client just for pipelining purposes?
I am not an expert in Redis and this is my first time using pipeline, so I wouldn't know.
I am starting the app, connect to a redis server, restart the redis server to break the connection, the apps try to fetch something and this is the result:
SocketException: OS Error: Connection reset by peer, errno = 54, address = 127.0.0.1, port = 58691
#0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1112:29)
#1 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#2 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#3 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:116:13)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:173:5)
However, I can't seem to catch this exception nor know before hand if the connection is broken.
How can I know when to reconnect when needed?
Getting this error when running on Web:
Error: Unsupported operation: Socket constructor
at Object.throw_ [as throw] (http://localhost:58623/dart_sdk.js:4348:11)
at Function._connect (http://localhost:58623/dart_sdk.js:57921:17)...
This package is working great, when deploying to Heroku and using their secure connection string, this package, per documentation, doesn't support a username/password at this time in the connection string. I'm going to try and see if I can add it and create a PR.
Result of automated pub analysis:
The description is too long.
- Search engines will display only the first part of the description. Try to keep it under 180 characters.
Hi,
Can you lower the SDK constraint to use 1.24?
A lot of VM packages are not yet compatible with Dart 2 unfortunately.
Is it somehow possible to supply the password to the redis server when connecting with PubSub?
I have redis in the cloud service. The connection string looks like redis://login:password@host:port.
When executing any command, it gives an error: RedisException: NOAUTH Authentication required.
How make auth?
Add support to work with Redis in streams mode, modeled after PubSub
.
Given that we've now enabled consumers to handled broken connections, can we publish a version 0.2.1?
Hi there I was trying to connect to my redis upstash cluster it needs tls or rediss protocol support while the dartis driver doesn't support any of them can you enable tls or rediss (redis Secure) protocol in the next release please?
EDIT: I found how to connect
import the "dart:io" library for the SecureSocket class
make sure if the Connection class is exported by dartis library then import it
use the :
Client( Connection(await SecureSocket.connect(HOST, PORT) ) );
then do the rest of the work
This code is running but publish command is not run. Error is: "ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context" Connection is OK, from Node.js message is received. What can I do?
final broker = PubSub<String, String>(client.connection);
// Outputs the data received from the server.
broker.stream.listen(print, onError: print, onDone: () => exit(0));
// Subscribes the client to some channels.
var hchannel='haber';
var kanal=broker.subscribe(channel: hchannel);
var bmessage='Ilk Mesajımız geldi mi?';
commands.publish(hchannel, bmessage);
My app wasn't getting errors nor the _done was being completed and it wasn't executing anything after the first 3 seconds of running.
Then I added _socket.flush();
after _socket.add(data);
in the void send(List<int> data) {}
method at lib/src/connection.dart
and it started working again.
I am not familiar with the internals of socket stuff... What can it be?
void main() async {
final pubsub = await redis.PubSub.connect<String, String>('redis://localhost:6379');
// Subscribe to some channels and patterns
pubsub
..subscribe(channel: 'dev.dart')
..psubscribe(pattern: 'message');
// Listen for server replies
pubsub.stream.listen(print, onDone: (){
print('done');
});
the onDone:(){print('done')} never worked when get a message from redis.
All i want is running a custom function with the message received from redis when a new message come in.
SOS!
Instead of this:
final client = await Client.connect('redis://myredis:8889');
final commands = client.asCommands<String, String>();
await commands.auth('password');
it is more elegant to do this:
final client = await Client.connect('redis://username:password@myredis:8889');
final commands = client.asCommands<String, String>();
As far as I can see connection errors are not handled and thrown to the global exception handler, which terminates the process. But in many cases it might be nice to support reconnecting.
If using redis as a single key/value cache... it would be preferred to reconnect and retry get/sets instead of crashing the entire process.
I think it's possible to handle errors by setting up a zone and handling the error, but:
I think we could solve (2) by resolving all _unreplied
commands in:
dartis/lib/src/client/client.dart
Lines 282 to 285 in 00a30eb
Otherwise, we essentially have futures that will never be resolved. We can just complete all the futures with some generic error, but without an error downstreamer are going to hang..
Am I missing something? I'm not sure exactly how to expose the error from (1), but if the commands return with a specific error when the connection is broken then it becomes a lot easier to wrap with retry logic.
File token.dart is unformatted
Most Redis clients use a custom exception when a watched value changes, that way it can accurately be detected. However, Dartis doesn't seem to support this. Could it be added?
BTW this is easily the best Redis library for Dart out there!
It works fine when I enable non SSL port in my Azure Cache for Redis. But when I enable SSL port 6380, this is the error I get: E/flutter ( 5132): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: SocketException: OS Error: Connection reset by peer, errno = 104, address = redisabhinav.redis.cache.windows.net, port = 44958
Code:
final client = await redis.Client.connect(
'redis://SampleName.redis.cache.windows.net:6380');
// Runs some commands.
final commands = client.asCommands<String, String>();
await commands.auth("<YourKey>");
// SET key value
await commands.set('key1', 'value1');
// GET key
final value = await commands.get('key1');
print(value);
// Disconnects.
await client.disconnect();
I think using the SecureSocket might help.
I was running into a seemingly random race condition error of the form:
RedisException: ERR MULTI calls can not be nested
and traced it down to asynchronous code execution. I.e., imagine you are sharing one Redis connection across several handlers, I was running into the following situation:
HANDLER 1:
await client.multi()
... starts waiting ...
HANDLER 2:
await client.multi()
throws ERROR bcz execution has not yet returned to HANDLER 1
I ended up implementing my own "transaction queueing" system (one per client connection), to ensure that I never had more than one MULTI/EXEC sequence in flight at a time. I found that with all the inherent asynchrony of dart, it could be very hard if not impossible to guarantee that you never nested calls.
I wanted to a) make sure I'm not just doing something stupid, i.e., is there a better or simpler solution, and b) assuming this is a realistic scenario, wanted to put forward the idea of embedding this sort of transaction queueing in the library itself. I thought it a somewhat subtle bug that only cropped up when I started running unit tests with multiple handlers firing off, and even then, it was far from 100%. With queueing embedded in the library itself, it might prevent people from shooting themselves in the foot.
It seems like a good idea to support timeout of commands like get
and set
and break the connection, if the timeout is violated..
This could be handled further down the stack, but consumers of this library. But it could also be an option passed to Client
when created.
Hello, I was using dartis in a project and I run into the problem that when I try to use hgetall dart crash.
Code:
final redis = await Client.connect('redis://localhost:6379');
final cmd = redis.asCommands<String, dynamic>();
final result = await cmd.hgetall('test');
print(result);
Error:
Unhandled exception:
RedisException: Unexpected value of type "BulkReply".
#0 _MultiConverter.convert (package:dartis/src/protocol/codec.dart:95:5)
#1 RedisCodec.decode (package:dartis/src/protocol/codec.dart:65:41)
#2 HashMapper.map (package:dartis/src/commands/hash.dart:163:27)
#3 CommandBase._complete (package:dartis/src/command/command.dart:91:20)
#4 CommandBase.complete (package:dartis/src/command/command.dart:65:19)
#5 _ClientDispatcher.onReply (package:dartis/src/client/client.dart:260:15)
#6 ReplyDispatcher._dispatch (package:dartis/src/client/dispatcher.dart:90:7)
#7 ReplyDispatcher.onData (package:dartis/src/client/dispatcher.dart:78:9)
#8 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#9 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#10 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#11 _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#12 _StreamController._add (dart:async/stream_controller.dart:639:7)
#13 _StreamController.add (dart:async/stream_controller.dart:585:5)
#14 _Socket._onData (dart:io/runtime/binsocket_patch.dart:1721:41)
#15 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#16 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#17 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#18 _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#19 _StreamController._add (dart:async/stream_controller.dart:639:7)
#20 _StreamController.add (dart:async/stream_controller.dart:585:5)
#21 new _RawSocket.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:1283:33)
#22 _NativeSocket.issueReadEvent.issue (dart:io/runtime/binsocket_patch.dart:826:14)
#23 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#24 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#25 _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#26 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
I've noticed that your README says in the Publish/Subscribe section:
In this mode the only allowed commands are
subscribe
,unsubscribe
,psubscribe
,punsubscribe
,ping
andquit
.
Is there any planned support for the publish
operation?
What is the best way to reconnect to Redis when the connection goes stale?
Do you plan to migrating to null safety?
The DateTimeDecoder class in the documentation is wrong.
It's checking if the given reply is null, but it must check if the bytes attribute of the reply is null instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.