nats_protocol 0.4.0

  • README.md
  • Example
  • Installing
  • Versions
  • 42

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]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
64
Overall:
Weighted score of the above. [more]
42
Learn more about scoring.

We analyzed this package on Aug 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status tool failures using:

  • Dart: 2.0.0
  • pana: 0.11.8

Platforms

Detected platforms: unsure

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

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 any which requires SDK version <2.0.0, version solving failed.

Fix platform conflicts.

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Maintain CHANGELOG.md.

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

The description is too short.

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

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

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.

Dependencies

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