Skip to content

Remove dependency on package:archive #707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Set compressed flag correctly for grpc-encoding = identity. Fixes [#669](https://github.com/grpc/grpc-dart/issues/669) (https://github.com/grpc/grpc-dart/pull/693)
* Remove generated status codes.
* Remove dependency on `package:archive`.

## 3.2.4

Expand Down
15 changes: 15 additions & 0 deletions example/grpc-web/lib/app.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
// for details. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:async';
import 'dart:html';

Expand Down
2 changes: 1 addition & 1 deletion example/helloworld/bin/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// Dart implementation of the gRPC helloworld.Greeter client.
import 'package:grpc/grpc.dart';
import 'package:helloworld/src/generated/helloworld.pbgrpc.dart';

/// Dart implementation of the gRPC helloworld.Greeter client.
Future<void> main(List<String> args) async {
final channel = ClientChannel(
'localhost',
Expand Down
2 changes: 1 addition & 1 deletion example/helloworld/bin/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// Dart implementation of the gRPC helloworld.Greeter server.
import 'package:grpc/grpc.dart';
import 'package:helloworld/src/generated/helloworld.pbgrpc.dart';

/// Dart implementation of the gRPC helloworld.Greeter server.
class GreeterService extends GreeterServiceBase {
@override
Future<HelloReply> sayHello(ServiceCall call, HelloRequest request) async {
Expand Down
2 changes: 1 addition & 1 deletion example/helloworld/bin/unix_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// Dart implementation of the gRPC helloworld.Greeter client.
import 'dart:io';

import 'package:grpc/grpc.dart';
import 'package:helloworld/src/generated/helloworld.pbgrpc.dart';

/// Dart implementation of the gRPC helloworld.Greeter client.
Future<void> main(List<String> args) async {
final udsAddress =
InternetAddress('localhost', type: InternetAddressType.unix);
Expand Down
2 changes: 1 addition & 1 deletion example/helloworld/bin/unix_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// Dart implementation of the gRPC helloworld.Greeter server.
import 'dart:io';

import 'package:grpc/grpc.dart';
import 'package:helloworld/src/generated/helloworld.pbgrpc.dart';

/// Dart implementation of the gRPC helloworld.Greeter server.
class GreeterService extends GreeterServiceBase {
@override
Future<HelloReply> sayHello(ServiceCall call, HelloRequest request) async {
Expand Down
4 changes: 2 additions & 2 deletions interop/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class Tester {
final receivedBytes = response.payload.body.length;
if (receivedBytes != 314159) {
throw 'Response payload mismatch. Expected 314159 bytes, '
'got ${receivedBytes}.';
'got $receivedBytes.';
}
}

Expand Down Expand Up @@ -869,7 +869,7 @@ class Tester {
final receivedBytes = response.payload.body.length;
if (receivedBytes != 314159) {
throw 'Response payload mismatch. Expected 314159 bytes, '
'got ${receivedBytes}.';
'got $receivedBytes.';
}
return response;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/grpc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export 'src/server/server.dart'
export 'src/server/server_keepalive.dart' show ServerKeepAliveOptions;
export 'src/server/service.dart' show ServiceMethod, Service;
export 'src/shared/api.dart';
export 'src/shared/codec.dart' show Codec, IdentityCodec, GzipCodec;
export 'src/shared/codec/codec.dart' show Codec, IdentityCodec, GzipCodec;
export 'src/shared/codec_registry.dart';
export 'src/shared/message.dart'
show GrpcMessage, GrpcMetadata, GrpcData, grpcDecompressor;
Expand Down
2 changes: 1 addition & 1 deletion lib/grpc_connection_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export 'src/client/options.dart' show ChannelOptions;
export 'src/client/transport/transport.dart'
show GrpcTransportStream, ErrorHandler;

export 'src/shared/codec.dart';
export 'src/shared/codec/codec.dart';
export 'src/shared/codec_registry.dart';
export 'src/shared/message.dart' show frame, GrpcMessage, grpcDecompressor;
export 'src/shared/status.dart' show GrpcError;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/client/call.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import 'dart:async';
import 'dart:developer';

import '../shared/codec.dart';
import '../shared/codec/codec.dart';
import '../shared/message.dart';
import '../shared/profiler.dart';
import '../shared/status.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/client/http2_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import 'dart:typed_data';

import 'package:http2/transport.dart';

import '../shared/codec.dart';
import '../shared/codec/codec.dart';
import '../shared/timeout.dart';
import 'call.dart';
import 'client_keepalive.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/client/transport/http2_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import 'dart:async';

import 'package:http2/transport.dart';

import '../../shared/codec.dart';
import '../../shared/codec/codec.dart';
import '../../shared/codec_registry.dart';
import '../../shared/message.dart';
import '../../shared/streams.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/server/handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'dart:convert';

import 'package:http2/transport.dart';

import '../shared/codec.dart';
import '../shared/codec/codec.dart';
import '../shared/codec_registry.dart';
import '../shared/io_bits/io_bits.dart' show InternetAddress, X509Certificate;
import '../shared/message.dart';
Expand Down
18 changes: 18 additions & 0 deletions lib/src/shared/codec/codec.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2020, the gRPC project authors. Please see the AUTHORS file
// for details. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

export 'codec_all.dart';
export 'codec_io.dart'
if (dart.library.js_interop) 'codec_web.dart'; // package:web implementation
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020, the gRPC project authors. Please see the AUTHORS file
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
// for details. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,8 +13,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:archive/archive.dart';

abstract class Codec {
/// Returns the message encoding that this compressor uses.
///
Expand Down Expand Up @@ -48,21 +46,3 @@ class IdentityCodec implements Codec {
return data;
}
}

/// A gzip compressor and decompressor.
class GzipCodec implements Codec {
const GzipCodec();

@override
final encodingName = 'gzip';

@override
List<int> compress(List<int> data) {
return GZipEncoder().encode(data)!;
}

@override
List<int> decompress(List<int> data) {
return GZipDecoder().decodeBytes(data);
}
}
36 changes: 36 additions & 0 deletions lib/src/shared/codec/codec_io.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
// for details. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:io';

import 'codec_all.dart';

/// A gzip compressor and decompressor.
class GzipCodec implements Codec {
const GzipCodec();

@override
final encodingName = 'gzip';

@override
List<int> compress(List<int> data) {
return gzip.encode(data);
}

@override
List<int> decompress(List<int> data) {
return gzip.decode(data);
}
}
34 changes: 34 additions & 0 deletions lib/src/shared/codec/codec_web.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
// for details. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'codec_all.dart';

/// A gzip compressor and decompressor.
class GzipCodec implements Codec {
const GzipCodec();

@override
final encodingName = 'gzip';

@override
List<int> compress(List<int> data) {
throw UnsupportedError('Gzip is not supported for grpc web');
}

@override
List<int> decompress(List<int> data) {
throw UnsupportedError('Gzip is not supported for grpc web');
}
}
2 changes: 1 addition & 1 deletion lib/src/shared/codec_registry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'codec.dart';
import 'codec/codec.dart';

/// Encloses classes related to the compression and decompression of messages.
class CodecRegistry {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/shared/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import 'dart:async';
import 'dart:typed_data';

import 'codec.dart';
import 'codec/codec.dart';
import 'codec_registry.dart';
import 'status.dart';

Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ environment:
sdk: ^3.2.0

dependencies:
archive: ^3.0.0
async: ^2.5.0
crypto: ^3.0.0
fixnum: ^1.0.0
Expand Down
15 changes: 15 additions & 0 deletions test/client_certificate_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
// for details. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// TODO(dartbug.com/26057) currently Mac OS X seems to have some issues with
// client certificates so we disable the test.
@TestOn('vm && !mac-os')
Expand Down
15 changes: 15 additions & 0 deletions test/client_handles_bad_connections_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
// for details. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

@TestOn('vm')
import 'dart:async';

Expand Down
15 changes: 15 additions & 0 deletions test/client_tests/call_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
// for details. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:grpc/src/client/call.dart';
import 'package:test/test.dart';

Expand Down
15 changes: 15 additions & 0 deletions test/client_tests/client_interceptor_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
// for details. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:async';

import 'package:grpc/grpc.dart';
Expand Down
15 changes: 15 additions & 0 deletions test/client_tests/client_keepalive_manager_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
// for details. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:fake_async/fake_async.dart';
import 'package:grpc/src/client/client_keepalive.dart';
import 'package:mockito/annotations.dart';
Expand Down
Loading