Working with gRPC in Java using Spring Boot to provide a service on eventually a service mesh (Istio?) for accessing data on Db2 and eventually making that accessible either through gRPC-web or GraphQL. A very overkill solution to a simple problem, however it does help with practicing with these technologies.

syntax = "proto3";

package io.snynx.namegengrpcinterface;

option java_multiple_files = true;
option java_package = "io.snynx.namegengrpcinterface";
option java_outer_classname = "NameGenGrpc";

service FavoritesService {
  rpc StoreFavorite (Favorite) returns (StoreFavoriteReply);
  rpc GetFavorites (FavoriteRequest) returns (stream Favorite);
}

message Favorite {
  uint64 uid = 1;
  string name1 = 2;
  string name2 = 3;
}

message FavoriteRequest {
  uint64 uid = 1;
}

enum Status {
  Success = 0;
  Error = 1;
}

message StoreFavoriteReply {
  Status status = 1;
}
@Override
public void getFavorites(FavoriteRequest request, StreamObserver<Favorite> responseObserver) {
    repo.getByUid(request.getUid())
            .map(f -> modelMapper.map(f, io.snynx.namegengrpcinterface.Favorite.class))
            .doOnEach(s -> responseObserver.onNext(s.get()));
    responseObserver.onCompleted();
}