nats_dart 0.0.5 copy "nats_dart: ^0.0.5" to clipboard
nats_dart: ^0.0.5 copied to clipboard

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

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', payload: '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', payload: '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', payload: 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! #

5
likes
40
pub points
25%
popularity

Publisher

unverified uploader

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

Homepage
Repository

License

Apache-2.0 (LICENSE)

Dependencies

event_bus, fixnum, kiwi, logging, meta, pedantic, protobuf, quiver, quiver_log, uuid

More

Packages that depend on nats_dart