vyshane/grpc-swift-combine

SPM plugin to generate RemoteDataSource

Opened this issue · 1 comments

Hi,

nice repo, I have an idea - not sure if its gonna work, to add SPM plugin to generate whole RemoteDataSoucre from service using CombineGrpc. Would be a great tool to generate entirely whole server side code 😸

Like:

payService.proto

service PayService {
    rpc pay(Request) returns (Response) {}
}

PayRemoteDataSource.swift

public protocol PayRemoteDataSource {
    //... service methods with GRPC generated structs
   func pay(Request) -> AnyPublisher<Response, RPCError>
}

PayRemoteDataSourceImpl.swift

struct PayRemoteDataSourceImpl: PayRemoteDataSource  {
    //... real implementation using grpcExecutor 
}

I know that is possible but I have no idea how to build this kind of plugin

CombineGRPC is implemented as a wrapper over Swift gRPC, and does not do any code generation. Swift gRPC does provide a protoc plugin for code generation though. Please see this directory for examples of how you could implement the server side with the Swift gRPC generated code + CombineGRPC.

Having said that, I'm not sure I understand your example. You mentioned server side code generation, but it looks like PayRemoteDataSource is used for making gRPC calls to the server? I.e. client code?