streamy 0.0.7

  • README.md
  • Installing
  • Versions
  • 19

Streamy for Dart (experimental)

Build Status

Streamy is a feature-rich RPC/API framework for applications written using Dart programming language. It relies on Google API Discovery file format for API description. Streamy also provides out-of-the-box JSON-over-REST protocol.

Using Streamy your application can:

  • Access many Google APIs, such as Google Calendar API
  • Talk to your own APIs built using Google Cloud Endpoints
  • Talk to your own APIs hosted on your own servers and described using Google Discovery format

Features

  • Rich Entity/Request/Resource objects: mutable, immutable, observable with Map-like interface
  • Fully customizable (in fact, fully replaceable) request handling pipeline
    • Caching
    • Request deduplication
    • API proxy
    • One-shot and keep-alive
    • Tracing
    • Out-of-the-box JSON-over-REST implementation
    • Transactional API
    • Request batching

5-Minute Tutorial

Let's write a command-line program that shortens URLs using Google URL Shortener API.

What you need for this tutorial

  • Dart SDK (add Dart's bin folder to your PATH)

Get Full Streamy

The simplest way is to use git:

> git clone https://github.com/google/streamy-dart.git streamy-dart
> cd streamy-dart

Can't I just get it from pub?

Yes, and no. You can and should use pub to import Streamy runtime library necessary to run your app. However, Streamy comes with command-line tools to work with Discovery files and generate API client libraries, so you need to download the full version.

Get a Discovery file

Find one for the API you want to access. Let's use Google URL shortener as example:

> curl https://www.googleapis.com/discovery/v1/apis/urlshortener/v1/rest >urlshortener.json

Generate client library

> dart bin/apigen.dart \
    --discovery_file=urlshortener.json \
    --client_file=urlshortener.dart \
    --library_name=urlshortener

What just happened?

The apigen.dart program provided by Streamy reads the discovery file (urlshortener.json in the example) and produces a Dart file (urlshortener.dart in the example) that contains an API client library for the API described in the discovery file. You can also give the library your own custom name (urlshortener in the example).

Use it

Let's create an entry point for our program, called main.dart, which contains the following code:

import 'urlshortener.dart';
import 'package:streamy/impl_server.dart';

main(List<String> args) {
  var requestHandler = new ServerRequestHandler();
  var api = new Urlshortener(requestHandler);
  api.url.insert(new Url()..longUrl = args[0])
    .send().listen((Url response) {
      print('Shortened to ${response.id}');
    });
}

We are done. Let's run the program:

> dart main.dart http://www.google.com

This should print something like:

Shortened to http://goo.gl/fbsS

What just happened?

import 'urlshortener.dart';

This line imports the API client library that we just generated from the discovery file.

import 'package:streamy/impl_server.dart';

This import provides an implementation of Streamy's RequestHandler interface. This particular implementation works for server-side and command-line apps. If your app runs in the web-browser, use package:streamy/impl_html.dart and HtmlRequestHandler instead.

main() {
  var requestHandler = new ServerRequestHandler();
  var api = new Urlshortener(requestHandler);

The above two lines instantiate a Urlshortener API client backed by ServerRequestHandler.

  api.url.insert(new Url()..longUrl = args[0])

This is an example of how you create an API request. Streamy API generator generates a fully type-annotated root API class (Urlshortener), resources (url), resource methods (insert), entity classes (Url) as well as getters/setters for properties on the entities (longUrl), so you can use auto-completion in your IDE and rely on compiler warnings to tell you about issues in your usage of the API.

    .send().listen((Url response) {
      print('Shortened to ${response.id}');
    });

Finally, we .send() the request to the server and .listen(...) to a Stream of responses.

}

Use this package as a library

1. Depend on it

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


dependencies:
  streamy: "^0.0.7"

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:streamy/streamy.dart';
  
Version Uploaded Documentation Archive
0.0.7 Nov 19, 2013 Go to the documentation of streamy 0.0.7 Download streamy 0.0.7 archive
0.0.4 Jun 20, 2013 Go to the documentation of streamy 0.0.4 Download streamy 0.0.4 archive
0.0.2 Jun 18, 2013 Go to the documentation of streamy 0.0.2 Download streamy 0.0.2 archive
0.0.1 Jun 18, 2013 Go to the documentation of streamy 0.0.1 Download streamy 0.0.1 archive

Analysis

We analyzed this package on Jul 17, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

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

Platforms

Detected platforms: unsure

Error(s) prevent platform classification:

Error(s) in lib/testing/testing.dart: Target of URI doesn't exist: 'package:unittest/unittest.dart'.

Suggestions

  • Fix platform conflicts.

    Error(s) prevent platform classification:

    Error(s) in lib/testing/testing.dart: Target of URI doesn't exist: 'package:unittest/unittest.dart'.

  • Running dartdoc failed.

    Make sure dartdoc runs without any issues.

  • Maintain CHANGELOG.md.

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

  • Use constrained dependencies.

    The pubspec.yaml contains 8 dependencies without version constraints. Specify version ranges for the following dependencies: args, browser, fixnum, json, meta, mustache, observe, quiver.

  • Package is too old.

    The package was released more than two years ago.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 45 errors 52 hints.

    Make sure that the imported libraries are not in conflict. Error(s) in lib/testing/testing.dart: Target of URI doesn't exist: 'package:unittest/unittest.dart'.

    Make sure that the imported libraries are not in conflict. Error(s) in lib/runtime/global.dart: Classes can only extend other classes.

    Similar analysis of the following files failed:

    • lib/runtime/entity/wrapper.dart (error)
    • lib/generator/discovery.dart (error)
    • lib/generator/emitter.dart (error)
    • lib/impl_server.dart (error)
    • lib/indexed_cache.dart (error)
    • lib/runtime/entity/raw.dart (error)
    • lib/runtime/entity/util.dart (error)
    • lib/runtime/multiplexer.dart (error)
    • lib/runtime/request.dart (error)
    • lib/testing/dynamic_entity.dart (error)
    • lib/generator.dart (hint)
    • lib/generator/default.dart (hint)
    • lib/impl.dart (hint)
    • lib/impl_html.dart (hint)
    • lib/runtime/batching.dart (hint)
    • lib/runtime/cache.dart (hint)
    • lib/runtime/entity/base.dart (hint)
    • lib/runtime/entity/empty.dart (hint)
    • lib/runtime/error.dart (hint)
    • lib/runtime/http.dart (hint)
    • lib/runtime/json.dart (hint)
    • lib/runtime/proxy.dart (hint)
    • lib/runtime/response.dart (hint)
    • lib/runtime/transforms.dart (hint)
    • lib/runtime/util.dart (hint)
    • lib/streamy.dart (hint)
  • 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 API.

  • The description is too long.

    Search engines will display only the first part of the description. Try to keep it under 180 characters.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use streamy.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=0.8.7
args >=0.8.7 0.13.7 1.4.3
browser any 0.10.0+3
fixnum >=0.8.7 0.10.7
json >=0.8.7 0.10.0
meta >=0.8.7 1.1.5
mustache >=0.1.5 1.0.1
observe >=0.8.7 0.14.0 0.15.1
quiver >=0.12.0 0.29.0+1
Transitive dependencies
analyzer 0.27.6 0.32.3
async 2.0.7
barback 0.15.2+16
charcode 1.1.2
cli_util 0.0.1+2 0.1.3+2
code_transformers 0.4.2+3 0.5.1+5
collection 1.14.10
convert 2.0.1
crypto 2.0.6
csslib 0.14.4 0.14.4+1
func 0.1.1 1.0.0
glob 1.1.6
html 0.13.3+1
isolate 0.2.3 2.0.1
logging 0.11.3+1
matcher 0.12.3+1
observable 0.14.0+1 0.22.1+3
package_config 1.0.3
plugin 0.2.0+2
pool 1.3.5
smoke 0.3.6+3
source_maps 0.10.6
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
typed_data 1.1.5
utf 0.9.0+5
watcher 0.9.7+9
when 0.2.0
which 0.1.3
yaml 2.1.14
Dev dependencies
benchmark_harness >=0.8.7
path any 1.6.1
unittest any