I have a simple microservice build with go-kit and protocol buffers. And I have a question about where should I transform request into business-ish data.
For instance, I have following protobuf
import "google/protobuf/empty.proto";
service Location {
rpc DeleteLocation(DeleteLocationRequest) returns (google.protobuf.Empty) {};
}
message DeleteLocationRequest {
string locationUID = 1;
}
A request has uid to delete as a string; however, I would like to use my custom struct
type LocationUID struct {
uuid.UUID
}
So, I'm wondering where it's better to transform incoming string into domain object.
Should I do it inside entrypoint? Get data from reqeust, transform it into LocationUID and then call service with business logic to perform a required action.
Or is it better to place inside service? Pass the whole request object from entrypoint into a service and then, inside service, get reqired data, transform it, validate (and return an error if data is invalid)