nats_protocol 0.4.0

  • README.md
  • Example
  • Installing
  • Versions
  • 8

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]
16
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]
8
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

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.0.0.
 
 Because nats_protocol depends on nuid <0.7.0 which requires SDK version <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.

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

Homepage does not exists. (-20 points)

We were unable to access http://www.github.com/kranfix/dart-nats-protocol at the time of the analysis.

Documentation URL does not exists. (-10 points)

We were unable to access http://www.github.com/kranfix/dart-nats-protocol#readme at the time of the analysis.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

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