Skip to content

Commit 0d02e43

Browse files
authored
Remove dependency on package:archive (grpc#707)
* Remove dependency on package:archive * Test compression on vm only * Add licenses * Fix analyze issues * Fix codec web * Fix licenses * Add changelog
1 parent 078fd23 commit 0d02e43

39 files changed

+408
-38
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* 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)
44
* Remove generated status codes.
5+
* Remove dependency on `package:archive`.
56

67
## 3.2.4
78

example/grpc-web/lib/app.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
2+
// for details. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
116
import 'dart:async';
217
import 'dart:html';
318

example/helloworld/bin/client.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

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

19+
/// Dart implementation of the gRPC helloworld.Greeter client.
2020
Future<void> main(List<String> args) async {
2121
final channel = ClientChannel(
2222
'localhost',

example/helloworld/bin/server.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

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

19+
/// Dart implementation of the gRPC helloworld.Greeter server.
2020
class GreeterService extends GreeterServiceBase {
2121
@override
2222
Future<HelloReply> sayHello(ServiceCall call, HelloRequest request) async {

example/helloworld/bin/unix_client.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

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

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

21+
/// Dart implementation of the gRPC helloworld.Greeter client.
2222
Future<void> main(List<String> args) async {
2323
final udsAddress =
2424
InternetAddress('localhost', type: InternetAddressType.unix);

example/helloworld/bin/unix_server.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

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

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

21+
/// Dart implementation of the gRPC helloworld.Greeter server.
2222
class GreeterService extends GreeterServiceBase {
2323
@override
2424
Future<HelloReply> sayHello(ServiceCall call, HelloRequest request) async {

interop/lib/src/client.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class Tester {
208208
final receivedBytes = response.payload.body.length;
209209
if (receivedBytes != 314159) {
210210
throw 'Response payload mismatch. Expected 314159 bytes, '
211-
'got ${receivedBytes}.';
211+
'got $receivedBytes.';
212212
}
213213
}
214214

@@ -869,7 +869,7 @@ class Tester {
869869
final receivedBytes = response.payload.body.length;
870870
if (receivedBytes != 314159) {
871871
throw 'Response payload mismatch. Expected 314159 bytes, '
872-
'got ${receivedBytes}.';
872+
'got $receivedBytes.';
873873
}
874874
return response;
875875
}

lib/grpc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export 'src/server/server.dart'
5555
export 'src/server/server_keepalive.dart' show ServerKeepAliveOptions;
5656
export 'src/server/service.dart' show ServiceMethod, Service;
5757
export 'src/shared/api.dart';
58-
export 'src/shared/codec.dart' show Codec, IdentityCodec, GzipCodec;
58+
export 'src/shared/codec/codec.dart' show Codec, IdentityCodec, GzipCodec;
5959
export 'src/shared/codec_registry.dart';
6060
export 'src/shared/message.dart'
6161
show GrpcMessage, GrpcMetadata, GrpcData, grpcDecompressor;

lib/grpc_connection_interface.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export 'src/client/options.dart' show ChannelOptions;
2525
export 'src/client/transport/transport.dart'
2626
show GrpcTransportStream, ErrorHandler;
2727

28-
export 'src/shared/codec.dart';
28+
export 'src/shared/codec/codec.dart';
2929
export 'src/shared/codec_registry.dart';
3030
export 'src/shared/message.dart' show frame, GrpcMessage, grpcDecompressor;
3131
export 'src/shared/status.dart' show GrpcError;

lib/src/client/call.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import 'dart:async';
1717
import 'dart:developer';
1818

19-
import '../shared/codec.dart';
19+
import '../shared/codec/codec.dart';
2020
import '../shared/message.dart';
2121
import '../shared/profiler.dart';
2222
import '../shared/status.dart';

lib/src/client/http2_connection.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import 'dart:typed_data';
2020

2121
import 'package:http2/transport.dart';
2222

23-
import '../shared/codec.dart';
23+
import '../shared/codec/codec.dart';
2424
import '../shared/timeout.dart';
2525
import 'call.dart';
2626
import 'client_keepalive.dart';

lib/src/client/transport/http2_transport.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import 'dart:async';
1717

1818
import 'package:http2/transport.dart';
1919

20-
import '../../shared/codec.dart';
20+
import '../../shared/codec/codec.dart';
2121
import '../../shared/codec_registry.dart';
2222
import '../../shared/message.dart';
2323
import '../../shared/streams.dart';

lib/src/server/handler.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import 'dart:convert';
1818

1919
import 'package:http2/transport.dart';
2020

21-
import '../shared/codec.dart';
21+
import '../shared/codec/codec.dart';
2222
import '../shared/codec_registry.dart';
2323
import '../shared/io_bits/io_bits.dart' show InternetAddress, X509Certificate;
2424
import '../shared/message.dart';

lib/src/shared/codec/codec.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2020, the gRPC project authors. Please see the AUTHORS file
2+
// for details. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
export 'codec_all.dart';
17+
export 'codec_io.dart'
18+
if (dart.library.js_interop) 'codec_web.dart'; // package:web implementation

lib/src/shared/codec.dart renamed to lib/src/shared/codec/codec_all.dart

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, the gRPC project authors. Please see the AUTHORS file
1+
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
22
// for details. All rights reserved.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,8 +13,6 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16-
import 'package:archive/archive.dart';
17-
1816
abstract class Codec {
1917
/// Returns the message encoding that this compressor uses.
2018
///
@@ -48,21 +46,3 @@ class IdentityCodec implements Codec {
4846
return data;
4947
}
5048
}
51-
52-
/// A gzip compressor and decompressor.
53-
class GzipCodec implements Codec {
54-
const GzipCodec();
55-
56-
@override
57-
final encodingName = 'gzip';
58-
59-
@override
60-
List<int> compress(List<int> data) {
61-
return GZipEncoder().encode(data)!;
62-
}
63-
64-
@override
65-
List<int> decompress(List<int> data) {
66-
return GZipDecoder().decodeBytes(data);
67-
}
68-
}

lib/src/shared/codec/codec_io.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
2+
// for details. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
import 'dart:io';
17+
18+
import 'codec_all.dart';
19+
20+
/// A gzip compressor and decompressor.
21+
class GzipCodec implements Codec {
22+
const GzipCodec();
23+
24+
@override
25+
final encodingName = 'gzip';
26+
27+
@override
28+
List<int> compress(List<int> data) {
29+
return gzip.encode(data);
30+
}
31+
32+
@override
33+
List<int> decompress(List<int> data) {
34+
return gzip.decode(data);
35+
}
36+
}

lib/src/shared/codec/codec_web.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
2+
// for details. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
import 'codec_all.dart';
17+
18+
/// A gzip compressor and decompressor.
19+
class GzipCodec implements Codec {
20+
const GzipCodec();
21+
22+
@override
23+
final encodingName = 'gzip';
24+
25+
@override
26+
List<int> compress(List<int> data) {
27+
throw UnsupportedError('Gzip is not supported for grpc web');
28+
}
29+
30+
@override
31+
List<int> decompress(List<int> data) {
32+
throw UnsupportedError('Gzip is not supported for grpc web');
33+
}
34+
}

lib/src/shared/codec_registry.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16-
import 'codec.dart';
16+
import 'codec/codec.dart';
1717

1818
/// Encloses classes related to the compression and decompression of messages.
1919
class CodecRegistry {

lib/src/shared/message.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import 'dart:async';
1717
import 'dart:typed_data';
1818

19-
import 'codec.dart';
19+
import 'codec/codec.dart';
2020
import 'codec_registry.dart';
2121
import 'status.dart';
2222

pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ environment:
88
sdk: ^3.2.0
99

1010
dependencies:
11-
archive: ^3.0.0
1211
async: ^2.5.0
1312
crypto: ^3.0.0
1413
fixnum: ^1.0.0

test/client_certificate_test.dart

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

test/client_handles_bad_connections_test.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
2+
// for details. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
116
@TestOn('vm')
217
import 'dart:async';
318

test/client_tests/call_test.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
2+
// for details. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
116
import 'package:grpc/src/client/call.dart';
217
import 'package:test/test.dart';
318

test/client_tests/client_interceptor_test.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
2+
// for details. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
116
import 'dart:async';
217

318
import 'package:grpc/grpc.dart';

test/client_tests/client_keepalive_manager_test.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
// Copyright (c) 2024, the gRPC project authors. Please see the AUTHORS file
2+
// for details. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
116
import 'package:fake_async/fake_async.dart';
217
import 'package:grpc/src/client/client_keepalive.dart';
318
import 'package:mockito/annotations.dart';

0 commit comments

Comments
 (0)