getTableService function
Implementation
String getTableService(String serviceFileNamse, String serviceClassName,
String servicePath, String packageName,
{int port = 8080}) {
var content = "import '../src/$serviceFileNamse';"
.add("import 'package:grpc/grpc.dart' as grpc;")
.add("import 'dart:io';")
.add("import 'connection.dart';")
.add('')
.add('class Server {')
.add(' Future<void> main(List<String> args) async {')
.add(' final server = grpc.Server(')
.add(' [$serviceClassName(getConnection())],')
.add(' const <grpc.Interceptor>[],')
.add(' grpc.CodecRegistry(codecs: [grpc.GzipCodec()]),')
.add(' );')
.add(" var sPort = Platform.environment['PORT'];")
.add(' var port = $port;')
.add(' if ((sPort != null) && (sPort.isNotEmpty)) {')
.add(" print('sPort: \$sPort');")
.add(' port = int.parse(sPort);')
.add(' }')
.add(' await server.serve(port: port);')
.add(" print('Server listening on port \${server.port}...');")
.add(' }')
.add('}');
_serviceList =
_serviceList.add(' list.add($serviceClassName(getConnection()));');
_importList = _importList.add(
"import 'package:$packageName/services/$servicePath/lib/src/$serviceFileNamse';");
return content;
}