consul_kv_dart 1.0.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 50

consul_kv_dart

Dart client for the Consul KV-store. Wraps Consul's simple key/value store API. Client uses HTTP requests to communicate with Consul. Each method has optional parameters that are described in Consul API docs. You might want to wrap responses into some kind of handler (check status codes, encode\convert values, etc.) - result is a flexible Response object. Each method return Future which is used to get result.

Usage

A simple usage example:

Future main() async {
  var consul = new ConsulKV(port: 5579, defaultHeaders: {'X-Consul-Token': 'bcd1234'});
  var newKey = await consul.put('foo', 'bar');
  var foundKey = await consul.get('foo');
  var insertIfNotExists = await consul.put('foo', 'bar', cas: 1);
  var deleteKey = await consul.delete('foo');
  var keyNotExists = await consul.get('foo');

  print(newKey.body); // true
  print(newKey.statusCode); // 200

  print(foundKey.body); // [{"LockIndex":0,"Key":"foo","Value":"YmFy",
                        // "CreateIndex":208877,"ModifyIndex":208877}]
  print(foundKey.statusCode);  // 200

  print(insertIfNotExists.body); // false
  print(insertIfNotExists.statusCode); // 200

  print(deleteKey.body); // true
  print(deleteKey.statusCode); // 200

  print(keyNotExists.statusCode); // 404

  consul.close();

}

Changelog

1.0.2

  • Resolving docgen issues

1.0.1

  • Description update

1.0.0

  • Initial version

example/consul_kv_dart_example.dart

/// Simple example of usage

import 'dart:async';
import 'package:consul_kv_dart/consul_kv_dart.dart';

Future main() async {
  var consul = new ConsulKV(defaultHeaders: {'X-Consul-Token': 'bcd1234'});
  var newKey = await consul.put('foo', 'bar');
  var foundKey = await consul.get('foo');
  var insertIfNotExists = await consul.put('foo', 'bar', cas: 1);
  var deleteKey = await consul.delete('foo');
  var keyNotExists = await consul.get('foo');

  print(newKey.body); // true
  print(newKey.statusCode); // 200

  print(foundKey.body); // [{"LockIndex":0,"Key":"foo","Value":"YmFy",
                        // "CreateIndex":208877,"ModifyIndex":208877}]
  print(foundKey.statusCode);  // 200

  print(insertIfNotExists.body); // false
  print(insertIfNotExists.statusCode); // 200

  print(deleteKey.body); // true
  print(deleteKey.statusCode); // 200

  print(keyNotExists.statusCode); // 404

  consul.close();

}

1. Depend on it

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


dependencies:
  consul_kv_dart: "^1.0.2"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:consul_kv_dart/consul_kv_dart.dart';
        
Version Uploaded Documentation Archive
1.0.2 Jan 18, 2018 Go to the documentation of consul_kv_dart 1.0.2 Download consul_kv_dart 1.0.2 archive
1.0.1 Jan 18, 2018 Go to the documentation of consul_kv_dart 1.0.1 Download consul_kv_dart 1.0.1 archive
1.0.0 Jan 18, 2018 Go to the documentation of consul_kv_dart 1.0.0 Download consul_kv_dart 1.0.0 archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
99 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
50

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:consul_kv_dart/consul_kv_dart.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
http ^0.11.3+16 0.11.3+16
Transitive dependencies
async 2.0.3
charcode 1.1.1
collection 1.14.5
http_parser 3.1.1
path 1.5.1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
test ^0.12.0