nats_dart 0.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 44

Bitbucket Pipelines branch Codecov Dart Version License

nats.dart #

A Dart client for NATS, a lightweight, high-performance cloud native messaging system


Note: this package is still in pre-release and not all features/functionalities are yet implemented. #

Usage #

// create a connection
var client = await Client.connectSingle(natsHost, username: natsUsername, password: natsPassword);

// subscribe to a topic
client.subscribe('myTopic', handler: (DataMessage message, {NatsError error}) {
  log.general.info('ooh, looky! A message for meeeeeee! ::: ${message.decodedPayload}');
});

// publish a message
await client.publish('myTopic', data: 'this is an event on topic: myTopic')); // -- let the client encode it for us (with the default encoder (ascii))

// publish a message with a custom encoding
await client.publish('myTopic', data: 'this is another event on topic: myTopic'), encoding: utf8); // -- specify our own encoding

// publish a message of raw bytes
var alreadyEncodedMessageBytes = ascii.encode('this is a pre-encoded event on topic: myTopic');
await client.publish('myTopic', data: alreadyEncodedMessageBytes, encoding: null); // -- passing a null-encoding tells the client encoding has already been done

See example files for more awesomeness.


Note: this package is still in pre-release and not all features/functionalities are yet implemented. #

Contributors and PRs welcome! #

0.0.1 #

  • Initial version

example/README.md

Examples - nats.dart #

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  nats_dart: ^0.0.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:nats_dart/nats_dart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
11
Health:
Code health derived from static analysis. [more]
75
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
44
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15

Analysis suggestions

Package not compatible with runtime flutter-web on Web

Because:

  • package:nats_dart/nats_dart.dart that imports:
  • dart:io

Package not compatible with runtime js

Because:

  • package:nats_dart/nats_dart.dart that imports:
  • dart:io

Health suggestions

Fix lib/src/classes/factories/MessageFactory.dart. (-8.63 points)

Analysis of lib/src/classes/factories/MessageFactory.dart reported 18 hints, including:

line 6 col 12: Unnecessary new keyword.

line 11 col 12: Unnecessary new keyword.

line 16 col 12: Unnecessary new keyword.

line 21 col 12: Unnecessary new keyword.

line 26 col 12: Unnecessary new keyword.

Fix lib/src/classes/ServerOptions.dart. (-7.24 points)

Analysis of lib/src/classes/ServerOptions.dart reported 15 hints, including:

line 13 col 3: Avoid return types on setters.

line 18 col 3: Avoid return types on setters.

line 23 col 3: Avoid return types on setters.

line 28 col 3: Avoid return types on setters.

line 33 col 3: Avoid return types on setters.

Fix lib/src/classes/factories/MessageProtoFactory.dart. (-4.89 points)

Analysis of lib/src/classes/factories/MessageProtoFactory.dart reported 10 hints, including:

line 6 col 12: Unnecessary new keyword.

line 11 col 12: Unnecessary new keyword.

line 16 col 12: Unnecessary new keyword.

line 21 col 12: Unnecessary new keyword.

line 26 col 12: Unnecessary new keyword.

Fix additional 52 files with analysis or formatting issues. (-33.19 points)

