mirror of https://github.com/grpc/grpc-dart.git
Fix interop tests (#651)
* Fix interop tests * Keepalive cleanups * Prepare for publish
This commit is contained in:
parent
8886dfd24b
commit
c7e07a09a5
|
@ -1,8 +1,9 @@
|
||||||
## 3.2.3-wip
|
## 3.2.3
|
||||||
|
|
||||||
* Add const constructor to `GrpcError` fixing #606.
|
* Add const constructor to `GrpcError` fixing #606.
|
||||||
* Make `GrpcError` non-final to allow implementations.
|
* Make `GrpcError` non-final to allow implementations.
|
||||||
* Only send keepalive pings on open connections.
|
* Only send keepalive pings on open connections.
|
||||||
|
* Fix interop tests.
|
||||||
|
|
||||||
## 3.2.2
|
## 3.2.2
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ export 'src/auth/auth_io.dart'
|
||||||
ServiceAccountAuthenticator;
|
ServiceAccountAuthenticator;
|
||||||
export 'src/client/call.dart' show ClientCall;
|
export 'src/client/call.dart' show ClientCall;
|
||||||
export 'src/client/client.dart' show Client;
|
export 'src/client/client.dart' show Client;
|
||||||
|
export 'src/client/client_keepalive.dart' show ClientKeepAliveOptions;
|
||||||
export 'src/client/client_transport_connector.dart'
|
export 'src/client/client_transport_connector.dart'
|
||||||
show ClientTransportConnector;
|
show ClientTransportConnector;
|
||||||
export 'src/client/connection.dart' show ConnectionState;
|
export 'src/client/connection.dart' show ConnectionState;
|
||||||
|
@ -50,6 +51,7 @@ export 'src/server/server.dart'
|
||||||
ServerTlsCredentials,
|
ServerTlsCredentials,
|
||||||
ConnectionServer,
|
ConnectionServer,
|
||||||
Server;
|
Server;
|
||||||
|
export 'src/server/server_keepalive.dart' show ServerKeepAliveOptions;
|
||||||
export 'src/server/service.dart' show ServiceMethod, Service;
|
export 'src/server/service.dart' show ServiceMethod, Service;
|
||||||
export 'src/shared/api.dart';
|
export 'src/shared/api.dart';
|
||||||
export 'src/shared/codec.dart' show Codec, IdentityCodec, GzipCodec;
|
export 'src/shared/codec.dart' show Codec, IdentityCodec, GzipCodec;
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ClientKeepAliveOptions {
|
||||||
|
|
||||||
const ClientKeepAliveOptions({
|
const ClientKeepAliveOptions({
|
||||||
this.pingInterval,
|
this.pingInterval,
|
||||||
this.timeout = const Duration(milliseconds: 20000),
|
this.timeout = const Duration(seconds: 20),
|
||||||
this.permitWithoutCalls = false,
|
this.permitWithoutCalls = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ class ClientKeepAlive {
|
||||||
final void Function() ping;
|
final void Function() ping;
|
||||||
|
|
||||||
final ClientKeepAliveOptions _options;
|
final ClientKeepAliveOptions _options;
|
||||||
Duration get _pingInterval => _options.pingInterval ?? Duration(days: 365);
|
Duration get _pingInterval => _options.pingInterval!;
|
||||||
|
|
||||||
ClientKeepAlive({
|
ClientKeepAlive({
|
||||||
required ClientKeepAliveOptions options,
|
required ClientKeepAliveOptions options,
|
||||||
|
@ -236,7 +236,9 @@ class ClientKeepAlive {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setState(KeepAliveEvent event) {
|
void _setState(KeepAliveEvent event) {
|
||||||
final newState = state.onEvent(event, this);
|
if (_options.shouldSendPings) {
|
||||||
if (newState != null) state = newState;
|
final newState = state.onEvent(event, this);
|
||||||
|
if (newState != null) state = newState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ class ConnectionServer {
|
||||||
final CodecRegistry? _codecRegistry;
|
final CodecRegistry? _codecRegistry;
|
||||||
final GrpcErrorHandler? _errorHandler;
|
final GrpcErrorHandler? _errorHandler;
|
||||||
final ServerKeepAliveOptions _keepAliveOptions;
|
final ServerKeepAliveOptions _keepAliveOptions;
|
||||||
final List<ServerHandler> _handlers = [];
|
final Map<ServerTransportConnection, List<ServerHandler>> _handlers = {};
|
||||||
|
|
||||||
final _connections = <ServerTransportConnection>[];
|
final _connections = <ServerTransportConnection>[];
|
||||||
|
|
||||||
|
@ -117,6 +117,7 @@ class ConnectionServer {
|
||||||
InternetAddress? remoteAddress,
|
InternetAddress? remoteAddress,
|
||||||
}) async {
|
}) async {
|
||||||
_connections.add(connection);
|
_connections.add(connection);
|
||||||
|
_handlers[connection] = [];
|
||||||
// TODO(jakobr): Set active state handlers, close connection after idle
|
// TODO(jakobr): Set active state handlers, close connection after idle
|
||||||
// timeout.
|
// timeout.
|
||||||
final onDataReceivedController = StreamController<void>();
|
final onDataReceivedController = StreamController<void>();
|
||||||
|
@ -128,7 +129,7 @@ class ConnectionServer {
|
||||||
dataNotifier: onDataReceivedController.stream,
|
dataNotifier: onDataReceivedController.stream,
|
||||||
).handle();
|
).handle();
|
||||||
connection.incomingStreams.listen((stream) {
|
connection.incomingStreams.listen((stream) {
|
||||||
_handlers.add(serveStream_(
|
_handlers[connection]!.add(serveStream_(
|
||||||
stream: stream,
|
stream: stream,
|
||||||
clientCertificate: clientCertificate,
|
clientCertificate: clientCertificate,
|
||||||
remoteAddress: remoteAddress,
|
remoteAddress: remoteAddress,
|
||||||
|
@ -143,10 +144,11 @@ class ConnectionServer {
|
||||||
// half-closed tcp streams.
|
// half-closed tcp streams.
|
||||||
// Half-closed streams seems to not be fully supported by package:http2.
|
// Half-closed streams seems to not be fully supported by package:http2.
|
||||||
// https://github.com/dart-lang/http2/issues/42
|
// https://github.com/dart-lang/http2/issues/42
|
||||||
for (var handler in _handlers) {
|
for (var handler in _handlers[connection]!) {
|
||||||
handler.cancel();
|
handler.cancel();
|
||||||
}
|
}
|
||||||
_connections.remove(connection);
|
_connections.remove(connection);
|
||||||
|
_handlers.remove(connection);
|
||||||
await onDataReceivedController.close();
|
await onDataReceivedController.close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,7 @@ class ServerKeepAliveOptions {
|
||||||
final Duration minIntervalBetweenPingsWithoutData;
|
final Duration minIntervalBetweenPingsWithoutData;
|
||||||
|
|
||||||
const ServerKeepAliveOptions({
|
const ServerKeepAliveOptions({
|
||||||
this.minIntervalBetweenPingsWithoutData =
|
this.minIntervalBetweenPingsWithoutData = const Duration(minutes: 5),
|
||||||
const Duration(milliseconds: 300000),
|
|
||||||
this.maxBadPings = 2,
|
this.maxBadPings = 2,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: grpc
|
name: grpc
|
||||||
description: Dart implementation of gRPC, a high performance, open-source universal RPC framework.
|
description: Dart implementation of gRPC, a high performance, open-source universal RPC framework.
|
||||||
version: 3.2.3-wip
|
version: 3.2.3
|
||||||
|
|
||||||
repository: https://github.com/grpc/grpc-dart
|
repository: https://github.com/grpc/grpc-dart
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import 'package:grpc/grpc.dart';
|
||||||
import 'package:grpc/src/client/client_keepalive.dart';
|
import 'package:grpc/src/client/client_keepalive.dart';
|
||||||
import 'package:grpc/src/client/connection.dart';
|
import 'package:grpc/src/client/connection.dart';
|
||||||
import 'package:grpc/src/client/http2_connection.dart';
|
import 'package:grpc/src/client/http2_connection.dart';
|
||||||
import 'package:grpc/src/server/server_keepalive.dart';
|
|
||||||
import 'package:http2/transport.dart';
|
import 'package:http2/transport.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import 'dart:convert';
|
||||||
|
|
||||||
import 'package:grpc/grpc.dart';
|
import 'package:grpc/grpc.dart';
|
||||||
import 'package:grpc/src/client/channel.dart' as base;
|
import 'package:grpc/src/client/channel.dart' as base;
|
||||||
import 'package:grpc/src/client/client_keepalive.dart';
|
|
||||||
import 'package:grpc/src/client/http2_connection.dart';
|
import 'package:grpc/src/client/http2_connection.dart';
|
||||||
import 'package:grpc/src/shared/message.dart';
|
import 'package:grpc/src/shared/message.dart';
|
||||||
import 'package:http2/transport.dart';
|
import 'package:http2/transport.dart';
|
||||||
|
|
Loading…
Reference in New Issue