feat(client): GrpcWebClientChannel on web targets via conditional import
Some checks failed
Security / Security check (push) Failing after 1s
Some checks failed
Security / Security check (push) Failing after 1s
Splits channel construction into two files selected at compile-time via `if (dart.library.html)`: channel_factory_io.dart — native ClientChannel (HTTP/2) channel_factory_web.dart — GrpcWebClientChannel.xhr (HTTP/1.1) HubClient._channel is now `ClientChannelBase` so both implementations satisfy the same field type. dart:html-only imports (`package:grpc/grpc_web.dart`) stay isolated from the native compile path. Pairs with the hub-side `fai_grpc_web` adapter crate (fai/platform 0d07892) — `tonic-web` on the same port as native gRPC, so one `fai serve` listener handles both surfaces. Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
parent
5604e5eaf3
commit
f481eee687
3 changed files with 49 additions and 13 deletions
17
lib/src/channel_factory_web.dart
Normal file
17
lib/src/channel_factory_web.dart
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Web channel factory — gRPC-Web over HTTP/1.1.
|
||||
// Selected on dart:html targets (Flutter web, Dart-for-web) via
|
||||
// the conditional import in hub_client.dart. The hub must be
|
||||
// running with `tonic-web` enabled — see fai_platform docs
|
||||
// architecture/protocol-surfaces.md.
|
||||
|
||||
import 'package:grpc/grpc_connection_interface.dart';
|
||||
import 'package:grpc/grpc_web.dart';
|
||||
|
||||
import 'hub_client.dart' show HubEndpoint;
|
||||
|
||||
ClientChannelBase createChannel(HubEndpoint endpoint) {
|
||||
final scheme = endpoint.secure ? 'https' : 'http';
|
||||
return GrpcWebClientChannel.xhr(
|
||||
Uri.parse('$scheme://${endpoint.host}:${endpoint.port}'),
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue