runAppService function

Future<void> runAppService(
  1. PatrolAppService service
)

Starts the gRPC server that runs the PatrolAppService.

Implementation

Future<void> runAppService(PatrolAppService service) async {
  final pipeline = const shelf.Pipeline()
      .addMiddleware(shelf.logRequests())
      .addHandler(service.handle);

  final server = await shelf_io.serve(
    pipeline,
    InternetAddress.anyIPv4,
    service.port,
    poweredByHeader: null,
  );

  server.idleTimeout = _idleTimeout;

  final address = server.address;

  print(
    'PatrolAppService started, address: ${address.address}, host: ${address.host}, port: ${server.port}',
  );
}