nats_protocol 0.4.0

  • README.md
  • Example
  • Installing
  • Versions
  • 0

dart-nats-protocol #

A Nats.io protocol parser in Dart language

example/example.dart

import 'dart:typed_data';
import 'package:nats_protocol/parser.dart';
import 'package:nats_protocol/client_base.dart';
import 'package:nats_protocol/src/utils.dart';

String msgSimple = "MSG foo.bar 1 21\r\nMessage without reply\r\n";
String msgReply  = "MSG foo.bar 1 _inbox.45 18\r\nMessage with reply\r\n";
String msgOk = "+OK\r\n";
String msgErr = "-ERR 'Some error message'\r\n";
String msgPing = "PING\r\n";
String msgPong = "PONG\r\n";
String msgInfo = 'INFO {"server_id":"U6XtKb2U7oS0Hx18dNEraV","version":"1.0.6","git_commit":"","go":"go1.9.4","host":"0.0.0.0","port":4222,"auth_required":false,"ssl_required":false,"tls_required":false,"tls_verify":false,"max_payload":1048576}\r\n';


class Client extends NatsClientBase {}

final NatsClientBase nc = new Client();
NatsParser parser = new NatsParser(nc);

main() async {
  Uint8List bufSimple = string2bytes(msgSimple);
  Uint8List bufReply  = string2bytes(msgReply);
  Uint8List bufOk     = string2bytes(msgOk);
  Uint8List bufErr    = string2bytes(msgErr);
  Uint8List bufPing   = string2bytes(msgPing);
  Uint8List bufPong   = string2bytes(msgPong);
  Uint8List bufInfo   = string2bytes(msgInfo);


  print('----------------------');
  print('Msg:\n$msgSimple');
  parser.parse(bufSimple);

  print('----------------------');
  print('Msg:\n$msgReply');
  parser.parse(bufReply);

  print('----------------------');
  print('Msg:\n$msgOk');
  parser.parse(bufOk);

  print('----------------------');
  print('Msg:\n$msgErr');
  parser.parse(bufErr);

  print('----------------------');
  print('Msg:\n$msgPing');
  parser.parse(bufPing);

  print('----------------------');
  print('Msg:\n$msgPong');
  parser.parse(bufPong);

  print('----------------------');
  print('Msg:\n$msgPong');
  parser.parse(bufInfo);

  print('----------------------');
}

Use this package as a library

1. Depend on it

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


dependencies:
  nats_protocol: ^0.4.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support 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_protocol/client_base.dart';
import 'package:nats_protocol/parser.dart';
  
Version Uploaded Documentation Archive
0.4.0 May 19, 2018 Go to the documentation of nats_protocol 0.4.0 Download nats_protocol 0.4.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

We analyzed this package on Apr 4, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms:

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.2.0.
 
 Because nats_protocol requires SDK version >=1.23.0 <=2.0.0, version solving failed.

Health suggestions

Format lib/client_base.dart.

Run dartfmt to format lib/client_base.dart.

Format lib/parser.dart.

Run dartfmt to format lib/parser.dart.

Format lib/src/const.dart.

Run dartfmt to format lib/src/const.dart.

Format lib/src/msg.dart.

Run dartfmt to format lib/src/msg.dart.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Support the latest stable Dart SDK in pubspec.yaml. (-20 points)

The SDK constraint in pubspec.yaml doesn't allow the latest stable Dart SDK release.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field http://www.github.com/kranfix/dart-nats-protocol was unreachable.

Documentation URL doesn't exist. (-10 points)

At the time of the analysis the documentation field http://www.github.com/kranfix/dart-nats-protocol#readme was unreachable.

The package description is too short. (-19 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.23.0 <=2.0.0