build_grpc_channel

Creator: coderz1093

Last updated:

0 purchases

build_grpc_channel Image
build_grpc_channel Images

Languages

Categories

Add to Cart

Description:

build grpc channel

The package for building grpc channel depending on is it web or not
Features #

The util builds gRPC channel for flutter web or other platforms conditionally, depending on the runtime environment

Usage #
const webAppPort = 8888;
const someGrpcServicePort = 5555;
const host = 'http://127.0.0.1';

// for web I suggest to use Envoy as a proxy routing from webAppPort to someGrpcServicePort
int get port => kIsWeb ? webAppPort : someGrpcServicePort;

class SomeGrpcService {
late final SomeGrpcClient stub;

SomeGrpcService() {
init();
}

void init() {
final channel = buildGrpcChannel(host: host, port: port, secure: false);
stub = SomeGrpcClient(channel);
}

Future<SomeRpcResponse> someRpc(SomeRpcRequest request) {
final response = stub.sendQuestion(request);
return response;
}
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.