Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Riak Dart client

Riak database client, written in Dart.

Features

Available Riak functionality:

  • fetch, store and delete objects (with vclock, vtag and last modified preconditions)
  • store and query secondary index
  • get and set bucket properties
  • resolve conflicts if parallel writes produce siblings
  • counters (fetch, increment/decrement)

Dart client design goals:

  • Meaningful wrapper objects
  • Immutable structures (exception: JSON content, but changes won't be pushed)

Usage Examples

Create an HTTP client and target a bucket:

Client client = new Client.http('127.0.0.1', 10017);
Bucket exampleBucket = client.getBucket('example');

Fetch a text object:

String exampleKey = 'text_example_key';

exampleBucket.fetch(exampleKey).then((Response value) {
  String text = value.result.content.asText;
  ... do something with text ...
});

Fetch a JSON object:

String exampleKey = 'json_example_key';

exampleBucket.fetch(exampleKey).then((Response value) {
  Map json = value.result.content.asJson;
  ... do something with JSON ...
});

Store a text object:

String key = 'text_message';
String message = 'hello from the Dart server';
Content content = new Content.text(message);

exampleBucket.store(key, content).then((Response response) {
  ... do something with response ...
});

Store a JSON object:

String key = 'json_message';
Map json = { 'foo': 'bar' };
Content content = new Content.json(json);

exampleBucket.store(key, content).then((Response response) {
  ... do something with response ...
});

List all buckets (not recommended in production environments):

client.listBuckets().toList().then((List<String> buckets) {
  print(buckets);
});

List all keys in a bucket (also not recommended in production environments):

bucket.listKeys().toList().then((List<String> keys) {
  print(keys);
});

Modify an existing object using a vclock:

String key = 'text_message';
String newMessage = 'this is the most up-to-date message';

exampleBucket.fetch(key).then((Response value) {
  if (value.code == 200) {
    String v = value.result.vclock;
    Content content = new Content.text(newMessage);
    exampleBucket.store(key, content, vclock: v).then((Response response) {
      print(response.code);
    });
  } else {
    print('Not found');
  }
});

Roadmap

0.7

  • map-reduce support
  • link-walking support
  • list-resources support

0.8

  • protobuf client implementation
  • mixed client (protobuf / http, based on the request)
  • search support

0.9

  • mock backend for testing (in-memory and filesystem)
  • configurable retry-on-failure
  • robust stream handling (e.g. what to do on backend failure, re-start?)
  • non-buffered HTTP response processing
  • pooling client (simple round-robin)

1.0

  • stable API
  • pool monitoring and stats

The order might vary, depending on the contributor's requirements. If you would like to add something, contact us (see AUTHORS or pubspec file).

Migration guide

0.4 -> 0.5

  • full API changed

0.5 -> 0.6

  • Renamed BucketProps's fields to follow the Dart conventions (n_val -> replicas, allow_mult -> allowSiblings, last_write_wins -> lastWriteWins).
  • Renamed Quorum's fields to follow the Dart conventions (basic_quorum -> basicQuorum, not_found_ok -> notFoundIsSuccess).

References

About

Riak database client, written in Dart.

Resources

License

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages