Skip to content

Latest commit

 

History

History

Readme.md

OpenVectorFormat: FileReaderWriterFactoryGRPCWrapper

This project provides an standalone console-application that wraps the functionality of the FileReaderWriterFactory and exposes it as an gRPC service and can easily be integrated in most progamming languages. The service definition can be found here. For more information on gRPC, see here: gRPC.

To read / write a job all-at-once, call the SimpleJobRead or SimpleJobWrite procedures. If the job is very big and you do not want to keep it in memory all the time, use the PartialJobRead and PartialJobWrite procedures to open a stream and do the reading / writing in parts.

How to build

A docker image with this project prebuild can be found here: https://hub.docker.com/r/digitalproductionaachen/ovf-grpc.

Other than this, there are no prebuild artefacts provided with each release at this time.

To build yourself (skip the first step if you already have .net build environment set up on your machine):

  • Setup dotnet on your machine: Download - be sure to pick a version >= 6, and use the SDK, not the runtime!
  • Download / Clone this repository and enter the root folder
  • Edit the network settings in ReaderWriter\FileReaderWriterFactoryGRPCWrapper\grpc_server_config.json to your needs.
  • Open a command prompt in the root folder
  • Run dotnet run --configuration Release --framework net6 --project .\ReaderWriter\FileReaderWriterFactoryGRPCWrapper\FileReaderWriterFactoryGRPCWrapper.csproj.

How to use

A quick example on how to set up a connection to the gRPC service in C#:

using Grpc.Net.Client;
using Grpc.Core;
using GrpcReaderWriterInterface;
using System;
using System.Collections.Generic;
using System.IO;

namespace OpenVectorFormat.GRPCWrapperDemo
{
    public class DemoGRPCWrapper
    {
        public void SupportedFormat()
        {
            string ip = "127.0.0.1";
            uint port = 50051;
            using GrpcChannel channel = GrpcChannel.ForAddress("http://" + ip + ":" + port.ToString());

            VectorFileHandler.VectorFileHandlerClient client = new VectorFileHandler.VectorFileHandlerClient(channel);
            IsFormatSupportedReply reply = client.IsFormatSupported(new IsFormatSupportedRequest { FileExtension = ".ovf" });
            Console.WriteLine("Format supported for reading: " + reply.ReadSupport.ToString());
            Console.WriteLine("Format supported for writing: " + reply.WriteSupport.ToString());
            
            Console.WriteLine("All formats supported for reading: " + reply.AllReadSupportedFormats);
            Console.WriteLine("All formats supported for writing: " + reply.AllWriteSupportedFormats);

            channel.ShutdownAsync().Wait();
        }
    }
}

Further procedure calls & streaming are done in the unit test for this module: TestGRPCWrapper.cs. However, those examples are all in C#.

For details how to set up a gRPC connection in your preferred language, check out the quick start guide here.