Additional issues in the following files:

  • lib/nats_dart.dart (9 hints)
  • lib/src/classes/Client.dart (9 hints)
  • lib/src/classes/ProtocolHandler.dart (8 hints)
  • lib/src/classes/ServerSet.dart (4 hints)
  • lib/watchdog/_Watchdog.dart (4 hints)
  • lib/src/classes/EventEmitter.dart (3 hints)
  • lib/src/classes/NatsError.dart (3 hints)
  • lib/src/classes/Subscription.dart (3 hints)
  • lib/src/classes/messages/SubMessage.dart (3 hints)
  • lib/src/classes/ClientOptions.dart (2 hints)
  • lib/src/classes/ProtocolParser.dart (2 hints)
  • lib/src/classes/factories/SubscriptionFactory.dart (2 hints)
  • lib/src/classes/messages/UnsubMessage.dart (2 hints)
  • lib/src/utilities/Enums.dart (2 hints)
  • lib/src/utilities/Streams.dart (2 hints)
  • lib/src/classes/SubscriptionList.dart (1 hint)
  • lib/src/classes/factories/ProtocolHandlerFactory.dart (1 hint)
  • lib/src/classes/factories/ProtocolParserFactory.dart (1 hint)
  • lib/src/classes/messages/ConnectMessage.dart (1 hint)
  • lib/src/classes/messages/DataMessage.dart (1 hint)
  • lib/src/classes/messages/interfaces/_PayloadMessage.dart (1 hint)
  • lib/watchdog/AsyncWatchdog.dart (1 hint)
  • lib/watchdog/Heartbeat.dart (1 hint)
  • lib/watchdog/SyncWatchdog.dart (1 hint)
  • lib/src/classes/RequestSubscription.dart (Run dartfmt to format lib/src/classes/RequestSubscription.dart.)
  • lib/src/classes/Server.dart (Run dartfmt to format lib/src/classes/Server.dart.)
  • lib/src/classes/events/ConnectionEvents.dart (Run dartfmt to format lib/src/classes/events/ConnectionEvents.dart.)
  • lib/src/classes/events/SubscriptionEvents.dart (Run dartfmt to format lib/src/classes/events/SubscriptionEvents.dart.)
  • lib/src/classes/events/_Event.dart (Run dartfmt to format lib/src/classes/events/_Event.dart.)
  • lib/src/classes/messages/ErrorMessage.dart (Run dartfmt to format lib/src/classes/messages/ErrorMessage.dart.)
  • lib/src/classes/messages/InfoMessage.dart (Run dartfmt to format lib/src/classes/messages/InfoMessage.dart.)
  • lib/src/classes/messages/OkMessage.dart (Run dartfmt to format lib/src/classes/messages/OkMessage.dart.)
  • lib/src/classes/messages/PingMessage.dart (Run dartfmt to format lib/src/classes/messages/PingMessage.dart.)
  • lib/src/classes/messages/PongMessage.dart (Run dartfmt to format lib/src/classes/messages/PongMessage.dart.)
  • lib/src/classes/messages/PubMessage.dart (Run dartfmt to format lib/src/classes/messages/PubMessage.dart.)
  • lib/src/classes/messages/interfaces/_BidirectionalMessage.dart (Run dartfmt to format lib/src/classes/messages/interfaces/_BidirectionalMessage.dart.)
  • lib/src/classes/messages/interfaces/_IncomingMessage.dart (Run dartfmt to format lib/src/classes/messages/interfaces/_IncomingMessage.dart.)
  • lib/src/classes/messages/interfaces/_OutgoingMessage.dart (Run dartfmt to format lib/src/classes/messages/interfaces/_OutgoingMessage.dart.)
  • lib/src/classes/messages/interfaces/_PresenceMessage.dart (Run dartfmt to format lib/src/classes/messages/interfaces/_PresenceMessage.dart.)
  • lib/src/classes/protos/ConnectMessageProto.dart (Run dartfmt to format lib/src/classes/protos/ConnectMessageProto.dart.)
  • lib/src/classes/protos/DataMessageProto.dart (Run dartfmt to format lib/src/classes/protos/DataMessageProto.dart.)
  • lib/src/classes/protos/ErrorMessageProto.dart (Run dartfmt to format lib/src/classes/protos/ErrorMessageProto.dart.)
  • lib/src/classes/protos/InfoMessageProto.dart (Run dartfmt to format lib/src/classes/protos/InfoMessageProto.dart.)
  • lib/src/classes/protos/OkMessageProto.dart (Run dartfmt to format lib/src/classes/protos/OkMessageProto.dart.)
  • lib/src/classes/protos/PingMessageProto.dart (Run dartfmt to format lib/src/classes/protos/PingMessageProto.dart.)
  • lib/src/classes/protos/PongMessageProto.dart (Run dartfmt to format lib/src/classes/protos/PongMessageProto.dart.)
  • lib/src/classes/protos/PubMessageProto.dart (Run dartfmt to format lib/src/classes/protos/PubMessageProto.dart.)
  • lib/src/classes/protos/SubMessageProto.dart (Run dartfmt to format lib/src/classes/protos/SubMessageProto.dart.)
  • lib/src/classes/protos/UnsubMessageProto.dart (Run dartfmt to format lib/src/classes/protos/UnsubMessageProto.dart.)
  • lib/src/classes/protos/interfaces/_MessageProto.dart (Run dartfmt to format lib/src/classes/protos/interfaces/_MessageProto.dart.)
  • lib/src/classes/protos/interfaces/_PayloadMessageProto.dart (Run dartfmt to format lib/src/classes/protos/interfaces/_PayloadMessageProto.dart.)
  • lib/src/utilities/misc.dart (Run dartfmt to format lib/src/utilities/misc.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (kiwi).

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
event_bus ^1.1.0 1.1.1
kiwi ^0.2.0 0.2.0 2.0.0
logging ^0.11.3+2 0.11.4
meta ^1.1.8 1.2.2 1.3.0-nullsafety
quiver ^2.1.2 2.1.3
quiver_log ^1.0.6 1.0.6 1.0.7-dev.1
uuid ^2.0.2 2.2.0
Transitive dependencies
charcode 1.1.3
collection 1.14.13 1.15.0-nullsafety
convert 2.1.1
crypto 2.1.5
intl 0.16.1
stack_trace 1.9.5
typed_data 1.2.0 1.3.0-nullsafety
Dev dependencies
extra_pedantic ^1.1.1
faker ^1.1.1
matcher ^0.12.6 0.12.8
mockito ^4.1.1
path ^1.6.4 1.7.0
pedantic ^1.8.0+1
test ^1.9.3
test_api ^0.2.10
test_coverage ^0.4.1