mirror of https://github.com/grpc/grpc-dart.git
Use new Dart 2 APIs (#99)
* Upgrade to Dart 2 APIs * Run dartfmt * Update CHANGELOG.md * Update pubspec.yaml
This commit is contained in:
parent
72aac2adbe
commit
c32a9e97be
|
@ -1,3 +1,8 @@
|
|||
## 0.6.0+1 - 2018-07-13
|
||||
|
||||
* Updated implementation to use new Dart 2 APIs using
|
||||
[dart2_fix](https://github.com/dart-lang/dart2_fix).
|
||||
|
||||
## 0.6.0 - 2018-07-12
|
||||
|
||||
* Dart SDK upper constraint raised to declare compatability with Dart 2.0 stable.
|
||||
|
|
|
@ -88,7 +88,7 @@ class ServiceAccountAuthenticator extends HttpBasedAuthenticator {
|
|||
String _projectId;
|
||||
|
||||
ServiceAccountAuthenticator(String serviceAccountJson, this._scopes) {
|
||||
final serviceAccount = JSON.decode(serviceAccountJson);
|
||||
final serviceAccount = jsonDecode(serviceAccountJson);
|
||||
_serviceAccountCredentials =
|
||||
new auth.ServiceAccountCredentials.fromJson(serviceAccount);
|
||||
_projectId = serviceAccount['project_id'];
|
||||
|
@ -108,7 +108,7 @@ class JwtServiceAccountAuthenticator extends BaseAuthenticator {
|
|||
String _keyId;
|
||||
|
||||
JwtServiceAccountAuthenticator(String serviceAccountJson) {
|
||||
final serviceAccount = JSON.decode(serviceAccountJson);
|
||||
final serviceAccount = jsonDecode(serviceAccountJson);
|
||||
_serviceAccountCredentials =
|
||||
new auth.ServiceAccountCredentials.fromJson(serviceAccount);
|
||||
_projectId = serviceAccount['project_id'];
|
||||
|
@ -148,13 +148,13 @@ auth.AccessToken _jwtTokenFor(
|
|||
claims['scope'] = scopes.join(' ');
|
||||
}
|
||||
|
||||
final headerBase64 = _base64url(ASCII.encode(JSON.encode(header)));
|
||||
final claimsBase64 = _base64url(UTF8.encode(JSON.encode(claims)));
|
||||
final headerBase64 = _base64url(ascii.encode(jsonEncode(header)));
|
||||
final claimsBase64 = _base64url(utf8.encode(jsonEncode(claims)));
|
||||
|
||||
final data = '$headerBase64.$claimsBase64';
|
||||
|
||||
final signer = new RS256Signer(credentials.privateRSAKey);
|
||||
final signature = signer.sign(ASCII.encode(data));
|
||||
final signature = signer.sign(ascii.encode(data));
|
||||
|
||||
final jwt = '$data.${_base64url(signature)}';
|
||||
|
||||
|
@ -163,5 +163,5 @@ auth.AccessToken _jwtTokenFor(
|
|||
}
|
||||
|
||||
String _base64url(List<int> bytes) {
|
||||
return BASE64URL.encode(bytes).replaceAll('=', '');
|
||||
return base64Url.encode(bytes).replaceAll('=', '');
|
||||
}
|
||||
|
|
|
@ -100,8 +100,7 @@ class ClientCall<Q, R> implements Response {
|
|||
lastSlashPos == -1 ? path : path.substring(0, lastSlashPos);
|
||||
audience = 'https://${connection.authority}$port$audiencePath';
|
||||
}
|
||||
Future
|
||||
.forEach(options.metadataProviders,
|
||||
Future.forEach(options.metadataProviders,
|
||||
(provider) => provider(metadata, audience))
|
||||
.then((_) => _sendRequest(connection, _sanitizeMetadata(metadata)))
|
||||
.catchError(_onMetadataProviderError);
|
||||
|
|
|
@ -89,13 +89,13 @@ class Server {
|
|||
Stream<Socket> server;
|
||||
if (security != null) {
|
||||
_secureServer = await SecureServerSocket.bind(
|
||||
address ?? InternetAddress.ANY_IP_V4,
|
||||
address ?? InternetAddress.anyIPv4,
|
||||
port ?? 443,
|
||||
security.securityContext);
|
||||
server = _secureServer;
|
||||
} else {
|
||||
_insecureServer = await ServerSocket.bind(
|
||||
address ?? InternetAddress.ANY_IP_V4, port ?? 80);
|
||||
address ?? InternetAddress.anyIPv4, port ?? 80);
|
||||
server = _insecureServer;
|
||||
}
|
||||
server.listen((socket) {
|
||||
|
|
|
@ -157,7 +157,7 @@ class _GrpcMessageConversionSink extends ChunkedConversionSink<StreamMessage> {
|
|||
final headers = <String, String>{};
|
||||
for (var header in chunk.headers) {
|
||||
// TODO(jakobr): Handle duplicate header names correctly.
|
||||
headers[ASCII.decode(header.name)] = ASCII.decode(header.value);
|
||||
headers[ascii.decode(header.name)] = ascii.decode(header.value);
|
||||
}
|
||||
// TODO(jakobr): Check :status, go to error mode if not 2xx.
|
||||
_out.add(new GrpcMetadata(headers));
|
||||
|
|
|
@ -26,13 +26,13 @@ String toTimeoutString(Duration duration) {
|
|||
} else if (timeout < cutoff) {
|
||||
return '${timeout}u';
|
||||
} else if (timeout < cutoff * 1000) {
|
||||
return '${timeout~/1000}m';
|
||||
return '${timeout ~/ 1000}m';
|
||||
} else if (timeout < cutoff * 1000 * 1000) {
|
||||
return '${timeout~/1000000}S';
|
||||
return '${timeout ~/ 1000000}S';
|
||||
} else if (timeout < cutoff * 1000 * 1000 * 60) {
|
||||
return '${timeout~/60000000}M';
|
||||
return '${timeout ~/ 60000000}M';
|
||||
} else {
|
||||
return '${timeout~/3600000000}H';
|
||||
return '${timeout ~/ 3600000000}H';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: grpc
|
||||
description: Dart implementation of gRPC.
|
||||
version: 0.6.0
|
||||
version: 0.6.0+1
|
||||
author: Dart Team <misc@dartlang.org>
|
||||
homepage: https://github.com/dart-lang/grpc-dart
|
||||
|
||||
|
|
|
@ -123,7 +123,8 @@ class ClientHarness {
|
|||
stream = new MockStream();
|
||||
fromClient = new StreamController();
|
||||
toClient = new StreamController();
|
||||
when(transport.makeRequest(any, endStream: anyNamed('endStream'))).thenReturn(stream);
|
||||
when(transport.makeRequest(any, endStream: anyNamed('endStream')))
|
||||
.thenReturn(stream);
|
||||
when(transport.onActiveStateChanged = captureAny).thenReturn(null);
|
||||
when(stream.outgoingMessages).thenReturn(fromClient.sink);
|
||||
when(stream.incomingMessages).thenAnswer((_) => toClient.stream);
|
||||
|
@ -152,9 +153,7 @@ class ClientHarness {
|
|||
|
||||
void signalIdle() {
|
||||
final ActiveStateHandler handler =
|
||||
verify(transport.onActiveStateChanged = captureAny)
|
||||
.captured
|
||||
.single;
|
||||
verify(transport.onActiveStateChanged = captureAny).captured.single;
|
||||
expect(handler, isNotNull);
|
||||
handler(false);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue